@nylas/web-elements 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/dist/cdn/checkbox-component/checkbox-component.es.js +48 -38
  2. package/dist/cdn/multi-select-dropdown/multi-select-dropdown.es.js +554 -535
  3. package/dist/cdn/nylas-additional-participants/nylas-additional-participants.es.js +2 -2
  4. package/dist/cdn/nylas-booking-form/nylas-booking-form.es.js +25 -9
  5. package/dist/cdn/nylas-booking-form-config/nylas-booking-form-config.es.js +2182 -2171
  6. package/dist/cdn/nylas-buffer-time/nylas-buffer-time.es.js +13 -14
  7. package/dist/cdn/nylas-calendar-picker/nylas-calendar-picker.es.js +571 -552
  8. package/dist/cdn/nylas-connected-calendars/nylas-connected-calendars.es.js +26 -7
  9. package/dist/cdn/nylas-customize-booking-settings/nylas-customize-booking-settings.es.js +12 -2
  10. package/dist/cdn/nylas-date-component/nylas-date-component.es.js +13 -7
  11. package/dist/cdn/nylas-editor-tabs/nylas-editor-tabs.es.js +3550 -3473
  12. package/dist/cdn/nylas-event-location/nylas-event-location.es.js +633 -621
  13. package/dist/cdn/nylas-limit-future-bookings/nylas-limit-future-bookings.es.js +25 -2
  14. package/dist/cdn/nylas-min-booking-notice/nylas-min-booking-notice.es.js +25 -2
  15. package/dist/cdn/nylas-min-cancellation-notice/nylas-min-cancellation-notice.es.js +163 -140
  16. package/dist/cdn/nylas-page-styling/nylas-page-styling.es.js +5 -3
  17. package/dist/cdn/nylas-participants-custom-availability/nylas-participants-custom-availability.es.js +4 -3
  18. package/dist/cdn/nylas-provider/nylas-provider.es.js +1 -1
  19. package/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +173 -96
  20. package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +28 -12
  21. package/dist/cdn/scheduler-store/scheduler-store.es.js +1 -1
  22. package/dist/cdn/time-period-selector/time-period-selector.es.js +25 -2
  23. package/dist/cjs/calendar-agenda-fill-icon_53.cjs.entry.js +88 -57
  24. package/dist/cjs/calendar-agenda-fill-icon_53.cjs.entry.js.map +1 -1
  25. package/dist/cjs/checkbox-component.cjs.entry.js +9 -1
  26. package/dist/cjs/checkbox-component.cjs.entry.js.map +1 -1
  27. package/dist/cjs/checkbox-component_3.cjs.entry.js +21 -8
  28. package/dist/cjs/checkbox-component_3.cjs.entry.js.map +1 -1
  29. package/dist/cjs/google-logo-icon_4.cjs.entry.js +2 -2
  30. package/dist/cjs/loader.cjs.js +1 -1
  31. package/dist/cjs/multi-select-dropdown.cjs.entry.js +19 -1
  32. package/dist/cjs/multi-select-dropdown.cjs.entry.js.map +1 -1
  33. package/dist/cjs/nylas-additional-participants.cjs.entry.js +1 -1
  34. package/dist/cjs/nylas-additional-participants.cjs.entry.js.map +1 -1
  35. package/dist/cjs/nylas-booking-form-config.cjs.entry.js +34 -27
  36. package/dist/cjs/nylas-booking-form-config.cjs.entry.js.map +1 -1
  37. package/dist/cjs/nylas-buffer-time.cjs.entry.js +13 -12
  38. package/dist/cjs/nylas-buffer-time.cjs.entry.js.map +1 -1
  39. package/dist/cjs/nylas-connected-calendars.cjs.entry.js +2 -2
  40. package/dist/cjs/nylas-connected-calendars.cjs.entry.js.map +1 -1
  41. package/dist/cjs/nylas-date-component.cjs.entry.js +12 -7
  42. package/dist/cjs/nylas-date-component.cjs.entry.js.map +1 -1
  43. package/dist/cjs/nylas-editor-tabs.cjs.entry.js +2 -2
  44. package/dist/cjs/nylas-event-location.cjs.entry.js +32 -11
  45. package/dist/cjs/nylas-event-location.cjs.entry.js.map +1 -1
  46. package/dist/cjs/nylas-page-styling.cjs.entry.js +3 -2
  47. package/dist/cjs/nylas-page-styling.cjs.entry.js.map +1 -1
  48. package/dist/cjs/nylas-participants-custom-availability.cjs.entry.js +3 -2
  49. package/dist/cjs/nylas-participants-custom-availability.cjs.entry.js.map +1 -1
  50. package/dist/cjs/nylas-provider.cjs.entry.js +1 -1
  51. package/dist/cjs/nylas-scheduling.cjs.entry.js +3 -3
  52. package/dist/cjs/nylas-web-elements.cjs.js +1 -1
  53. package/dist/cjs/{scheduler-store-37a0e152.js → scheduler-store-2cd220d1.js} +2 -2
  54. package/dist/cjs/{scheduler-store-37a0e152.js.map → scheduler-store-2cd220d1.js.map} +1 -1
  55. package/dist/cjs/{scheduler-store-373adf03.js → scheduler-store-70af2279.js} +2 -2
  56. package/dist/cjs/{scheduler-store-373adf03.js.map → scheduler-store-70af2279.js.map} +1 -1
  57. package/dist/cjs/time-period-selector.cjs.entry.js +21 -1
  58. package/dist/cjs/time-period-selector.cjs.entry.js.map +1 -1
  59. package/dist/collection/components/design-system/checkbox-component/checkbox-component.js +12 -1
  60. package/dist/collection/components/design-system/checkbox-component/checkbox-component.js.map +1 -1
  61. package/dist/collection/components/design-system/multi-select-dropdown/multi-select-dropdown.js +22 -1
  62. package/dist/collection/components/design-system/multi-select-dropdown/multi-select-dropdown.js.map +1 -1
  63. package/dist/collection/components/design-system/nylas-date-component/nylas-date-component.js +14 -8
  64. package/dist/collection/components/design-system/nylas-date-component/nylas-date-component.js.map +1 -1
  65. package/dist/collection/components/design-system/nylas-date-component/test/nylas-date-component.spec.js +39 -0
  66. package/dist/collection/components/design-system/nylas-date-component/test/nylas-date-component.spec.js.map +1 -0
  67. package/dist/collection/components/design-system/time-period-selector/time-period-selector.js +28 -1
  68. package/dist/collection/components/design-system/time-period-selector/time-period-selector.js.map +1 -1
  69. package/dist/collection/components/scheduler/nylas-date-picker/test/nylas-date-picker.spec.js +3 -1
  70. package/dist/collection/components/scheduler/nylas-date-picker/test/nylas-date-picker.spec.js.map +1 -1
  71. package/dist/collection/components/scheduler-editor/nylas-additional-participants/nylas-additional-participants.js +1 -1
  72. package/dist/collection/components/scheduler-editor/nylas-additional-participants/nylas-additional-participants.js.map +1 -1
  73. package/dist/collection/components/scheduler-editor/nylas-booking-form-config/nylas-booking-form-config.js +36 -27
  74. package/dist/collection/components/scheduler-editor/nylas-booking-form-config/nylas-booking-form-config.js.map +1 -1
  75. package/dist/collection/components/scheduler-editor/nylas-booking-form-config/test/nylas-booking-form-config.spec.js +23 -0
  76. package/dist/collection/components/scheduler-editor/nylas-booking-form-config/test/nylas-booking-form-config.spec.js.map +1 -1
  77. package/dist/collection/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.js +13 -12
  78. package/dist/collection/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.js.map +1 -1
  79. package/dist/collection/components/scheduler-editor/nylas-calendar-picker/test/nylas-calendar-picker.spec.js +13 -0
  80. package/dist/collection/components/scheduler-editor/nylas-calendar-picker/test/nylas-calendar-picker.spec.js.map +1 -1
  81. package/dist/collection/components/scheduler-editor/nylas-connected-calendars/nylas-connected-calendars.js +2 -2
  82. package/dist/collection/components/scheduler-editor/nylas-connected-calendars/nylas-connected-calendars.js.map +1 -1
  83. package/dist/collection/components/scheduler-editor/nylas-event-location/nylas-event-location.js +35 -10
  84. package/dist/collection/components/scheduler-editor/nylas-event-location/nylas-event-location.js.map +1 -1
  85. package/dist/collection/components/scheduler-editor/nylas-page-styling/nylas-page-styling.js +4 -1
  86. package/dist/collection/components/scheduler-editor/nylas-page-styling/nylas-page-styling.js.map +1 -1
  87. package/dist/collection/components/scheduler-editor/nylas-participants-custom-availability/nylas-participants-custom-availability.js +3 -2
  88. package/dist/collection/components/scheduler-editor/nylas-participants-custom-availability/nylas-participants-custom-availability.js.map +1 -1
  89. package/dist/components/checkbox-component2.js +12 -2
  90. package/dist/components/checkbox-component2.js.map +1 -1
  91. package/dist/components/multi-select-dropdown2.js +22 -2
  92. package/dist/components/multi-select-dropdown2.js.map +1 -1
  93. package/dist/components/nylas-additional-participants2.js +1 -1
  94. package/dist/components/nylas-additional-participants2.js.map +1 -1
  95. package/dist/components/nylas-booking-form-config2.js +35 -27
  96. package/dist/components/nylas-booking-form-config2.js.map +1 -1
  97. package/dist/components/nylas-buffer-time2.js +13 -12
  98. package/dist/components/nylas-buffer-time2.js.map +1 -1
  99. package/dist/components/nylas-connected-calendars2.js +2 -2
  100. package/dist/components/nylas-connected-calendars2.js.map +1 -1
  101. package/dist/components/nylas-date-component2.js +14 -8
  102. package/dist/components/nylas-date-component2.js.map +1 -1
  103. package/dist/components/nylas-editor-tabs2.js +2 -2
  104. package/dist/components/nylas-event-location2.js +35 -12
  105. package/dist/components/nylas-event-location2.js.map +1 -1
  106. package/dist/components/nylas-page-styling2.js +5 -3
  107. package/dist/components/nylas-page-styling2.js.map +1 -1
  108. package/dist/components/nylas-participants-custom-availability2.js +3 -2
  109. package/dist/components/nylas-participants-custom-availability2.js.map +1 -1
  110. package/dist/components/nylas-scheduling.js +2 -2
  111. package/dist/components/scheduler-store.js +1 -1
  112. package/dist/components/time-period-selector2.js +26 -2
  113. package/dist/components/time-period-selector2.js.map +1 -1
  114. package/dist/esm/calendar-agenda-fill-icon_53.entry.js +88 -57
  115. package/dist/esm/calendar-agenda-fill-icon_53.entry.js.map +1 -1
  116. package/dist/esm/checkbox-component.entry.js +9 -1
  117. package/dist/esm/checkbox-component.entry.js.map +1 -1
  118. package/dist/esm/checkbox-component_3.entry.js +21 -8
  119. package/dist/esm/checkbox-component_3.entry.js.map +1 -1
  120. package/dist/esm/google-logo-icon_4.entry.js +2 -2
  121. package/dist/esm/loader.js +1 -1
  122. package/dist/esm/multi-select-dropdown.entry.js +19 -1
  123. package/dist/esm/multi-select-dropdown.entry.js.map +1 -1
  124. package/dist/esm/nylas-additional-participants.entry.js +1 -1
  125. package/dist/esm/nylas-additional-participants.entry.js.map +1 -1
  126. package/dist/esm/nylas-booking-form-config.entry.js +34 -27
  127. package/dist/esm/nylas-booking-form-config.entry.js.map +1 -1
  128. package/dist/esm/nylas-buffer-time.entry.js +13 -12
  129. package/dist/esm/nylas-buffer-time.entry.js.map +1 -1
  130. package/dist/esm/nylas-connected-calendars.entry.js +2 -2
  131. package/dist/esm/nylas-connected-calendars.entry.js.map +1 -1
  132. package/dist/esm/nylas-date-component.entry.js +12 -7
  133. package/dist/esm/nylas-date-component.entry.js.map +1 -1
  134. package/dist/esm/nylas-editor-tabs.entry.js +2 -2
  135. package/dist/esm/nylas-event-location.entry.js +32 -11
  136. package/dist/esm/nylas-event-location.entry.js.map +1 -1
  137. package/dist/esm/nylas-page-styling.entry.js +3 -2
  138. package/dist/esm/nylas-page-styling.entry.js.map +1 -1
  139. package/dist/esm/nylas-participants-custom-availability.entry.js +3 -2
  140. package/dist/esm/nylas-participants-custom-availability.entry.js.map +1 -1
  141. package/dist/esm/nylas-provider.entry.js +1 -1
  142. package/dist/esm/nylas-scheduling.entry.js +3 -3
  143. package/dist/esm/nylas-web-elements.js +1 -1
  144. package/dist/esm/{scheduler-store-20151a77.js → scheduler-store-3acf4d70.js} +2 -2
  145. package/dist/esm/{scheduler-store-20151a77.js.map → scheduler-store-3acf4d70.js.map} +1 -1
  146. package/dist/esm/{scheduler-store-b6d12f40.js → scheduler-store-79dc16cc.js} +2 -2
  147. package/dist/esm/{scheduler-store-b6d12f40.js.map → scheduler-store-79dc16cc.js.map} +1 -1
  148. package/dist/esm/time-period-selector.entry.js +21 -1
  149. package/dist/esm/time-period-selector.entry.js.map +1 -1
  150. package/dist/nylas-web-elements/checkbox-component.entry.js +9 -1
  151. package/dist/nylas-web-elements/checkbox-component.entry.js.map +1 -1
  152. package/dist/nylas-web-elements/multi-select-dropdown.entry.js +19 -1
  153. package/dist/nylas-web-elements/multi-select-dropdown.entry.js.map +1 -1
  154. package/dist/nylas-web-elements/nylas-additional-participants.entry.js +1 -1
  155. package/dist/nylas-web-elements/nylas-additional-participants.entry.js.map +1 -1
  156. package/dist/nylas-web-elements/nylas-booking-form-config.entry.js +34 -27
  157. package/dist/nylas-web-elements/nylas-booking-form-config.entry.js.map +1 -1
  158. package/dist/nylas-web-elements/nylas-buffer-time.entry.js +13 -12
  159. package/dist/nylas-web-elements/nylas-buffer-time.entry.js.map +1 -1
  160. package/dist/nylas-web-elements/nylas-connected-calendars.entry.js +2 -2
  161. package/dist/nylas-web-elements/nylas-connected-calendars.entry.js.map +1 -1
  162. package/dist/nylas-web-elements/nylas-date-component.entry.js +12 -7
  163. package/dist/nylas-web-elements/nylas-date-component.entry.js.map +1 -1
  164. package/dist/nylas-web-elements/nylas-editor-tabs.entry.js +2 -2
  165. package/dist/nylas-web-elements/nylas-event-location.entry.js +32 -11
  166. package/dist/nylas-web-elements/nylas-event-location.entry.js.map +1 -1
  167. package/dist/nylas-web-elements/nylas-page-styling.entry.js +3 -2
  168. package/dist/nylas-web-elements/nylas-page-styling.entry.js.map +1 -1
  169. package/dist/nylas-web-elements/nylas-participants-custom-availability.entry.js +3 -2
  170. package/dist/nylas-web-elements/nylas-participants-custom-availability.entry.js.map +1 -1
  171. package/dist/nylas-web-elements/nylas-provider.entry.js +1 -1
  172. package/dist/nylas-web-elements/nylas-scheduling.entry.js +3 -3
  173. package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
  174. package/dist/nylas-web-elements/p-040b8553.entry.js +2 -0
  175. package/dist/nylas-web-elements/p-040b8553.entry.js.map +1 -0
  176. package/dist/nylas-web-elements/p-13a83f9a.entry.js +8 -0
  177. package/dist/nylas-web-elements/p-13a83f9a.entry.js.map +1 -0
  178. package/dist/nylas-web-elements/p-1a9fc29a.entry.js +2 -0
  179. package/dist/nylas-web-elements/p-1a9fc29a.entry.js.map +1 -0
  180. package/dist/nylas-web-elements/{p-e543a827.entry.js → p-1dedce7c.entry.js} +2 -2
  181. package/dist/nylas-web-elements/{p-284c14bb.js → p-53f7b360.js} +2 -2
  182. package/dist/nylas-web-elements/p-7f100474.entry.js +2 -0
  183. package/dist/nylas-web-elements/p-7f100474.entry.js.map +1 -0
  184. package/dist/nylas-web-elements/{p-70d36207.entry.js → p-84e69241.entry.js} +2 -2
  185. package/dist/nylas-web-elements/{p-36c73819.entry.js → p-ad7f8831.entry.js} +2 -2
  186. package/dist/nylas-web-elements/{scheduler-store-b6d12f40.js → scheduler-store-79dc16cc.js} +2 -2
  187. package/dist/nylas-web-elements/{scheduler-store-b6d12f40.js.map → scheduler-store-79dc16cc.js.map} +1 -1
  188. package/dist/nylas-web-elements/time-period-selector.entry.js +21 -1
  189. package/dist/nylas-web-elements/time-period-selector.entry.js.map +1 -1
  190. package/dist/types/components/design-system/checkbox-component/checkbox-component.d.ts +1 -0
  191. package/dist/types/components/design-system/multi-select-dropdown/multi-select-dropdown.d.ts +2 -0
  192. package/dist/types/components/design-system/nylas-date-component/nylas-date-component.d.ts +1 -0
  193. package/dist/types/components/design-system/time-period-selector/time-period-selector.d.ts +3 -0
  194. package/dist/types/components/scheduler-editor/nylas-booking-form-config/nylas-booking-form-config.d.ts +2 -0
  195. package/dist/types/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.d.ts +2 -0
  196. package/dist/types/components/scheduler-editor/nylas-event-location/nylas-event-location.d.ts +3 -0
  197. package/dist/types/components/scheduler-editor/nylas-participants-custom-availability/nylas-participants-custom-availability.d.ts +2 -2
  198. package/package.json +1 -1
  199. package/dist/nylas-web-elements/p-2fa604d7.entry.js +0 -2
  200. package/dist/nylas-web-elements/p-2fa604d7.entry.js.map +0 -1
  201. package/dist/nylas-web-elements/p-52b9c0cb.entry.js +0 -2
  202. package/dist/nylas-web-elements/p-52b9c0cb.entry.js.map +0 -1
  203. package/dist/nylas-web-elements/p-9db69aed.entry.js +0 -2
  204. package/dist/nylas-web-elements/p-9db69aed.entry.js.map +0 -1
  205. package/dist/nylas-web-elements/p-a1a75dc7.entry.js +0 -8
  206. package/dist/nylas-web-elements/p-a1a75dc7.entry.js.map +0 -1
  207. /package/dist/nylas-web-elements/{p-e543a827.entry.js.map → p-1dedce7c.entry.js.map} +0 -0
  208. /package/dist/nylas-web-elements/{p-284c14bb.js.map → p-53f7b360.js.map} +0 -0
  209. /package/dist/nylas-web-elements/{p-70d36207.entry.js.map → p-84e69241.entry.js.map} +0 -0
  210. /package/dist/nylas-web-elements/{p-36c73819.entry.js.map → p-ad7f8831.entry.js.map} +0 -0
@@ -18,6 +18,7 @@ export class NylasDateComponent {
18
18
  this.requiredError = '';
19
19
  this.value = undefined;
20
20
  this.error = '';
21
+ this.isDateValid = true;
21
22
  }
22
23
  handleDefaultValueChange(newValue) {
23
24
  this.value = sanitize(newValue);
@@ -38,16 +39,16 @@ export class NylasDateComponent {
38
39
  }
39
40
  }
40
41
  async handleFormSubmitted(event) {
41
- if (this.el?.getAttribute('data-page-styling')) {
42
- this.validatePattern(this.value);
43
- if (this.error) {
44
- event.preventDefault();
45
- }
42
+ this.validatePattern(this.value);
43
+ if (this.error) {
44
+ event.preventDefault();
46
45
  }
47
46
  }
48
47
  handleInput(e) {
49
48
  this.error = '';
50
- this.value = sanitize(e.target.value);
49
+ const target = e.target;
50
+ this.value = sanitize(target.value);
51
+ this.isDateValid = target.validity.valid;
51
52
  this.nylasFormInputChanged.emit({
52
53
  value: this.value,
53
54
  name: this.name,
@@ -70,6 +71,10 @@ export class NylasDateComponent {
70
71
  }
71
72
  validatePattern(value) {
72
73
  this.error = '';
74
+ if (!this.isDateValid) {
75
+ this.error = 'Please enter a valid date';
76
+ return;
77
+ }
73
78
  if (this.required && !value) {
74
79
  this.error = this.requiredError || 'This field is required.';
75
80
  return;
@@ -84,7 +89,7 @@ export class NylasDateComponent {
84
89
  }
85
90
  }
86
91
  render() {
87
- return (h("label", { key: '959c6b772ea4f2f4706d72255d1e36ea8d4fcbd3', part: "ic__label", class: { error: !!this.error } }, this.label && (h("p", null, h("span", { class: "label" }, this.label), this.required && h("span", { class: "required" }, "*"))), h("div", { key: 'a018a19fe2a77416d7ac4d9c7ea84cb0560a70de', part: "ic__input_wrapper", class: "input_wrapper" }, h("input", { key: '7952451a1397dc1a08ac5dc6a251d452a882981b', type: "date", name: this.name, part: "ic__date", readOnly: this.readOnly, autoFocus: this.autoFocus, value: this.value, maxLength: this.maxLength, placeholder: this.placeholder, class: { error: !!this.error }, onInput: e => this.handleInput(e), onFocus: () => this.handleFocus(), onBlur: () => this.handleBlur() }), h("slot", { key: '9730db9ef73e570667c69879ce457c45b5e196a5', name: "additional-input" })), this.error && h("span", { class: "error help-text" }, this.error)));
92
+ return (h("label", { key: 'db7e5910f650055747d1f2bca13356d2c3fe3f9e', part: "ic__label", class: { error: !!this.error } }, this.label && (h("p", null, h("span", { class: "label" }, this.label), this.required && h("span", { class: "required" }, "*"))), h("div", { key: '81d0a723cec27805587e2abdac667504d078e211', part: "ic__input_wrapper", class: "input_wrapper" }, h("input", { key: '948cf92087a3763d058588c8f6b7764e96234595', type: "date", name: this.name, part: "ic__date", readOnly: this.readOnly, autoFocus: this.autoFocus, value: this.value, maxLength: this.maxLength, placeholder: this.placeholder, class: { error: !!this.error }, onInput: e => this.handleInput(e), onFocus: () => this.handleFocus(), onBlur: () => this.handleBlur() }), h("slot", { key: '6c1d31a29dc01621d9212a95574c329844da0eed', name: "additional-input" })), this.error && h("span", { class: "error help-text" }, this.error)));
88
93
  }
89
94
  static get is() { return "nylas-date-component"; }
90
95
  static get encapsulation() { return "shadow"; }
@@ -304,7 +309,8 @@ export class NylasDateComponent {
304
309
  static get states() {
305
310
  return {
306
311
  "value": {},
307
- "error": {}
312
+ "error": {},
313
+ "isDateValid": {}
308
314
  };
309
315
  }
310
316
  static get events() {
@@ -1 +1 @@
1
- {"version":3,"file":"nylas-date-component.js","sourceRoot":"","sources":["../../../../src/components/design-system/nylas-date-component/nylas-date-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,YAAY;CACnB,CAAC;AAYF,MAAM,OAAO,kBAAkB;;oBAQN,OAAO;;qBAQN,EAAE;2BAKI,kBAAkB,CAAC,MAAM,CAAC;wBAK5B,KAAK;wBAKL,KAAK;yBAMJ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, Watch, Element } from '@stencil/core';\nimport { sanitize } from '@/utils/utils';\n\nconst DefaultPlaceholder = {\n date: 'YYYY-MM-DD',\n};\n\n/**\n * The `nylas-date-component` component is a UI component that allows users to input text, email, or phone number values.\n * This component is used in the scheduling form to input text, email and phone number type inputs.\n */\n\n@Component({\n tag: 'nylas-date-component',\n styleUrl: 'nylas-date-component.scss',\n shadow: true,\n})\nexport class NylasDateComponent {\n /**\n * The host element\n */\n @Element() el!: HTMLElement;\n /**\n * The name of the input. This is used to identify the input when submitting a form.\n */\n @Prop() name: string = 'input';\n /**\n * The default value of the input. This is the value that is displayed when the input is rendered.\n */\n @Prop() defaultValue?: string;\n /**\n * The label of the input. This is displayed above the input.\n */\n @Prop() label: string = '';\n\n /**\n * The placeholder of the input. This is displayed when the input is empty.\n */\n @Prop() placeholder: string = DefaultPlaceholder['date'];\n /**\n * Whether the input is required. If true, the input must have a value when submitting a form.\n * Default is false. If the input is required and the value is empty, an error message is displayed.\n */\n @Prop() required: boolean = false;\n /**\n * Whether the input is read-only. If true, the input cannot be edited.\n * Default is false.\n */\n @Prop() readOnly: boolean = false;\n /**\n * Whether the input should be focused when rendered.\n * Default is false. If true, the input is focused when rendered.\n * Use this to set the focus on the first input in a form.\n */\n @Prop() autoFocus: boolean = false;\n /**\n * The pattern to validate the input value. If the value does not match the pattern, an error message is displayed.\n * Default is null. If the pattern is not set, the pattern is determined by the input type for 'email' and 'phone_number'.\n */\n @Prop() pattern?: RegExp;\n /**\n * The maximum length of the input value. If the value is longer than the maximum length, an error message is displayed.\n * Default is 255.\n */\n @Prop() maxLength: number = 255;\n /**\n * The error message to display when the value does not match the pattern.\n * Default is 'Invalid <field> format.' where <field> is the input label.\n */\n @Prop() patternError: string = '';\n\n /**\n * This error message is displayed when the input value is empty and the input is required.\n */\n @Prop() requiredError: string = '';\n\n /**\n * The input value state.\n */\n @State() value!: string;\n /**\n * The error message state.\n */\n @State() error: string = '';\n\n /**\n * This event is fired when the input value is changed.\n * The scheduling form listens for this event to validate the input value and submit the form.\n * If using outside of the scheduling form, listen for this event to validate the input value\n * and handle the input value change.\n */\n @Event() nylasFormInputChanged!: EventEmitter<{\n value: string;\n name: string;\n label: string;\n type: string;\n error: string;\n }>;\n\n @Event() nylasFormInputFocused!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n @Event() nylasFormInputBlurred!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n // Lifecycle methods\n @Watch('defaultValue')\n handleDefaultValueChange(newValue: string) {\n this.value = sanitize(newValue);\n if (this.value) {\n this.validatePattern(this.value);\n }\n }\n\n componentDidLoad() {\n this.value = sanitize(this.defaultValue || '');\n if (this.value) {\n this.validatePattern(this.value);\n }\n }\n\n // Event listeners\n /**\n * Listen for the bookingFormSubmitted event to validate the input value when the form is submitted.\n */\n @Listen('bookingFormSubmitted', { target: 'document' })\n handleBookingFormSubmitted(event: CustomEvent) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n\n @Listen('formSubmitted', { target: 'document' })\n async handleFormSubmitted(event: CustomEvent) {\n if (this.el?.getAttribute('data-page-styling')) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n }\n\n // Methods\n handleInput(e: Event) {\n this.error = '';\n this.value = sanitize((e.target as HTMLInputElement).value);\n this.nylasFormInputChanged.emit({\n value: this.value,\n name: this.name,\n label: this.label,\n error: this.error,\n type: 'date',\n });\n }\n\n handleBlur() {\n this.nylasFormInputBlurred.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n handleFocus() {\n this.nylasFormInputFocused.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n validatePattern(value: string) {\n // Reset error\n this.error = '';\n // Check if the field is required and value is empty\n if (this.required && !value) {\n this.error = this.requiredError || 'This field is required.';\n return;\n }\n // Check if value matches pattern\n if (!this.pattern || (!value && !this.required)) return;\n\n if (this.pattern.test(value)) {\n this.error = '';\n } else {\n this.error = this.patternError || 'Invalid format.';\n }\n }\n\n render() {\n return (\n <label part=\"ic__label\" class={{ error: !!this.error }}>\n {this.label && (\n <p>\n <span class=\"label\">{this.label}</span>\n {this.required && <span class=\"required\">*</span>}\n </p>\n )}\n <div part=\"ic__input_wrapper\" class=\"input_wrapper\">\n <input\n type=\"date\"\n name={this.name}\n part=\"ic__date\"\n readOnly={this.readOnly}\n autoFocus={this.autoFocus}\n value={this.value}\n maxLength={this.maxLength}\n placeholder={this.placeholder}\n class={{ error: !!this.error }}\n onInput={e => this.handleInput(e)}\n onFocus={() => this.handleFocus()}\n onBlur={() => this.handleBlur()}\n />\n <slot name=\"additional-input\"></slot>\n </div>\n {this.error && <span class=\"error help-text\">{this.error}</span>}\n </label>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"nylas-date-component.js","sourceRoot":"","sources":["../../../../src/components/design-system/nylas-date-component/nylas-date-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,YAAY;CACnB,CAAC;AAYF,MAAM,OAAO,kBAAkB;;oBAQN,OAAO;;qBAQN,EAAE;2BAKI,kBAAkB,CAAC,MAAM,CAAC;wBAK5B,KAAK;wBAKL,KAAK;yBAMJ,KAAK;;yBAUN,GAAG;4BAKA,EAAE;6BAKD,EAAE;;qBAST,EAAE;2BAKK,IAAI;;IA4BpC,wBAAwB,CAAC,QAAgB;QACvC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,K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AE,IAAI,CAAC,IAAI,EACf,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAC9B,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EACjC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EACjC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,GAC/B;gBACF,6DAAM,IAAI,EAAC,kBAAkB,GAAQ,CACjC;YACL,IAAI,CAAC,KAAK,IAAI,YAAM,KAAK,EAAC,iBAAiB,IAAE,IAAI,CAAC,KAAK,CAAQ,CAC1D,CACT,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Event, EventEmitter, Listen, Watch, Element } from '@stencil/core';\nimport { sanitize } from '@/utils/utils';\n\nconst DefaultPlaceholder = {\n date: 'YYYY-MM-DD',\n};\n\n/**\n * The `nylas-date-component` component is a UI component that allows users to input text, email, or phone number values.\n * This component is used in the scheduling form to input text, email and phone number type inputs.\n */\n\n@Component({\n tag: 'nylas-date-component',\n styleUrl: 'nylas-date-component.scss',\n shadow: true,\n})\nexport class NylasDateComponent {\n /**\n * The host element\n */\n @Element() el!: HTMLElement;\n /**\n * The name of the input. This is used to identify the input when submitting a form.\n */\n @Prop() name: string = 'input';\n /**\n * The default value of the input. This is the value that is displayed when the input is rendered.\n */\n @Prop() defaultValue?: string;\n /**\n * The label of the input. This is displayed above the input.\n */\n @Prop() label: string = '';\n\n /**\n * The placeholder of the input. This is displayed when the input is empty.\n */\n @Prop() placeholder: string = DefaultPlaceholder['date'];\n /**\n * Whether the input is required. If true, the input must have a value when submitting a form.\n * Default is false. If the input is required and the value is empty, an error message is displayed.\n */\n @Prop() required: boolean = false;\n /**\n * Whether the input is read-only. If true, the input cannot be edited.\n * Default is false.\n */\n @Prop() readOnly: boolean = false;\n /**\n * Whether the input should be focused when rendered.\n * Default is false. If true, the input is focused when rendered.\n * Use this to set the focus on the first input in a form.\n */\n @Prop() autoFocus: boolean = false;\n /**\n * The pattern to validate the input value. If the value does not match the pattern, an error message is displayed.\n * Default is null. If the pattern is not set, the pattern is determined by the input type for 'email' and 'phone_number'.\n */\n @Prop() pattern?: RegExp;\n /**\n * The maximum length of the input value. If the value is longer than the maximum length, an error message is displayed.\n * Default is 255.\n */\n @Prop() maxLength: number = 255;\n /**\n * The error message to display when the value does not match the pattern.\n * Default is 'Invalid <field> format.' where <field> is the input label.\n */\n @Prop() patternError: string = '';\n\n /**\n * This error message is displayed when the input value is empty and the input is required.\n */\n @Prop() requiredError: string = '';\n\n /**\n * The input value state.\n */\n @State() value!: string;\n /**\n * The error message state.\n */\n @State() error: string = '';\n\n /**\n * State to track the validity of the date input.\n */\n @State() isDateValid: boolean = true;\n\n /**\n * This event is fired when the input value is changed.\n * The scheduling form listens for this event to validate the input value and submit the form.\n * If using outside of the scheduling form, listen for this event to validate the input value\n * and handle the input value change.\n */\n @Event() nylasFormInputChanged!: EventEmitter<{\n value: string;\n name: string;\n label: string;\n type: string;\n error: string;\n }>;\n\n @Event() nylasFormInputFocused!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n @Event() nylasFormInputBlurred!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n // Lifecycle methods\n @Watch('defaultValue')\n handleDefaultValueChange(newValue: string) {\n this.value = sanitize(newValue);\n if (this.value) {\n this.validatePattern(this.value);\n }\n }\n\n componentDidLoad() {\n this.value = sanitize(this.defaultValue || '');\n if (this.value) {\n this.validatePattern(this.value);\n }\n }\n\n // Event listeners\n /**\n * Listen for the bookingFormSubmitted event to validate the input value when the form is submitted.\n */\n @Listen('bookingFormSubmitted', { target: 'document' })\n handleBookingFormSubmitted(event: CustomEvent) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n\n @Listen('formSubmitted', { target: 'document' })\n async handleFormSubmitted(event: CustomEvent) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n\n // Methods\n handleInput(e: Event) {\n this.error = '';\n const target = e.target as HTMLInputElement;\n this.value = sanitize(target.value);\n this.isDateValid = target.validity.valid;\n this.nylasFormInputChanged.emit({\n value: this.value,\n name: this.name,\n label: this.label,\n error: this.error,\n type: 'date',\n });\n }\n\n handleBlur() {\n this.nylasFormInputBlurred.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n handleFocus() {\n this.nylasFormInputFocused.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n validatePattern(value: string) {\n // Reset error\n this.error = '';\n if (!this.isDateValid) {\n this.error = 'Please enter a valid date';\n return;\n }\n // Check if the field is required and value is empty\n if (this.required && !value) {\n this.error = this.requiredError || 'This field is required.';\n return;\n }\n // Check if value matches pattern\n if (!this.pattern || (!value && !this.required)) return;\n\n if (this.pattern.test(value)) {\n this.error = '';\n } else {\n this.error = this.patternError || 'Invalid format.';\n }\n }\n\n render() {\n return (\n <label part=\"ic__label\" class={{ error: !!this.error }}>\n {this.label && (\n <p>\n <span class=\"label\">{this.label}</span>\n {this.required && <span class=\"required\">*</span>}\n </p>\n )}\n <div part=\"ic__input_wrapper\" class=\"input_wrapper\">\n <input\n type=\"date\"\n name={this.name}\n part=\"ic__date\"\n readOnly={this.readOnly}\n autoFocus={this.autoFocus}\n value={this.value}\n maxLength={this.maxLength}\n placeholder={this.placeholder}\n class={{ error: !!this.error }}\n onInput={e => this.handleInput(e)}\n onFocus={() => this.handleFocus()}\n onBlur={() => this.handleBlur()}\n />\n <slot name=\"additional-input\"></slot>\n </div>\n {this.error && <span class=\"error help-text\">{this.error}</span>}\n </label>\n );\n }\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import { newSpecPage } from "@stencil/core/testing";
2
+ import { NylasDateComponent } from "../nylas-date-component";
3
+ import { h } from "@stencil/core";
4
+ describe('nylas-date-component', () => {
5
+ beforeEach(() => {
6
+ jest.clearAllMocks();
7
+ });
8
+ it('renders error if date form field is invalid', async () => {
9
+ const page = await newSpecPage({
10
+ components: [NylasDateComponent],
11
+ template: () => h("nylas-date-component", null),
12
+ });
13
+ await page.waitForChanges();
14
+ expect(page.root).toMatchSnapshot();
15
+ const dateInput = page?.root?.shadowRoot?.querySelector('input');
16
+ const mockOnInput = jest.fn();
17
+ dateInput.addEventListener('input', mockOnInput);
18
+ dateInput.value = '1993-02-29';
19
+ dateInput.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
20
+ await page.waitForChanges();
21
+ expect(mockOnInput).toHaveBeenCalled();
22
+ const customEvent = new CustomEvent('bookingFormSubmitted', {
23
+ detail: {},
24
+ });
25
+ page.rootInstance.handleInput({
26
+ target: {
27
+ value: '',
28
+ validity: {
29
+ valid: false,
30
+ },
31
+ },
32
+ });
33
+ page.rootInstance.handleBookingFormSubmitted(customEvent);
34
+ await page.waitForChanges();
35
+ expect(page.rootInstance.isDateValid).toBe(false);
36
+ expect(page.root).toMatchSnapshot();
37
+ });
38
+ });
39
+ //# sourceMappingURL=nylas-date-component.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nylas-date-component.sp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AAE,EAAE;SACX,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;YAC5B,MAAM,EAAE;gBACN,KAAK,EAAE,EAAE;gBACT,QAAQ,EAAE;oBACR,KAAK,EAAE,KAAK;iBACb;aACF;SACF,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC;QAC1D,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { NylasDateComponent } from '../nylas-date-component';\nimport { h } from '@stencil/core';\n\ndescribe('nylas-date-component', () => {\n beforeEach(() => {\n // Clear and reset the mock before each test if needed\n jest.clearAllMocks();\n });\n\n it('renders error if date form field is invalid', async () => {\n const page = await newSpecPage({\n components: [NylasDateComponent],\n template: () => <nylas-date-component />,\n });\n await page.waitForChanges();\n expect(page.root).toMatchSnapshot();\n const dateInput = page?.root?.shadowRoot?.querySelector('input') as HTMLInputElement;\n\n const mockOnInput = jest.fn();\n dateInput.addEventListener('input', mockOnInput);\n dateInput.value = '1993-02-29';\n dateInput.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));\n await page.waitForChanges();\n expect(mockOnInput).toHaveBeenCalled();\n\n const customEvent = new CustomEvent('bookingFormSubmitted', {\n detail: {},\n });\n page.rootInstance.handleInput({\n target: {\n value: '',\n validity: {\n valid: false,\n },\n },\n });\n page.rootInstance.handleBookingFormSubmitted(customEvent);\n await page.waitForChanges();\n expect(page.rootInstance.isDateValid).toBe(false);\n expect(page.root).toMatchSnapshot();\n });\n});\n"]}
@@ -26,6 +26,21 @@ export class TimePeriodSelector {
26
26
  };
27
27
  });
28
28
  }
29
+ defaultSelectedPeriodChanged(newValue) {
30
+ this.selectedPeriod = newValue;
31
+ this.updateNumberOptionsAndSelectedNumber(newValue);
32
+ }
33
+ defaultSelectedNumberChanged(newValue) {
34
+ this.selectedNumber = newValue;
35
+ }
36
+ timePeriodsChanged(newValue) {
37
+ this.timePeriodOptions = newValue.map(period => {
38
+ return {
39
+ label: period,
40
+ value: period,
41
+ };
42
+ });
43
+ }
29
44
  componentDidLoad() {
30
45
  this.selectedNumber = this.defaultSelectedNumber;
31
46
  this.selectedPeriod = this.defaultSelectedPeriod;
@@ -93,7 +108,7 @@ export class TimePeriodSelector {
93
108
  this.selectedNumber = parseInt(this.numberOptions[0].value);
94
109
  }
95
110
  render() {
96
- return (h("div", { key: '76ed6c36ebbcfbb8b8d54edc6a26a9d2a6d6f7fb', class: "time-period-selector" }, typeof this.selectedNumber == 'number' && (h("input-dropdown", { id: "time-number", name: 'time-number', inputValue: this.selectedNumber.toString(), exportparts: "id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content", options: this.numberOptions, defaultInputOption: this.numberOptions.find(i => i.value == this.selectedNumber.toString()) })), typeof this.selectedPeriod == 'string' && (h("select-dropdown", { id: "time-period", name: 'time-period', options: this.timePeriodOptions, exportparts: "sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content", pluralizedLabel: this.selectedNumber > 1 ? 's' : '', defaultSelectedOption: this.timePeriodOptions.find(i => i.value == this.selectedPeriod), withSearch: false }))));
111
+ return (h("div", { key: 'f40a2be9bc76a0a5be0ffa3c87779fab644e52f2', class: "time-period-selector" }, typeof this.selectedNumber == 'number' && (h("input-dropdown", { id: "time-number", name: 'time-number', inputValue: this.selectedNumber.toString(), exportparts: "id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content", options: this.numberOptions, defaultInputOption: this.numberOptions.find(i => i.value == this.selectedNumber.toString()) })), typeof this.selectedPeriod == 'string' && (h("select-dropdown", { id: "time-period", name: 'time-period', options: this.timePeriodOptions, exportparts: "sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content", pluralizedLabel: this.selectedNumber > 1 ? 's' : '', defaultSelectedOption: this.timePeriodOptions.find(i => i.value == this.selectedPeriod), withSearch: false }))));
97
112
  }
98
113
  static get is() { return "time-period-selector"; }
99
114
  static get encapsulation() { return "scoped"; }
@@ -188,6 +203,18 @@ export class TimePeriodSelector {
188
203
  }];
189
204
  }
190
205
  static get elementRef() { return "host"; }
206
+ static get watchers() {
207
+ return [{
208
+ "propName": "defaultSelectedPeriod",
209
+ "methodName": "defaultSelectedPeriodChanged"
210
+ }, {
211
+ "propName": "defaultSelectedNumber",
212
+ "methodName": "defaultSelectedNumberChanged"
213
+ }, {
214
+ "propName": "timePeriods",
215
+ "methodName": "timePeriodsChanged"
216
+ }];
217
+ }
191
218
  static get listeners() {
192
219
  return [{
193
220
  "name": "inputOptionChanged",
@@ -1 +1 @@
1
- {"version":3,"file":"time-period-selector.js","sourceRoot":"","sources":["../../../../src/components/design-system/time-period-selector/time-period-selector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAElE,MAAM,gBAAgB,GAAG;IACvB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,OAAO;CAChB,CAAC;AAOF,MAAM,OAAO,kBAAkB;;2BAIG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;;;8BAe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sIAAsI,EAClJ,OAAO,EAAE,IAAI,CAAC,aAAa,EAC3B,kBAAkB,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,GAC3F,CACH;YACA,OAAO,IAAI,CAAC,cAAc,IAAI,QAAQ,IAAI,CACzC,uBACE,EAAE,EAAC,aAAa,EAChB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAC/B,WAAW,EAAC,uIAAuI,EACnJ,eAAe,EAAE,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EACnD,qBAAqB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,EACvF,UAAU,EAAE,KAAK,GACjB,CACH,CACG,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { debug } from '@/utils/utils';\nimport { Element, Event, EventEmitter } from '@stencil/core';\nimport { Component, h, Listen, Prop, State } from '@stencil/core';\n\nconst pluralToSingular = {\n hours: 'hour',\n days: 'day',\n weeks: 'week',\n months: 'month',\n};\n\n@Component({\n tag: 'time-period-selector',\n styleUrl: 'time-period-selector.scss',\n scoped: true,\n})\nexport class TimePeriodSelector {\n @Element() host!: HTMLElement;\n\n // The possible values for the time periods dropdown\n @Prop() timePeriods: string[] = ['hour', 'day', 'week', 'month'];\n\n /**\n * The default selected time period.\n */\n @Prop() defaultSelectedPeriod!: string;\n\n /**\n * The default selected number.\n */\n @Prop() defaultSelectedNumber!: number;\n\n /**\n * The currently selected time period\n */\n @State() selectedPeriod: string = this.defaultSelectedPeriod;\n\n /**\n * The currently selected number of the time period\n */\n @State() selectedNumber: number = this.defaultSelectedNumber;\n\n /*\n * The options for the number dropdown, to be calculated based on the selectedPeriod\n */\n @State() numberOptions: { label: string; value: string }[] = this.calculateOptions(this.defaultSelectedPeriod || 'hour').map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n\n /**\n * The options for the time period dropdown\n */\n @State() timePeriodOptions = this.timePeriods.map(period => {\n return {\n label: period,\n value: period,\n };\n });\n\n componentDidLoad() {\n this.selectedNumber = this.defaultSelectedNumber;\n this.selectedPeriod = this.defaultSelectedPeriod;\n const period = pluralToSingular[this.selectedPeriod] ?? this.selectedPeriod;\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n }\n\n @Event() timePeriodChanged!: EventEmitter<{ number: number; period: string }>;\n\n private calculateOptions(period: string): number[] {\n switch (period) {\n case 'hour':\n return Array.from({ length: 23 }, (_, i) => i + 1);\n case 'minute':\n return Array.from({ length: 13 }, (_, i) => i * 5);\n case 'day':\n return Array.from({ length: 30 }, (_, i) => i + 1);\n case 'week':\n return Array.from({ length: 4 }, (_, i) => i + 1);\n case 'month':\n return Array.from({ length: 12 }, (_, i) => i + 1);\n default:\n return [];\n }\n }\n\n @Listen('inputOptionChanged')\n inputOptionChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'inputOptionChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-number') {\n this.selectedNumber = value ? parseInt(value) : this.defaultSelectedNumber;\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n @Listen('nylasFormDropdownChanged')\n nylasFormDropdownChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'nylasFormDropdownChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-period') {\n this.selectedPeriod = value;\n this.updateNumberOptionsAndSelectedNumber(value);\n } else if (name === 'time-number') {\n this.selectedNumber = parseInt(value);\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n updateNumberOptionsAndSelectedNumber(period: string) {\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n this.selectedNumber = parseInt(this.numberOptions[0].value);\n }\n\n render() {\n return (\n <div class=\"time-period-selector\">\n {typeof this.selectedNumber == 'number' && (\n <input-dropdown\n id=\"time-number\"\n name={'time-number'}\n inputValue={this.selectedNumber.toString()}\n exportparts=\"id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content\"\n options={this.numberOptions}\n defaultInputOption={this.numberOptions.find(i => i.value == this.selectedNumber.toString())}\n />\n )}\n {typeof this.selectedPeriod == 'string' && (\n <select-dropdown\n id=\"time-period\"\n name={'time-period'}\n options={this.timePeriodOptions}\n exportparts=\"sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content\"\n pluralizedLabel={this.selectedNumber > 1 ? 's' : ''}\n defaultSelectedOption={this.timePeriodOptions.find(i => i.value == this.selectedPeriod)}\n withSearch={false}\n />\n )}\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"time-period-selector.js","sourceRoot":"","sources":["../../../../src/components/design-system/time-period-selector/time-period-selector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAElE,MAAM,gBAAgB,GAAG;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AC,EACvF,UAAU,EAAE,KAAK,GACjB,CACH,CACG,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { debug } from '@/utils/utils';\nimport { Element, Event, EventEmitter, Watch } from '@stencil/core';\nimport { Component, h, Listen, Prop, State } from '@stencil/core';\n\nconst pluralToSingular = {\n hours: 'hour',\n days: 'day',\n weeks: 'week',\n months: 'month',\n};\n\n@Component({\n tag: 'time-period-selector',\n styleUrl: 'time-period-selector.scss',\n scoped: true,\n})\nexport class TimePeriodSelector {\n @Element() host!: HTMLElement;\n\n // The possible values for the time periods dropdown\n @Prop() timePeriods: string[] = ['hour', 'day', 'week', 'month'];\n\n /**\n * The default selected time period.\n */\n @Prop() defaultSelectedPeriod!: string;\n\n /**\n * The default selected number.\n */\n @Prop() defaultSelectedNumber!: number;\n\n /**\n * The currently selected time period\n */\n @State() selectedPeriod: string = this.defaultSelectedPeriod;\n\n /**\n * The currently selected number of the time period\n */\n @State() selectedNumber: number = this.defaultSelectedNumber;\n\n /*\n * The options for the number dropdown, to be calculated based on the selectedPeriod\n */\n @State() numberOptions: { label: string; value: string }[] = this.calculateOptions(this.defaultSelectedPeriod || 'hour').map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n\n /**\n * The options for the time period dropdown\n */\n @State() timePeriodOptions = this.timePeriods.map(period => {\n return {\n label: period,\n value: period,\n };\n });\n\n @Watch('defaultSelectedPeriod')\n defaultSelectedPeriodChanged(newValue: string) {\n this.selectedPeriod = newValue;\n this.updateNumberOptionsAndSelectedNumber(newValue);\n }\n\n @Watch('defaultSelectedNumber')\n defaultSelectedNumberChanged(newValue: number) {\n this.selectedNumber = newValue;\n }\n\n @Watch('timePeriods')\n timePeriodsChanged(newValue: string[]) {\n this.timePeriodOptions = newValue.map(period => {\n return {\n label: period,\n value: period,\n };\n });\n }\n\n componentDidLoad() {\n this.selectedNumber = this.defaultSelectedNumber;\n this.selectedPeriod = this.defaultSelectedPeriod;\n const period = pluralToSingular[this.selectedPeriod] ?? this.selectedPeriod;\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n }\n\n @Event() timePeriodChanged!: EventEmitter<{ number: number; period: string }>;\n\n private calculateOptions(period: string): number[] {\n switch (period) {\n case 'hour':\n return Array.from({ length: 23 }, (_, i) => i + 1);\n case 'minute':\n return Array.from({ length: 13 }, (_, i) => i * 5);\n case 'day':\n return Array.from({ length: 30 }, (_, i) => i + 1);\n case 'week':\n return Array.from({ length: 4 }, (_, i) => i + 1);\n case 'month':\n return Array.from({ length: 12 }, (_, i) => i + 1);\n default:\n return [];\n }\n }\n\n @Listen('inputOptionChanged')\n inputOptionChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'inputOptionChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-number') {\n this.selectedNumber = value ? parseInt(value) : this.defaultSelectedNumber;\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n @Listen('nylasFormDropdownChanged')\n nylasFormDropdownChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'nylasFormDropdownChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-period') {\n this.selectedPeriod = value;\n this.updateNumberOptionsAndSelectedNumber(value);\n } else if (name === 'time-number') {\n this.selectedNumber = parseInt(value);\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n updateNumberOptionsAndSelectedNumber(period: string) {\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n this.selectedNumber = parseInt(this.numberOptions[0].value);\n }\n\n render() {\n return (\n <div class=\"time-period-selector\">\n {typeof this.selectedNumber == 'number' && (\n <input-dropdown\n id=\"time-number\"\n name={'time-number'}\n inputValue={this.selectedNumber.toString()}\n exportparts=\"id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content\"\n options={this.numberOptions}\n defaultInputOption={this.numberOptions.find(i => i.value == this.selectedNumber.toString())}\n />\n )}\n {typeof this.selectedPeriod == 'string' && (\n <select-dropdown\n id=\"time-period\"\n name={'time-period'}\n options={this.timePeriodOptions}\n exportparts=\"sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content\"\n pluralizedLabel={this.selectedNumber > 1 ? 's' : ''}\n defaultSelectedOption={this.timePeriodOptions.find(i => i.value == this.selectedPeriod)}\n withSearch={false}\n />\n )}\n </div>\n );\n }\n}\n"]}
@@ -37,7 +37,9 @@ describe('nylas-date-picker', () => {
37
37
  nextMonthButton.click();
38
38
  await page.waitForChanges();
39
39
  expect(spyEvent).toHaveBeenCalled();
40
- expect(page.rootInstance.month.getMonth()).toBe(new Date().getMonth() + 1);
40
+ const currentMonth = new Date().getMonth();
41
+ const expectedMonth = (currentMonth + 1) % 12;
42
+ expect(page.rootInstance.month.getMonth()).toBe(expectedMonth);
41
43
  });
42
44
  it('disables dates not in selectableDates', async () => {
43
45
  const selectableDates = [new Date()];
@@ -1 +1 @@
1
- {"version":3,"file":"nylas-date-picker.spec.js","sourceRoot":"","sources":["../../../../../src/components/scheduler/nylas-date-picker/test/nylas-date-picker.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,UAAU,CAAC,GAAG,EAAE;QAEd,IAAI,CAAC,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AkC,CAAC;QAEvI,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,eAAe,CAAC;YAC7B,IAAI,EAAE,2DAA2D;SAClE,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,aAAa,CAAkC,CAAC;QACvG,MAAM,YAAY,GAAG,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,0BAA0B,CAAkC,CAAC;QAC3H,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC;QAC7D,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { NylasDatePicker } from '../nylas-date-picker';\n\ndescribe('nylas-date-picker', () => {\n beforeEach(() => {\n // Clear and reset the mock before each test if needed\n jest.clearAllMocks();\n });\n\n it('renders correctly and generates dates for the current month', async () => {\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n if (!page.root) {\n throw new Error('Component did not render.');\n }\n expect(page.rootInstance.dates.length).toBeGreaterThan(0);\n });\n it('emits dateSelected event with the correct date on date selection', async () => {\n const selectedDate = new Date();\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n\n const spyEvent = jest.fn();\n page.win.addEventListener('dateSelected', spyEvent);\n\n page.rootInstance.selectDate(selectedDate);\n await page.waitForChanges();\n\n expect(spyEvent).toHaveBeenCalledWith(expect.objectContaining({ detail: selectedDate }));\n });\n it('changes the month and emits monthChanged event on month navigation', async () => {\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n\n const spyEvent = jest.fn();\n page.win.addEventListener('monthChanged', spyEvent);\n\n // Change to the next month\n const nextMonthButton = page?.root?.shadowRoot?.querySelector('.chevron-right') as HTMLButtonElement;\n nextMonthButton.click();\n await page.waitForChanges();\n\n expect(spyEvent).toHaveBeenCalled();\n expect(page.rootInstance.month.getMonth()).toBe(new Date().getMonth() + 1); // Assuming test runs in a month that is not December\n });\n it('disables dates not in selectableDates', async () => {\n const selectableDates = [new Date()];\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n\n if (!page.root) {\n throw new Error('Component did not render.');\n }\n\n page.root.selectableDates = selectableDates;\n page.root.isLoading = false;\n await page.waitForChanges();\n const dates = page?.root?.shadowRoot?.querySelectorAll('button.date.current-month') as NodeListOf<HTMLButtonElement>;\n const disabledDates = page?.root?.shadowRoot?.querySelectorAll('button.date.current-month[disabled]') as NodeListOf<HTMLButtonElement>;\n\n expect(disabledDates.length).toBe(dates.length - selectableDates.length);\n });\n it('displays loading state and disables date selection', async () => {\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker is-loading=\"true\"></nylas-date-picker>`,\n });\n\n await page.waitForChanges();\n\n const dates = page?.root?.shadowRoot?.querySelectorAll('button.date') as NodeListOf<HTMLButtonElement>;\n const loadingDates = page?.root?.shadowRoot?.querySelectorAll('button.date.day-skeleton') as NodeListOf<HTMLButtonElement>;\n const allDatesLoading = loadingDates.length === dates.length;\n expect(allDatesLoading).toBe(true);\n });\n});\n"]}
1
+ {"version":3,"file":"nylas-date-picker.spec.js","sourceRoot":"","sources":["../../../../../src/components/scheduler/nylas-date-picker/test/nylas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CAAC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QAC5C,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAC5B,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,2BAA2B,CAAkC,CAAC;QACrH,MAAM,aAAa,GAAG,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,qCAAqC,CAAkC,CAAC;QAEvI,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,eAAe,CAAC;YAC7B,IAAI,EAAE,2DAA2D;SAClE,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,aAAa,CAAkC,CAAC;QACvG,MAAM,YAAY,GAAG,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,0BAA0B,CAAkC,CAAC;QAC3H,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC;QAC7D,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { NylasDatePicker } from '../nylas-date-picker';\n\ndescribe('nylas-date-picker', () => {\n beforeEach(() => {\n // Clear and reset the mock before each test if needed\n jest.clearAllMocks();\n });\n\n it('renders correctly and generates dates for the current month', async () => {\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n if (!page.root) {\n throw new Error('Component did not render.');\n }\n expect(page.rootInstance.dates.length).toBeGreaterThan(0);\n });\n it('emits dateSelected event with the correct date on date selection', async () => {\n const selectedDate = new Date();\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n\n const spyEvent = jest.fn();\n page.win.addEventListener('dateSelected', spyEvent);\n\n page.rootInstance.selectDate(selectedDate);\n await page.waitForChanges();\n\n expect(spyEvent).toHaveBeenCalledWith(expect.objectContaining({ detail: selectedDate }));\n });\n it('changes the month and emits monthChanged event on month navigation', async () => {\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n\n const spyEvent = jest.fn();\n page.win.addEventListener('monthChanged', spyEvent);\n\n // Change to the next month\n const nextMonthButton = page?.root?.shadowRoot?.querySelector('.chevron-right') as HTMLButtonElement;\n nextMonthButton.click();\n await page.waitForChanges();\n\n expect(spyEvent).toHaveBeenCalled();\n const currentMonth = new Date().getMonth();\n const expectedMonth = (currentMonth + 1) % 12; // Handles December wrap-around\n expect(page.rootInstance.month.getMonth()).toBe(expectedMonth);\n });\n it('disables dates not in selectableDates', async () => {\n const selectableDates = [new Date()];\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker></nylas-date-picker>`,\n });\n\n if (!page.root) {\n throw new Error('Component did not render.');\n }\n\n page.root.selectableDates = selectableDates;\n page.root.isLoading = false;\n await page.waitForChanges();\n const dates = page?.root?.shadowRoot?.querySelectorAll('button.date.current-month') as NodeListOf<HTMLButtonElement>;\n const disabledDates = page?.root?.shadowRoot?.querySelectorAll('button.date.current-month[disabled]') as NodeListOf<HTMLButtonElement>;\n\n expect(disabledDates.length).toBe(dates.length - selectableDates.length);\n });\n it('displays loading state and disables date selection', async () => {\n const page = await newSpecPage({\n components: [NylasDatePicker],\n html: `<nylas-date-picker is-loading=\"true\"></nylas-date-picker>`,\n });\n\n await page.waitForChanges();\n\n const dates = page?.root?.shadowRoot?.querySelectorAll('button.date') as NodeListOf<HTMLButtonElement>;\n const loadingDates = page?.root?.shadowRoot?.querySelectorAll('button.date.day-skeleton') as NodeListOf<HTMLButtonElement>;\n const allDatesLoading = loadingDates.length === dates.length;\n expect(allDatesLoading).toBe(true);\n });\n});\n"]}
@@ -48,10 +48,10 @@ export class NylasAdditionalParticipants {
48
48
  componentWillLoad() {
49
49
  debug('nylas-additional-participants', 'componentWillLoad');
50
50
  this.host.setAttribute('name', this.name);
51
- this.updateState(this.selectedConfiguration, this.currentUser);
52
51
  }
53
52
  componentDidLoad() {
54
53
  debug('nylas-additional-participants', 'componentDidLoad');
54
+ this.updateState(this.selectedConfiguration, this.currentUser);
55
55
  }
56
56
  disconnectedCallback() {
57
57
  debug('nylas-additional-participants', 'disconnectedCallback');
@@ -1 +1 @@
1
- {"version":3,"file":"nylas-additional-participants.js","sourceRoot":"","sources":["../../../../src/components/scheduler-editor/nylas-additional-participants/nylas-additional-participants.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAgB,MAAM,eAAe,CAAC;AAEvH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAsCtC,MAAM,OAAO,2BAA2B;;oBAMf,cAAc;;;;;;4BA4BE,IAAI,CAAC,iBAAiB,IAAI,EAAE;iCACX,EAAE;6CACR,IAAI;kCACf,KAAK;qBACnB,EAAE;;IAgB3B,yBAAyB,CAAC,QAAgB;QACxC,KAAK,CAAC,+BAA+B,EAAE,2BAA2B,E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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAjGC;IAXC,iBAAiB,CAAiH;QACjI,IAAI,EAAE,+BAA+B;QACrC,YAAY,EAAE,IAAI,GAAG,CAAC;YACpB,CAAC,wCAAwC,EAAE,oBAAoB,CAAC;YAChE,CAAC,uCAAuC,EAAE,uBAAuB,CAAC;YAClE,CAAC,6BAA6B,EAAE,aAAa,CAAC;YAC9C,CAAC,2BAA2B,EAAE,sBAAsB,CAAC;SACtD,CAAC;QACF,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,IAAI;KACxB,CAAC;;;;yDAiGD","sourcesContent":["import { RegisterComponent } from '@/common/register-component';\nimport { NylasSchedulerConfigConnector } from '@/connector/nylas-scheduler-config-connector';\nimport { debug } from '@/utils/utils';\nimport { AttachInternals, Component, Host, Prop, State, Watch, h, Element, Listen, EventEmitter } from '@stencil/core';\nimport { NylasSchedulerEditor } from '../nylas-scheduler-editor/nylas-scheduler-editor';\nimport { Event } from '@stencil/core';\nimport { AdditionalParticipant, Calendar, Configuration } from '@nylas/core';\nimport { User } from '@/common/nylas-api-request';\n\ntype Participant = {\n name?: string;\n email: string;\n is_valid?: boolean;\n is_organizer?: boolean;\n availability?: Availability;\n booking?: Booking;\n};\ntype Availability = {\n calendar_ids: string[];\n};\ntype Booking = {\n calendar_id: string;\n};\n\n/**\n * The `nylas-additional-participants` component is a form input for adding additional participants to an event.\n *\n * @part nap__title - The title of the component.\n * @part nap__subtitle - The subtitle of the component.\n * @part nap__content - The content of the component.\n * @part nap__input_group - The input group of the component.\n * @part nap__input_wrapper - The input wrapper of the component.\n * @part nap__input - The input of the component.\n * @part nap__remove-participant - The remove participant button of the component.\n * @part nap__add-participant - The add participant button of the component.\n *\n */\n@Component({\n tag: 'nylas-additional-participants',\n styleUrl: 'nylas-additional-participants.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class NylasAdditionalParticipants {\n @Element() host!: HTMLNylasAdditionalParticipantsElement;\n /**\n * @standalone\n * The name of the component\n */\n @Prop() name: string = 'participants';\n /**\n * @standalone\n * The selected config\n */\n @Prop() selectedConfiguration?: Configuration;\n /**\n * @standalone\n * The logged in user\n */\n @Prop() currentUser?: User;\n /**\n * @standalone\n * The list of user's calendars.\n */\n @Prop() currentUserCalendars?: Calendar[];\n /**\n * @standalone\n * The additional participants options from the config\n */\n @Prop() participantOptions?: AdditionalParticipant[];\n /**\n * @standalone\n * The event participants\n */\n @Prop() eventParticipants?: Participant[];\n\n @AttachInternals() internals!: ElementInternals;\n @State() participants: Participant[] = this.eventParticipants ?? [];\n @State() participantErrors: { [key: string]: string } = {};\n @State() includeOrganizerAsParticipant: boolean = true;\n @State() isRoundRobinConfig: boolean = false;\n @State() error: string = '';\n\n /**\n * This event is fired when the selected participants change.\n */\n @Event() valueChanged!: EventEmitter<{\n value: string;\n name: string;\n }>;\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-additional-participants', 'elementNameChangedHandler', newValue);\n this.host.setAttribute('name', newValue);\n }\n\n @Watch('currentUser')\n @Watch('selectedConfiguration')\n selectedConfigurationAndCurrentUserChangedHandler(newValue: unknown, _oldValue: unknown, propName: string) {\n debug('nylas-additional-participants', 'selectedConfigurationAndCurrentUserChangedHandler', newValue, this.currentUser);\n\n if (propName === 'selectedConfiguration') {\n this.updateState(newValue as Configuration, this.currentUser);\n } else if (propName === 'currentUser') {\n this.updateState(this.selectedConfiguration, newValue as User);\n }\n }\n\n connectedCallback() {\n debug('nylas-additional-participants', 'connectedCallback');\n }\n\n componentWillLoad() {\n debug('nylas-additional-participants', 'componentWillLoad');\n this.host.setAttribute('name', this.name);\n this.updateState(this.selectedConfiguration, this.currentUser);\n }\n\n componentDidLoad() {\n debug('nylas-additional-participants', 'componentDidLoad');\n }\n\n disconnectedCallback() {\n debug('nylas-additional-participants', 'disconnectedCallback');\n }\n\n private updateState(selectedConfig?: Configuration, currentUser?: User) {\n this.isRoundRobinConfig = selectedConfig?.availability?.availability_rules?.availability_method\n ? selectedConfig?.availability?.availability_rules?.availability_method !== 'collective'\n : false;\n this.participants = selectedConfig?.participants || [];\n this.includeOrganizerAsParticipant = this.isRoundRobinConfig && this.participants.find(p => p.email === currentUser?.email) ? true : false;\n this.updateOrganizerAsParticipant();\n }\n\n /**\n * This method is essentially a workaround to check if the internals are available because\n * the unit tests in stencil do not support the internals.\n * @returns boolean\n */\n get isInternalsAvailable() {\n return this.internals !== undefined && typeof this.internals.setFormValue === 'function' && typeof this.internals.setValidity === 'function';\n }\n\n @Listen('inputOptionChanged')\n onInputOptionChanged(event: CustomEvent<{ value: string; name: string }>) {\n debug('nylas-additional-participants', 'onInputOptionChanged');\n const EMAIL_REGEX = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\n const index = event.detail.name;\n const participant = this.participantOptions?.find(participant => participant.email === event.detail.value);\n\n if (!participant && this.isRoundRobinConfig) {\n this.isInternalsAvailable && this.internals.setValidity({ customError: true }, 'For round robin configuration, participant should be selected from the dropdown.');\n this.participantErrors[index] = 'For round robin page, participant should be selected from the dropdown.';\n this.participants[index].is_valid = false;\n this.participants = [...this.participants];\n return;\n } else if (!participant && !EMAIL_REGEX.test(event.detail.value)) {\n this.isInternalsAvailable && this.internals.setValidity({ customError: true }, 'Please enter a valid email address');\n this.participantErrors[index] = 'Please enter a valid email address';\n this.participants[index].is_valid = false;\n this.participants = [...this.participants];\n return;\n } else {\n this.participantErrors[index] = '';\n this.participants[index].is_valid = true;\n this.isInternalsAvailable && this.internals.setValidity({});\n }\n this.participants[index].email = event.detail.value;\n // Default to the first calendar if participant was picked from the dropdown options\n this.participants[index].availability = participant && participant.calendars[0].id ? { calendar_ids: [participant.calendars[0].id] } : undefined;\n // If round-robin config, set booking calendar to first calendar for all participants\n this.participants[index].booking = participant && this.isRoundRobinConfig && participant.calendars[0].id ? { calendar_id: participant.calendars[0].id } : undefined;\n this.participants[index].name = participant?.name || event.detail.value;\n this.participants = [...this.participants];\n this.updateFormValue();\n }\n\n updateOrganizerAsParticipant() {\n const findCurrentUserInParticipants = this.participants.find(p => p.email === this.currentUser?.email);\n if (this.isRoundRobinConfig && !findCurrentUserInParticipants && this.currentUser?.email) {\n const bookingCalendarDefault = this.currentUserCalendars?.find(calendar => calendar.is_primary)?.id || this.currentUserCalendars?.[0]?.id || 'primary';\n this.participants = [\n {\n name: this.currentUser?.name,\n email: this.currentUser?.email,\n is_organizer: true,\n availability: {\n calendar_ids: [bookingCalendarDefault],\n },\n booking: {\n calendar_id: bookingCalendarDefault,\n },\n },\n ...this.participants,\n ];\n }\n this.updateFormValue();\n }\n\n addParticipant() {\n debug('nylas-additional-participants', 'addParticipant');\n this.participants = [...this.participants, { name: '', email: '', is_organizer: false }];\n this.updateFormValue();\n }\n removeParticipant(index: number) {\n debug('nylas-additional-participants', 'removeParticipant');\n this.participants = this.participants.filter((_, i) => i !== index);\n this.updateFormValue();\n }\n\n updateFormValue() {\n debug('nylas-additional-participants', 'updateFormValue');\n const participants = this.isRoundRobinConfig ? (this.includeOrganizerAsParticipant ? this.participants : this.participants.filter(p => !p.is_organizer)) : this.participants;\n if (participants.length === 0) {\n this.isInternalsAvailable && this.internals.setValidity({ customError: true }, 'Please add at least one participant');\n this.error = 'Please add at least one participant';\n } else {\n this.isInternalsAvailable && this.internals.setValidity({});\n this.error = '';\n this.isInternalsAvailable && this.internals.setFormValue(JSON.stringify(participants), this.name);\n this.valueChanged.emit({ value: JSON.stringify(participants), name: this.name });\n }\n }\n\n // Filter out the participants that are already added\n getArrayDifference(array1: AdditionalParticipant[], array2: Participant[]) {\n const filtered = array1.filter(participant1 => !array2.some(participant2 => participant1.email === participant2.email));\n return filtered.map(participant => {\n return { value: participant.email, label: participant.email };\n });\n }\n\n @RegisterComponent<NylasAdditionalParticipants, NylasSchedulerConfigConnector, Exclude<NylasSchedulerEditor['stores'], undefined>>({\n name: 'nylas-additional-participants',\n stateToProps: new Map([\n ['schedulerConfig.additionalParticipants', 'participantOptions'],\n ['schedulerConfig.selectedConfiguration', 'selectedConfiguration'],\n ['schedulerConfig.currentUser', 'currentUser'],\n ['schedulerConfig.calendars', 'currentUserCalendars'],\n ]),\n eventToProps: {},\n fireRegisterEvent: true,\n })\n render() {\n return (\n <Host part=\"nap\">\n <nylas-form-card>\n <h3 slot=\"header-title\" class=\"nylas-additional-participants__title\" part=\"nap__title\">\n Participants\n </h3>\n <p slot=\"header-subtitle\" class=\"nylas-additional-participants__subtitle\" part=\"nap__subtitle\">\n Add people in your team or organization to join the event.\n </p>\n <div slot=\"content\" class=\"nylas-additional-participants__content\">\n <div>\n {this.participants.map((participant, index) => {\n return (\n <div class={'nylas-additional-participants__input_group'} part=\"nap__input_group\">\n {!participant.is_organizer && <label>{`Participant ${index}`}</label>}\n <div\n part=\"nap__input_wrapper\"\n class={{\n 'nylas-additional-participants__input_wrapper': true,\n 'nylas-additional-participants__input_wrapper_organizer': participant?.is_organizer === true,\n 'nylas-additional-participants__input_wrapper_invalid': participant.is_valid === false,\n 'error': participant.is_valid === false,\n }}\n >\n <div class={{ 'nylas-additional-participants__input': true, 'organizer': participant?.is_organizer === true }} part=\"nap__input\">\n {participant.is_organizer ? (\n <input-component\n class={'label-input'}\n name={`${index}`}\n key={index}\n label=\"Organizer\"\n required={false}\n readOnly={participant.is_organizer}\n defaultValue={participant.email}\n >\n {this.isRoundRobinConfig && (\n <div class=\"required-input\" slot=\"additional-input\">\n <input\n type=\"checkbox\"\n name={`organizer_participant`}\n id={`organizer_participant`}\n onClick={() => {\n this.includeOrganizerAsParticipant = !this.includeOrganizerAsParticipant;\n this.updateFormValue();\n }}\n checked={this.includeOrganizerAsParticipant}\n />\n <label htmlFor={`organizer_participant`} aria-label=\"Include as participant\">\n Participant\n <tooltip-component id=\"organizer_participant_tooltip\">\n <info-icon slot=\"tooltip-icon\" />\n <span slot=\"tooltip-content\">\n <strong>Include Organizer:</strong> The organizer (you) will be included in the round-robin rotation. <br />\n <strong>Exclude Organizer:</strong> The organizer (you) will not be included in the round-robin rotation.\n </span>\n </tooltip-component>\n </label>\n </div>\n )}\n </input-component>\n ) : (\n <input-dropdown\n id={`${index}`}\n name={`${index}`}\n filterable={true}\n inputValue={participant.email}\n options={this.getArrayDifference(this.participantOptions || [], this.participants)}\n />\n )}\n {!participant.is_organizer && (\n <button onClick={() => this.removeParticipant(index)} part=\"nap__remove-participant\">\n <close-icon />\n </button>\n )}\n </div>\n </div>\n {!participant.is_valid && (\n <p class=\"nylas-additional-participants__error\" part=\"nap__error\">\n {this.participantErrors[index]}\n </p>\n )}\n </div>\n );\n })}\n <p class=\"nylas-additional-participants__error\" part=\"nap__error\">\n {this.error}\n </p>\n </div>\n <button class=\"nylas-additional-participants__add\" part=\"nap__add-participant\" onClick={() => this.addParticipant()}>\n <add-circle-icon /> <span>Add {this.participants.length > 1 ? 'another' : 'a'} participant</span>\n </button>\n </div>\n </nylas-form-card>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"nylas-additional-participants.js","sourceRoot":"","sources":["../../../../src/components/scheduler-editor/nylas-additional-participants/nylas-additional-participants.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAgB,MAAM,eAAe,CAAC;AAEvH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAsCtC,MAAM,OAAO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,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG;2CAAoB,CAC1F,CACL,CACU,CACb,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAjGC;IAXC,iBAAiB,CAAiH;QACjI,IAAI,EAAE,+BAA+B;QACrC,YAAY,EAAE,IAAI,GAAG,CAAC;YACpB,CAAC,wCAAwC,EAAE,oBAAoB,CAAC;YAChE,CAAC,uCAAuC,EAAE,uBAAuB,CAAC;YAClE,CAAC,6BAA6B,EAAE,aAAa,CAAC;YAC9C,CAAC,2BAA2B,EAAE,sBAAsB,CAAC;SACtD,CAAC;QACF,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,IAAI;KACxB,CAAC;;;;yDAiGD","sourcesContent":["import { RegisterComponent } from '@/common/register-component';\nimport { NylasSchedulerConfigConnector } from '@/connector/nylas-scheduler-config-connector';\nimport { debug } from '@/utils/utils';\nimport { AttachInternals, Component, Host, Prop, State, Watch, h, Element, Listen, EventEmitter } from '@stencil/core';\nimport { NylasSchedulerEditor } from '../nylas-scheduler-editor/nylas-scheduler-editor';\nimport { Event } from '@stencil/core';\nimport { AdditionalParticipant, Calendar, Configuration } from '@nylas/core';\nimport { User } from '@/common/nylas-api-request';\n\ntype Participant = {\n name?: string;\n email: string;\n is_valid?: boolean;\n is_organizer?: boolean;\n availability?: Availability;\n booking?: Booking;\n};\ntype Availability = {\n calendar_ids: string[];\n};\ntype Booking = {\n calendar_id: string;\n};\n\n/**\n * The `nylas-additional-participants` component is a form input for adding additional participants to an event.\n *\n * @part nap__title - The title of the component.\n * @part nap__subtitle - The subtitle of the component.\n * @part nap__content - The content of the component.\n * @part nap__input_group - The input group of the component.\n * @part nap__input_wrapper - The input wrapper of the component.\n * @part nap__input - The input of the component.\n * @part nap__remove-participant - The remove participant button of the component.\n * @part nap__add-participant - The add participant button of the component.\n *\n */\n@Component({\n tag: 'nylas-additional-participants',\n styleUrl: 'nylas-additional-participants.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class NylasAdditionalParticipants {\n @Element() host!: HTMLNylasAdditionalParticipantsElement;\n /**\n * @standalone\n * The name of the component\n */\n @Prop() name: string = 'participants';\n /**\n * @standalone\n * The selected config\n */\n @Prop() selectedConfiguration?: Configuration;\n /**\n * @standalone\n * The logged in user\n */\n @Prop() currentUser?: User;\n /**\n * @standalone\n * The list of user's calendars.\n */\n @Prop() currentUserCalendars?: Calendar[];\n /**\n * @standalone\n * The additional participants options from the config\n */\n @Prop() participantOptions?: AdditionalParticipant[];\n /**\n * @standalone\n * The event participants\n */\n @Prop() eventParticipants?: Participant[];\n\n @AttachInternals() internals!: ElementInternals;\n @State() participants: Participant[] = this.eventParticipants ?? [];\n @State() participantErrors: { [key: string]: string } = {};\n @State() includeOrganizerAsParticipant: boolean = true;\n @State() isRoundRobinConfig: boolean = false;\n @State() error: string = '';\n\n /**\n * This event is fired when the selected participants change.\n */\n @Event() valueChanged!: EventEmitter<{\n value: string;\n name: string;\n }>;\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-additional-participants', 'elementNameChangedHandler', newValue);\n this.host.setAttribute('name', newValue);\n }\n\n @Watch('currentUser')\n @Watch('selectedConfiguration')\n selectedConfigurationAndCurrentUserChangedHandler(newValue: unknown, _oldValue: unknown, propName: string) {\n debug('nylas-additional-participants', 'selectedConfigurationAndCurrentUserChangedHandler', newValue, this.currentUser);\n\n if (propName === 'selectedConfiguration') {\n this.updateState(newValue as Configuration, this.currentUser);\n } else if (propName === 'currentUser') {\n this.updateState(this.selectedConfiguration, newValue as User);\n }\n }\n\n connectedCallback() {\n debug('nylas-additional-participants', 'connectedCallback');\n }\n\n componentWillLoad() {\n debug('nylas-additional-participants', 'componentWillLoad');\n this.host.setAttribute('name', this.name);\n }\n\n componentDidLoad() {\n debug('nylas-additional-participants', 'componentDidLoad');\n this.updateState(this.selectedConfiguration, this.currentUser);\n }\n\n disconnectedCallback() {\n debug('nylas-additional-participants', 'disconnectedCallback');\n }\n\n private updateState(selectedConfig?: Configuration, currentUser?: User) {\n this.isRoundRobinConfig = selectedConfig?.availability?.availability_rules?.availability_method\n ? selectedConfig?.availability?.availability_rules?.availability_method !== 'collective'\n : false;\n this.participants = selectedConfig?.participants || [];\n this.includeOrganizerAsParticipant = this.isRoundRobinConfig && this.participants.find(p => p.email === currentUser?.email) ? true : false;\n this.updateOrganizerAsParticipant();\n }\n\n /**\n * This method is essentially a workaround to check if the internals are available because\n * the unit tests in stencil do not support the internals.\n * @returns boolean\n */\n get isInternalsAvailable() {\n return this.internals !== undefined && typeof this.internals.setFormValue === 'function' && typeof this.internals.setValidity === 'function';\n }\n\n @Listen('inputOptionChanged')\n onInputOptionChanged(event: CustomEvent<{ value: string; name: string }>) {\n debug('nylas-additional-participants', 'onInputOptionChanged');\n const EMAIL_REGEX = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\n const index = event.detail.name;\n const participant = this.participantOptions?.find(participant => participant.email === event.detail.value);\n\n if (!participant && this.isRoundRobinConfig) {\n this.isInternalsAvailable && this.internals.setValidity({ customError: true }, 'For round robin configuration, participant should be selected from the dropdown.');\n this.participantErrors[index] = 'For round robin page, participant should be selected from the dropdown.';\n this.participants[index].is_valid = false;\n this.participants = [...this.participants];\n return;\n } else if (!participant && !EMAIL_REGEX.test(event.detail.value)) {\n this.isInternalsAvailable && this.internals.setValidity({ customError: true }, 'Please enter a valid email address');\n this.participantErrors[index] = 'Please enter a valid email address';\n this.participants[index].is_valid = false;\n this.participants = [...this.participants];\n return;\n } else {\n this.participantErrors[index] = '';\n this.participants[index].is_valid = true;\n this.isInternalsAvailable && this.internals.setValidity({});\n }\n this.participants[index].email = event.detail.value;\n // Default to the first calendar if participant was picked from the dropdown options\n this.participants[index].availability = participant && participant.calendars[0].id ? { calendar_ids: [participant.calendars[0].id] } : undefined;\n // If round-robin config, set booking calendar to first calendar for all participants\n this.participants[index].booking = participant && this.isRoundRobinConfig && participant.calendars[0].id ? { calendar_id: participant.calendars[0].id } : undefined;\n this.participants[index].name = participant?.name || event.detail.value;\n this.participants = [...this.participants];\n this.updateFormValue();\n }\n\n updateOrganizerAsParticipant() {\n const findCurrentUserInParticipants = this.participants.find(p => p.email === this.currentUser?.email);\n if (this.isRoundRobinConfig && !findCurrentUserInParticipants && this.currentUser?.email) {\n const bookingCalendarDefault = this.currentUserCalendars?.find(calendar => calendar.is_primary)?.id || this.currentUserCalendars?.[0]?.id || 'primary';\n this.participants = [\n {\n name: this.currentUser?.name,\n email: this.currentUser?.email,\n is_organizer: true,\n availability: {\n calendar_ids: [bookingCalendarDefault],\n },\n booking: {\n calendar_id: bookingCalendarDefault,\n },\n },\n ...this.participants,\n ];\n }\n this.updateFormValue();\n }\n\n addParticipant() {\n debug('nylas-additional-participants', 'addParticipant');\n this.participants = [...this.participants, { name: '', email: '', is_organizer: false }];\n this.updateFormValue();\n }\n removeParticipant(index: number) {\n debug('nylas-additional-participants', 'removeParticipant');\n this.participants = this.participants.filter((_, i) => i !== index);\n this.updateFormValue();\n }\n\n updateFormValue() {\n debug('nylas-additional-participants', 'updateFormValue');\n const participants = this.isRoundRobinConfig ? (this.includeOrganizerAsParticipant ? this.participants : this.participants.filter(p => !p.is_organizer)) : this.participants;\n if (participants.length === 0) {\n this.isInternalsAvailable && this.internals.setValidity({ customError: true }, 'Please add at least one participant');\n this.error = 'Please add at least one participant';\n } else {\n this.isInternalsAvailable && this.internals.setValidity({});\n this.error = '';\n this.isInternalsAvailable && this.internals.setFormValue(JSON.stringify(participants), this.name);\n this.valueChanged.emit({ value: JSON.stringify(participants), name: this.name });\n }\n }\n\n // Filter out the participants that are already added\n getArrayDifference(array1: AdditionalParticipant[], array2: Participant[]) {\n const filtered = array1.filter(participant1 => !array2.some(participant2 => participant1.email === participant2.email));\n return filtered.map(participant => {\n return { value: participant.email, label: participant.email };\n });\n }\n\n @RegisterComponent<NylasAdditionalParticipants, NylasSchedulerConfigConnector, Exclude<NylasSchedulerEditor['stores'], undefined>>({\n name: 'nylas-additional-participants',\n stateToProps: new Map([\n ['schedulerConfig.additionalParticipants', 'participantOptions'],\n ['schedulerConfig.selectedConfiguration', 'selectedConfiguration'],\n ['schedulerConfig.currentUser', 'currentUser'],\n ['schedulerConfig.calendars', 'currentUserCalendars'],\n ]),\n eventToProps: {},\n fireRegisterEvent: true,\n })\n render() {\n return (\n <Host part=\"nap\">\n <nylas-form-card>\n <h3 slot=\"header-title\" class=\"nylas-additional-participants__title\" part=\"nap__title\">\n Participants\n </h3>\n <p slot=\"header-subtitle\" class=\"nylas-additional-participants__subtitle\" part=\"nap__subtitle\">\n Add people in your team or organization to join the event.\n </p>\n <div slot=\"content\" class=\"nylas-additional-participants__content\">\n <div>\n {this.participants.map((participant, index) => {\n return (\n <div class={'nylas-additional-participants__input_group'} part=\"nap__input_group\">\n {!participant.is_organizer && <label>{`Participant ${index}`}</label>}\n <div\n part=\"nap__input_wrapper\"\n class={{\n 'nylas-additional-participants__input_wrapper': true,\n 'nylas-additional-participants__input_wrapper_organizer': participant?.is_organizer === true,\n 'nylas-additional-participants__input_wrapper_invalid': participant.is_valid === false,\n 'error': participant.is_valid === false,\n }}\n >\n <div class={{ 'nylas-additional-participants__input': true, 'organizer': participant?.is_organizer === true }} part=\"nap__input\">\n {participant.is_organizer ? (\n <input-component\n class={'label-input'}\n name={`${index}`}\n key={index}\n label=\"Organizer\"\n required={false}\n readOnly={participant.is_organizer}\n defaultValue={participant.email}\n >\n {this.isRoundRobinConfig && (\n <div class=\"required-input\" slot=\"additional-input\">\n <input\n type=\"checkbox\"\n name={`organizer_participant`}\n id={`organizer_participant`}\n onClick={() => {\n this.includeOrganizerAsParticipant = !this.includeOrganizerAsParticipant;\n this.updateFormValue();\n }}\n checked={this.includeOrganizerAsParticipant}\n />\n <label htmlFor={`organizer_participant`} aria-label=\"Include as participant\">\n Participant\n <tooltip-component id=\"organizer_participant_tooltip\">\n <info-icon slot=\"tooltip-icon\" />\n <span slot=\"tooltip-content\">\n <strong>Include Organizer:</strong> The organizer (you) will be included in the round-robin rotation. <br />\n <strong>Exclude Organizer:</strong> The organizer (you) will not be included in the round-robin rotation.\n </span>\n </tooltip-component>\n </label>\n </div>\n )}\n </input-component>\n ) : (\n <input-dropdown\n id={`${index}`}\n name={`${index}`}\n filterable={true}\n inputValue={participant.email}\n options={this.getArrayDifference(this.participantOptions || [], this.participants)}\n />\n )}\n {!participant.is_organizer && (\n <button onClick={() => this.removeParticipant(index)} part=\"nap__remove-participant\">\n <close-icon />\n </button>\n )}\n </div>\n </div>\n {!participant.is_valid && (\n <p class=\"nylas-additional-participants__error\" part=\"nap__error\">\n {this.participantErrors[index]}\n </p>\n )}\n </div>\n );\n })}\n <p class=\"nylas-additional-participants__error\" part=\"nap__error\">\n {this.error}\n </p>\n </div>\n <button class=\"nylas-additional-participants__add\" part=\"nap__add-participant\" onClick={() => this.addParticipant()}>\n <add-circle-icon /> <span>Add {this.participants.length > 1 ? 'another' : 'a'} participant</span>\n </button>\n </div>\n </nylas-form-card>\n </Host>\n );\n }\n}\n"]}
@@ -17,6 +17,28 @@ import { debug } from "../../../utils/utils";
17
17
  import { Host, h } from "@stencil/core";
18
18
  import { DEFAULT_FORM_FIELD_TYPES, FIELD_TYPES } from "../../../common/constants";
19
19
  import Sortable from "sortablejs";
20
+ const staticFields = [
21
+ {
22
+ type: 'text',
23
+ label: 'Your name',
24
+ key: 'your_name',
25
+ typeLabel: 'Short text',
26
+ readonly: true,
27
+ required: true,
28
+ isOpen: false,
29
+ order: 0,
30
+ },
31
+ {
32
+ type: 'email',
33
+ label: 'Your Email',
34
+ key: 'your_email',
35
+ typeLabel: 'Email',
36
+ readonly: true,
37
+ isOpen: false,
38
+ required: true,
39
+ order: 1,
40
+ },
41
+ ];
20
42
  export class NylasBookingFormConfig {
21
43
  constructor() {
22
44
  this.selectedConfiguration = undefined;
@@ -28,6 +50,9 @@ export class NylasBookingFormConfig {
28
50
  debug('nylas-calendar-picker', 'elementNameChangedHandler', newValue);
29
51
  this.host.setAttribute('name', newValue);
30
52
  }
53
+ selectedConfigurationChangedHandler(newValue) {
54
+ this.updateFormFields(newValue);
55
+ }
31
56
  connectedCallback() {
32
57
  debug('nylas-booking-form-config', 'connectedCallback');
33
58
  }
@@ -37,37 +62,18 @@ export class NylasBookingFormConfig {
37
62
  componentWillLoad() {
38
63
  debug('nylas-booking-form-config', 'componentWillLoad');
39
64
  this.host.setAttribute('name', this.name);
40
- const staticFields = [
41
- {
42
- type: 'text',
43
- label: 'Your name',
44
- key: 'your_name',
45
- typeLabel: 'Short text',
46
- readonly: true,
47
- required: true,
48
- isOpen: false,
49
- order: 0,
50
- },
51
- {
52
- type: 'email',
53
- label: 'Your Email',
54
- key: 'your_email',
55
- typeLabel: 'Email',
56
- readonly: true,
57
- isOpen: false,
58
- required: true,
59
- order: 1,
60
- },
61
- ];
62
65
  this.formFields = [...staticFields];
63
66
  }
64
67
  componentDidLoad() {
65
68
  debug('nylas-booking-form-config', 'componentDidLoad');
66
- const additionalFields = Object.entries(this.selectedConfiguration?.scheduler?.additional_fields || {}).map(([id, field]) => ({ ...field, key: id })) ||
67
- this.additionalFields ||
68
- [];
69
+ if (this.selectedConfiguration) {
70
+ this.updateFormFields(this.selectedConfiguration);
71
+ }
72
+ }
73
+ updateFormFields(config) {
74
+ const additionalFields = Object.entries(config?.scheduler?.additional_fields || {}).map(([id, field]) => ({ ...field, key: id })) || this.additionalFields || [];
69
75
  this.formFields = [
70
- ...this.formFields,
76
+ ...staticFields,
71
77
  ...additionalFields
72
78
  .sort((a, b) => a.order - b.order)
73
79
  .map((f, i) => {
@@ -275,7 +281,7 @@ export class NylasBookingFormConfig {
275
281
  });
276
282
  }
277
283
  render() {
278
- return (h(Host, { key: '632d9bd6cc0162efdb7e83b78b23935f04569fcb' }, h("div", { key: 'dae8d7f52a658b121a992f9cd73cd766e2c16cec', class: "nylas-booking-form-config", part: "nbfc" }, h("div", { key: '4f02c7163dfecd29df48da9b163e12e9a6c9c357', class: "header", part: "nbfc__header" }, h("div", { key: '169cfa3f8d4dd519dd0621d032d3e7a13384b8c7', class: "header_text" }, h("h3", { key: '66e50347bae8fca4c3344030d4d3caf4158244e2' }, "Booking form"), h("p", { key: '883886b2c841acdbd44e6cb1c18a860a51c52412' }, "Add custom fields to the booking form.")), h("div", { key: 'e307526fa6d75c4aaaa71c5658006d9e7417c0f0', class: "header_action" }, h("select-dropdown", { key: '4b16dd221f5740b21cde95488e2609730e08ea54', name: "add-field", exportparts: "sd_dropdown: nbfc__add_field, sd_dropdown-button: nbfc__add_field-button, sd_dropdown-content: nbfc__add_field-dropdown-content", options: DEFAULT_FORM_FIELD_TYPES, withSearch: false, withChevron: false, dropdownButtonText: "Add new field" }, h("span", { key: '5ccd949bb563f32f1682b9432759828f086b46e3', slot: "select-icon" }, h("plus-icon", { key: 'b77ac5dd297071ec6e16c3728db1a7b096e83e74', width: "15", height: "15" }))))), h("div", { key: 'a7499ce8959d027f0540b086c3393353c3993452', class: "content" }, h("div", { key: 'ff24161e13beba123ca46c814515704bf06d4259', id: "fields", class: "additional_fields", part: "nbfc__additional_fields" }, this.formFields.map((field, i) => {
284
+ return (h(Host, { key: 'bd832f2b9a02ce53187e4f633e4c0388e6e65a03' }, h("div", { key: 'fcf79fe131d8e0a99312286b15f228b997d8c0be', class: "nylas-booking-form-config", part: "nbfc" }, h("div", { key: '07cd086a8af8145f5a8c6676e360fa5f919040f3', class: "header", part: "nbfc__header" }, h("div", { key: 'f703982061b36b7f4b792f4deff59cc4256b7c25', class: "header_text" }, h("h3", { key: 'a7cba135c527592a000c296ceaf68bb91c9ddcf4' }, "Booking form"), h("p", { key: '62acf8b4a583145e2bc300b1b351799dec1ff438' }, "Add custom fields to the booking form.")), h("div", { key: '574ef9a02aa06ad29ac0b08c22aa749a844d32d8', class: "header_action" }, h("select-dropdown", { key: 'c2a83f721237dc1032af5e55e17438e1060b2e58', name: "add-field", exportparts: "sd_dropdown: nbfc__add_field, sd_dropdown-button: nbfc__add_field-button, sd_dropdown-content: nbfc__add_field-dropdown-content", options: DEFAULT_FORM_FIELD_TYPES, withSearch: false, withChevron: false, dropdownButtonText: "Add new field" }, h("span", { key: 'e0aaa33a3bd04b79499310c3904984269eaecbf3', slot: "select-icon" }, h("plus-icon", { key: '06bf29f2b3d0dca74d660db8791a47bc2474652b', width: "15", height: "15" }))))), h("div", { key: 'b33cfae9a876be328d795366802a1791e22ca164', class: "content" }, h("div", { key: '0df453e1fc129a13b90b33c6e267ecd9dd149c56', id: "fields", class: "additional_fields", part: "nbfc__additional_fields" }, this.formFields.map((field, i) => {
279
285
  return (h("div", { class: `form-field draggable ${field.readonly && 'fixed'}`, part: "nbfc__form_field", key: i }, h("div", { class: "form-field_header", part: "nbfc__form_field-header" }, h("span", { class: "dragable" }, h("dragable-icon", { width: "24", height: "25" })), h("div", { class: "form-field_header_text" }, h("h4", null, field.label), h("p", null, field.typeLabel)), h("div", { class: "form-field_header_actions" }, h("span", { class: `is-required` }, field.required ? 'Required' : 'Optional'), !field.readonly && (h("button", { onClick: () => {
280
286
  this.fieldRemove(i);
281
287
  } }, h("close-icon", null))), h("span", { class: `chevron ${field.isOpen ? 'open' : 'closed'}`, onClick: () => {
@@ -407,6 +413,9 @@ export class NylasBookingFormConfig {
407
413
  return [{
408
414
  "propName": "name",
409
415
  "methodName": "elementNameChangedHandler"
416
+ }, {
417
+ "propName": "selectedConfiguration",
418
+ "methodName": "selectedConfigurationChangedHandler"
410
419
  }, {
411
420
  "propName": "formFields",
412
421
  "methodName": "watchHandler"