@nylas/react 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/add-circle-icon_2.entry-8c3bb0bb.cjs +1 -0
  2. package/dist/{add-circle-icon_2.entry-e59a5b4d.js → add-circle-icon_2.entry-a3daf6c4.js} +6 -4
  3. package/dist/archive-icon.entry-46ad0ff3.cjs +1 -0
  4. package/dist/{archive-icon.entry-ea5667df.js → archive-icon.entry-d5141486.js} +6 -4
  5. package/dist/{arrow-icon.entry-1f766862.js → arrow-icon.entry-1b89ce78.js} +6 -4
  6. package/dist/arrow-icon.entry-f696de4f.cjs +1 -0
  7. package/dist/bold-icon.entry-7827cd4e.cjs +1 -0
  8. package/dist/{bold-icon.entry-240950a6.js → bold-icon.entry-c117b4cf.js} +6 -4
  9. package/dist/button-component_2.entry-8cd4c5f3.cjs +1 -0
  10. package/dist/{button-component_2.entry-96785a34.js → button-component_2.entry-e68caa9b.js} +5 -3
  11. package/dist/{calendar-agenda-fill-icon_37.entry-e732ee2e.js → calendar-agenda-fill-icon_37.entry-52bdc8b3.js} +1478 -1210
  12. package/dist/calendar-agenda-fill-icon_37.entry-8c592cfa.cjs +6 -0
  13. package/dist/calendar-cancel-icon.entry-7facfa05.cjs +1 -0
  14. package/dist/{calendar-cancel-icon.entry-7543c684.js → calendar-cancel-icon.entry-f5f1d499.js} +8 -6
  15. package/dist/{calendar-check-icon.entry-aba54652.js → calendar-check-icon.entry-55320137.js} +6 -4
  16. package/dist/calendar-check-icon.entry-72108702.cjs +1 -0
  17. package/dist/{calendar-icon.entry-2cb3b7d1.js → calendar-icon.entry-afea361e.js} +9 -7
  18. package/dist/calendar-icon.entry-f5c6730f.cjs +1 -0
  19. package/dist/checkbox-component.entry-5722d263.cjs +1 -0
  20. package/dist/checkbox-component.entry-89fa6edd.js +54 -0
  21. package/dist/checkbox-group_4.entry-30e8af17.cjs +28 -0
  22. package/dist/{checkbox-group_4.entry-04561314.js → checkbox-group_4.entry-51f03009.js} +289 -245
  23. package/dist/checkmark-circle-icon.entry-ae11049d.cjs +1 -0
  24. package/dist/{checkmark-circle-icon.entry-1f788efc.js → checkmark-circle-icon.entry-dfe67e22.js} +8 -6
  25. package/dist/{checkmark-icon_15.entry-146c1cb0.js → checkmark-icon_15.entry-4c3979db.js} +408 -332
  26. package/dist/checkmark-icon_15.entry-e59c0f53.cjs +5 -0
  27. package/dist/{chevron-icon_3.entry-637338b5.js → chevron-icon_3.entry-1f3c3ca6.js} +21 -10
  28. package/dist/chevron-icon_3.entry-ea791750.cjs +1 -0
  29. package/dist/clock-icon_4.entry-172fed74.cjs +1 -0
  30. package/dist/{clock-icon_4.entry-e69395a2.js → clock-icon_4.entry-78878cb8.js} +3 -1
  31. package/dist/customParseFormat-b5d95b34-a6b6fcba.cjs +1 -0
  32. package/dist/{customParseFormat-8be9be1b-2464f2ba.js → customParseFormat-b5d95b34-ce80820c.js} +1 -1
  33. package/dist/delete-icon.entry-a8c0bf03.cjs +1 -0
  34. package/dist/{delete-icon.entry-8a956edd.js → delete-icon.entry-cebdc90f.js} +7 -5
  35. package/dist/document-refresh-icon.entry-2d9a529d.cjs +1 -0
  36. package/dist/{document-refresh-icon.entry-5f58f367.js → document-refresh-icon.entry-8780a2b8.js} +3 -1
  37. package/dist/{feedbackSync-3db3713c-701d2eb9.cjs → feedbackSync-92220b42-fbebe1f9.cjs} +1 -1
  38. package/dist/{feedbackSync-3db3713c-aadf336b.js → feedbackSync-92220b42-fd5f5610.js} +1 -1
  39. package/dist/folder-icon.entry-3e61ccca.cjs +1 -0
  40. package/dist/{folder-icon.entry-e5d7a651.js → folder-icon.entry-6ffd5191.js} +6 -4
  41. package/dist/forward-icon.entry-c7d88db8.cjs +1 -0
  42. package/dist/{forward-icon.entry-59be8165.js → forward-icon.entry-c9c4bf5b.js} +5 -3
  43. package/dist/globe-icon.entry-0b93cab8.cjs +1 -0
  44. package/dist/{globe-icon.entry-0fe4a4bb.js → globe-icon.entry-7c0dca7b.js} +5 -3
  45. package/dist/{google-logo-icon_6.entry-799511df.js → google-logo-icon_6.entry-deef91ee.js} +283 -237
  46. package/dist/google-logo-icon_6.entry-e25ce3e7.cjs +2 -0
  47. package/dist/google-meet-icon_5.entry-214347f0.cjs +1 -0
  48. package/dist/{google-meet-icon_5.entry-e753ba28.js → google-meet-icon_5.entry-f8b5a92a.js} +3 -1
  49. package/dist/{inbox-icon.entry-61132337.js → inbox-icon.entry-873062c3.js} +7 -5
  50. package/dist/inbox-icon.entry-f08f2fd5.cjs +1 -0
  51. package/dist/index-025be398.js +7187 -0
  52. package/dist/index-c510313d-1318f67a.js +289 -0
  53. package/dist/index-c510313d-b0508eee.cjs +1 -0
  54. package/dist/index-f42fe591.cjs +65 -0
  55. package/dist/{index.es-9e756df7-fa75b01e.cjs → index.es-488bc919-d02dd50a.cjs} +1 -1
  56. package/dist/{index.es-9e756df7-42d8a4cf.js → index.es-488bc919-ea63a7e9.js} +1 -1
  57. package/dist/info-icon_2.entry-442b9097.cjs +1 -0
  58. package/dist/{info-icon_2.entry-8d2750ce.js → info-icon_2.entry-60fb8648.js} +3 -1
  59. package/dist/{input-component.entry-2e134e2a.js → input-component.entry-5898a52e.js} +22 -10
  60. package/dist/input-component.entry-7274fd28.cjs +1 -0
  61. package/dist/{input-dropdown_2.entry-1a02e672.js → input-dropdown_2.entry-4534436c.js} +33 -9
  62. package/dist/input-dropdown_2.entry-9b72f637.cjs +1 -0
  63. package/dist/{italic-icon.entry-0ec2793b.js → italic-icon.entry-62052cd8.js} +6 -4
  64. package/dist/italic-icon.entry-9bdbbd37.cjs +1 -0
  65. package/dist/lib/connect/index.d.ts +6 -0
  66. package/dist/lib/connect/types.d.ts +2 -0
  67. package/dist/lib/connect/useNylasConnect.d.ts +28 -0
  68. package/dist/lib/connect/useNylasConnect.test.d.ts +1 -0
  69. package/dist/lib/elements/index.d.ts +1 -1
  70. package/dist/lib/index.d.ts +1 -0
  71. package/dist/lib/notetaker/SendNotetaker/SendNotetaker.d.ts +3 -2
  72. package/dist/lib/notetaker/VideoPlayer/VideoPlayer.d.ts +2 -0
  73. package/dist/multi-select-dropdown.entry-77752d46.cjs +1 -0
  74. package/dist/{multi-select-dropdown.entry-15e887be.js → multi-select-dropdown.entry-9c9d05c1.js} +42 -30
  75. package/dist/{nylas-booked-event-card_11.entry-98bcc904.js → nylas-booked-event-card_11.entry-32b2e9f1.js} +188 -185
  76. package/dist/nylas-booked-event-card_11.entry-4aba5146.cjs +1 -0
  77. package/dist/nylas-date-component_2.entry-6b058796.cjs +1 -0
  78. package/dist/{nylas-date-component_2.entry-6a98a5bf.js → nylas-date-component_2.entry-a869519f.js} +91 -70
  79. package/dist/nylas-form-card.entry-5390459f.js +75 -0
  80. package/dist/nylas-form-card.entry-c2f34d73.cjs +1 -0
  81. package/dist/nylas-notification_2.entry-054392cf.cjs +1 -0
  82. package/dist/{nylas-notification_2.entry-320a5a65.js → nylas-notification_2.entry-f46e88e5.js} +4 -1
  83. package/dist/{nylas-scheduler-editor.entry-aa62c689.js → nylas-scheduler-editor.entry-40a48f47.js} +129 -60
  84. package/dist/nylas-scheduler-editor.entry-e29fdf07.cjs +2 -0
  85. package/dist/{nylas-scheduling.entry-aec79de5.js → nylas-scheduling.entry-115b1752.js} +203 -190
  86. package/dist/nylas-scheduling.entry-79cb1d9c.cjs +1 -0
  87. package/dist/person-icon.entry-2cae306c.cjs +1 -0
  88. package/dist/{person-icon.entry-23cbe5dd.js → person-icon.entry-fd668b89.js} +6 -4
  89. package/dist/{play-icon.entry-4a529bd2.js → play-icon.entry-7fc3c0fd.js} +5 -3
  90. package/dist/play-icon.entry-9989a520.cjs +1 -0
  91. package/dist/radio-button-group.entry-03385b5f.cjs +1 -0
  92. package/dist/{radio-button-group.entry-04b7ff59.js → radio-button-group.entry-9df82cd0.js} +21 -10
  93. package/dist/react.cjs +1 -1
  94. package/dist/react.js +142 -127
  95. package/dist/refresh-icon.entry-310954ba.cjs +1 -0
  96. package/dist/{refresh-icon.entry-61ced881.js → refresh-icon.entry-c56e5623.js} +8 -6
  97. package/dist/register-component-3acd57e7-5a79a90a.cjs +1 -0
  98. package/dist/{register-component-8bbd6492-0d8737fd.js → register-component-3acd57e7-cb09c05e.js} +15 -14
  99. package/dist/{reply-all-icon.entry-83509aaf.js → reply-all-icon.entry-32e0e000.js} +7 -5
  100. package/dist/reply-all-icon.entry-68388f97.cjs +1 -0
  101. package/dist/{reply-icon.entry-131ade31.js → reply-icon.entry-3ac2e736.js} +6 -4
  102. package/dist/reply-icon.entry-e616a9a4.cjs +1 -0
  103. package/dist/{sent-icon.entry-72fd8f16.js → sent-icon.entry-0622ed04.js} +6 -4
  104. package/dist/sent-icon.entry-543eb3c4.cjs +1 -0
  105. package/dist/{spam-icon.entry-7594c792.js → spam-icon.entry-74bcfd4f.js} +3 -1
  106. package/dist/spam-icon.entry-e341ee3e.cjs +1 -0
  107. package/dist/{star-icon.entry-adbe1bb3.js → star-icon.entry-864d2bf9.js} +5 -3
  108. package/dist/star-icon.entry-c90d40f6.cjs +1 -0
  109. package/dist/{stop-icon.entry-e95993f2.js → stop-icon.entry-835908c5.js} +3 -1
  110. package/dist/stop-icon.entry-ffc46b42.cjs +1 -0
  111. package/dist/{textarea-component.entry-f5d74fb8.js → textarea-component.entry-6adcf6a6.js} +29 -10
  112. package/dist/textarea-component.entry-dae8eb5c.cjs +1 -0
  113. package/dist/toggle-switch.entry-5ee29867.cjs +1 -0
  114. package/dist/toggle-switch.entry-ff2ccb75.js +51 -0
  115. package/dist/{translate-icon.entry-01cbe664.js → translate-icon.entry-372dd808.js} +3 -1
  116. package/dist/translate-icon.entry-5606067d.cjs +1 -0
  117. package/dist/{trash-fill-icon.entry-b39ff771.js → trash-fill-icon.entry-01b4379e.js} +3 -1
  118. package/dist/trash-fill-icon.entry-daed6c0a.cjs +1 -0
  119. package/dist/underline-icon.entry-2020ee64.cjs +1 -0
  120. package/dist/{underline-icon.entry-39179a2e.js → underline-icon.entry-464b900d.js} +5 -3
  121. package/dist/utils-31933f5d-15041585.js +17878 -0
  122. package/dist/utils-31933f5d-1d4c81ab.cjs +54 -0
  123. package/package.json +4 -3
  124. package/dist/abstract-provider-97cdbfea-5837e17f.cjs +0 -1
  125. package/dist/abstract-provider-97cdbfea-6b0e3547.js +0 -187
  126. package/dist/add-circle-icon_2.entry-96ef4ded.cjs +0 -1
  127. package/dist/archive-icon.entry-49b4e0fd.cjs +0 -1
  128. package/dist/arrow-icon.entry-5aefd7de.cjs +0 -1
  129. package/dist/bold-icon.entry-1a4955df.cjs +0 -1
  130. package/dist/button-component_2.entry-357fa02a.cjs +0 -1
  131. package/dist/calendar-agenda-fill-icon_37.entry-5e405c00.cjs +0 -6
  132. package/dist/calendar-cancel-icon.entry-55d746cf.cjs +0 -1
  133. package/dist/calendar-check-icon.entry-63d33f23.cjs +0 -1
  134. package/dist/calendar-icon.entry-e13add9b.cjs +0 -1
  135. package/dist/checkbox-component.entry-8341a8d6.cjs +0 -1
  136. package/dist/checkbox-component.entry-da122544.js +0 -43
  137. package/dist/checkbox-group_4.entry-8854d522.cjs +0 -28
  138. package/dist/checkmark-circle-icon.entry-e637e20e.cjs +0 -1
  139. package/dist/checkmark-icon_15.entry-a265f687.cjs +0 -5
  140. package/dist/chevron-icon_3.entry-6c38b5e5.cjs +0 -1
  141. package/dist/clock-icon_4.entry-aa4117dc.cjs +0 -1
  142. package/dist/customParseFormat-8be9be1b-7ad95d87.cjs +0 -1
  143. package/dist/delete-icon.entry-af0cc45b.cjs +0 -1
  144. package/dist/document-refresh-icon.entry-45931416.cjs +0 -1
  145. package/dist/folder-icon.entry-cb80c172.cjs +0 -1
  146. package/dist/forward-icon.entry-c792734b.cjs +0 -1
  147. package/dist/globe-icon.entry-9ecf0255.cjs +0 -1
  148. package/dist/google-logo-icon_6.entry-60924f34.cjs +0 -2
  149. package/dist/google-meet-icon_5.entry-3841313d.cjs +0 -1
  150. package/dist/inbox-icon.entry-2b450378.cjs +0 -1
  151. package/dist/index-2084ffd9.js +0 -24884
  152. package/dist/index-e9dc7971.cjs +0 -118
  153. package/dist/info-icon_2.entry-c547775c.cjs +0 -1
  154. package/dist/input-component.entry-b1086460.cjs +0 -1
  155. package/dist/input-dropdown_2.entry-cb163dc3.cjs +0 -1
  156. package/dist/italic-icon.entry-6a3a5464.cjs +0 -1
  157. package/dist/multi-select-dropdown.entry-daccefd5.cjs +0 -1
  158. package/dist/nylas-booked-event-card_11.entry-3cdf8015.cjs +0 -1
  159. package/dist/nylas-date-component_2.entry-5d4f54fa.cjs +0 -1
  160. package/dist/nylas-form-card.entry-22851b77.cjs +0 -1
  161. package/dist/nylas-form-card.entry-a997084f.js +0 -58
  162. package/dist/nylas-notification_2.entry-4638126b.cjs +0 -1
  163. package/dist/nylas-scheduler-editor.entry-82e0f79e.cjs +0 -2
  164. package/dist/nylas-scheduling.entry-9cef581a.cjs +0 -1
  165. package/dist/person-icon.entry-01a6a976.cjs +0 -1
  166. package/dist/play-icon.entry-33443687.cjs +0 -1
  167. package/dist/radio-button-group.entry-65155787.cjs +0 -1
  168. package/dist/refresh-icon.entry-e4ea4811.cjs +0 -1
  169. package/dist/register-component-8bbd6492-d9a23f3c.cjs +0 -1
  170. package/dist/reply-all-icon.entry-c64d923b.cjs +0 -1
  171. package/dist/reply-icon.entry-4edfbb70.cjs +0 -1
  172. package/dist/sent-icon.entry-e4f6a3ef.cjs +0 -1
  173. package/dist/spam-icon.entry-c531c188.cjs +0 -1
  174. package/dist/star-icon.entry-a75255ff.cjs +0 -1
  175. package/dist/stop-icon.entry-079b28c6.cjs +0 -1
  176. package/dist/textarea-component.entry-920a81ac.cjs +0 -1
  177. package/dist/toggle-switch.entry-33273409.js +0 -34
  178. package/dist/toggle-switch.entry-ba6b4f33.cjs +0 -1
  179. package/dist/translate-icon.entry-f33632d6.cjs +0 -1
  180. package/dist/trash-fill-icon.entry-298eece8.cjs +0 -1
  181. package/dist/underline-icon.entry-3704187c.cjs +0 -1
@@ -0,0 +1,289 @@
1
+ import { b as r, j as k, k as R } from "./utils-31933f5d-15041585.js";
2
+ import { a as w, f as y } from "./index-025be398.js";
3
+ class I {
4
+ constructor(t, e, g = !0, i) {
5
+ this.automaticComponentRegistration = !0, this.registeredComponents = {}, this.propStateRegistrations = /* @__PURE__ */ new Map(), this.eventListenerRegistrations = /* @__PURE__ */ new Map(), this.host = t, this.stores = e, this.automaticComponentRegistration = g, this.eventOverrides = i, r(`[${this.hostTagName}] Initializing (abstract) provider.`, { eventOverrides: i }), this.registerComponent = this.registerComponent.bind(this), this.getStore = this.getStore.bind(this), Object.keys(this.stores).forEach((a) => {
6
+ this.propStateRegistrations.set(a, /* @__PURE__ */ new Map());
7
+ });
8
+ }
9
+ async componentWillLoad(t) {
10
+ r(`[${this.hostTagName}] Will load`), this.setupStoreListeners(), this.nylasConnector = t;
11
+ const e = Array.from(this.host.querySelectorAll("*")).filter((i) => i.tagName.toLowerCase().startsWith("nylas-"));
12
+ r(`[${this.hostTagName}] Found ${e.length} child component(s).`, { childComponents: e });
13
+ const g = e.map(async (i) => {
14
+ const a = i;
15
+ if (!a) {
16
+ r(`[~${this.hostTagName}] (componentWillLoad) Component ${a.tagName} does not have a name. Skipping.`);
17
+ return;
18
+ }
19
+ if (!a.registerNylasComponent) {
20
+ r(`[~${this.hostTagName}] (componentWillLoad) Component ${a.tagName} is not a component that can be registered. Skipping.`, { component: a });
21
+ return;
22
+ }
23
+ const l = {
24
+ element: a,
25
+ name: a.tagName.toLowerCase(),
26
+ getStoresToProp: a.getStoresToProp,
27
+ storeToProps: a.storeToProps,
28
+ stateToProps: a.stateToProps,
29
+ authToProp: a.authToProp,
30
+ eventToProps: a.eventToProps,
31
+ connectorToProp: a.connectorToProp,
32
+ localPropsToProp: a.localPropsToProp
33
+ };
34
+ await this.registerComponent(l);
35
+ });
36
+ await Promise.all(g);
37
+ }
38
+ async componentDidLoad() {
39
+ r(`[~${this.hostTagName}] (componentDidLoad) Did load`);
40
+ }
41
+ async componentDisconnected() {
42
+ Object.values(this.stores).forEach((t) => {
43
+ t.dispose();
44
+ });
45
+ }
46
+ async registerComponentHandler(t) {
47
+ if (t.stopPropagation(), !this.automaticComponentRegistration) {
48
+ r(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${t.detail.name}.`);
49
+ return;
50
+ }
51
+ await this.registerComponent(t.detail);
52
+ }
53
+ async unregisterComponentHandler(t) {
54
+ if (t.stopPropagation(), !this.automaticComponentRegistration) {
55
+ r(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${t.detail.name}.`);
56
+ return;
57
+ }
58
+ this.unregisterComponent(t.detail);
59
+ }
60
+ async registerComponent(t) {
61
+ r(`~[${this.hostTagName}] (registerComponent) Registering component ${t.name}.`);
62
+ const e = t.element.dataset.nylasId;
63
+ e && this.registeredComponents[e] ? (r(`[${this.hostTagName}] (registerComponent) Component ${t.name} already registered. Updating registration.`), this.cleanupComponentRegistration(e, !1)) : t.element.dataset.nylasId = e || k();
64
+ const i = t.element.dataset.nylasId;
65
+ i && (this.registeredComponents[i] = t), r(`[${this.hostTagName}] (registerComponent) Waiting for "${t.element.localName}" component to be defined`, { component: t });
66
+ try {
67
+ await customElements.whenDefined(t.element.tagName.toLowerCase()), r(`[${this.hostTagName}] (registerComponent) Component "${t.element.localName}" is now defined`);
68
+ } catch (u) {
69
+ r(`[${this.hostTagName}] (registerComponent) Error waiting for component "${t.element.localName}" to be defined:`, u);
70
+ }
71
+ const a = this.eventOverrides, { stateToProps: l, getStoresToProp: m, eventToProps: f, storeToProps: $, connectorToProp: c, localPropsToProp: S, element: d } = t;
72
+ f == null || f.forEach((u, s) => {
73
+ var T;
74
+ const n = this.nylasConnector, h = async (N) => {
75
+ r(`[${this.hostTagName}] (registerComponent) Handling "${t.name}" prop "${String(s)}" event.`, { event: N }), s in a && (r(`[${this.hostTagName}] (registerComponent) Found event override for "${String(s)}" event. Calling override.`), await a[s](N, n)), N.defaultPrevented || await u(N, n);
76
+ }, p = t.element.dataset.nylasId;
77
+ p && !this.eventListenerRegistrations.has(p) && this.eventListenerRegistrations.set(p, []), p && ((T = this.eventListenerRegistrations.get(p)) == null || T.push([d, s, h])), r(`[${this.hostTagName}] (registerComponent) Setting "${t.name}" event "${String(s)}" to automcially call NylasConnector method.`);
78
+ const C = R(s.toString());
79
+ r(`[${this.hostTagName}] (registerComponent) Adding event listener for "${C}" on "${d.tagName}"`), d.addEventListener(C, h);
80
+ }), l == null || l.forEach((u, s) => {
81
+ var T, N, E, L;
82
+ const [n, h] = s.split("."), C = this.getStore(n).state[h];
83
+ if (!d.dataset.nylasId) {
84
+ r(`[${this.hostTagName}] (registerComponent) Component "${t.name}" not registered. Skipping.`, { component: t });
85
+ return;
86
+ }
87
+ this.propStateRegistrations.has(n) || this.propStateRegistrations.set(n, /* @__PURE__ */ new Map()), (T = this.propStateRegistrations.get(n)) != null && T.has(h) ? (L = (E = this.propStateRegistrations.get(n)) == null ? void 0 : E.get(h)) == null || L.push({
88
+ elementId: d.dataset.nylasId,
89
+ propKey: u
90
+ }) : (N = this.propStateRegistrations.get(n)) == null || N.set(h, [
91
+ {
92
+ elementId: d.dataset.nylasId,
93
+ propKey: u
94
+ }
95
+ ]), d[u.toString()] = C, r(`[${this.hostTagName}] Setting "${t.name}" prop "${u.toString()}" to "${s}" value.`, { stateValue: C });
96
+ }), S == null || S.forEach((u, s) => {
97
+ const n = this.host[s];
98
+ d[u.toString()] = n, r(`[${this.hostTagName}] Setting "${t.name}" prop "${u.toString()}" to the value of "${s}" value.`, { value: s, mappedPropValue: n });
99
+ }), m && (d[m == null ? void 0 : m.toString()] = this.getStore, r(`[${this.hostTagName}] Setting "${t.name}" prop "${m.toString()}" to "getStore" method.`)), $ == null || $.forEach((u, s) => {
100
+ const n = this.getStore(s);
101
+ d[u.toString()] = n, r(`[${this.hostTagName}] Setting "${t.name}" prop "${u.toString()}" to "${s}" store.`, { store: n });
102
+ }), c && (d[c == null ? void 0 : c.toString()] = this.nylasConnector, r(`[${this.hostTagName}] Setting "${t.name}" prop "${c.toString()}" to "nylasConnector" value.`, { connectorToProp: c })), typeof d.registerCallback == "function" && (r(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${t.name}".`), await d.registerCallback()), r(`[${this.hostTagName}] (registerComponent) Component ${t.name} registered.`);
103
+ }
104
+ cleanupComponentRegistration(t, e = !0) {
105
+ const g = this.eventListenerRegistrations.get(t);
106
+ g && (g.forEach(([i, a, l]) => {
107
+ const m = R(a.toString());
108
+ r(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${m}" on "${i.tagName}"`), i.removeEventListener(m, l);
109
+ }), this.eventListenerRegistrations.delete(t)), this.propStateRegistrations.forEach((i, a) => {
110
+ i.forEach((l, m) => {
111
+ var $;
112
+ const f = l.filter((c) => c.elementId !== t);
113
+ f.length !== l.length && (($ = this.propStateRegistrations.get(a)) == null || $.set(m, f));
114
+ });
115
+ }), e && delete this.registeredComponents[t];
116
+ }
117
+ unregisterComponent(t) {
118
+ r(`[${this.hostTagName}] Unregistering component ${t.name}.`);
119
+ const e = t.element.dataset.nylasId;
120
+ if (!e) {
121
+ r(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${t.name}.`);
122
+ return;
123
+ }
124
+ if (this.registeredComponents[e]) {
125
+ r(`[${this.hostTagName}] (unregisterComponent) Component ${t.name} not registered. Skipping.`);
126
+ return;
127
+ }
128
+ this.propStateRegistrations.forEach((i, a) => {
129
+ i.forEach((l, m) => {
130
+ var c, S;
131
+ const f = (c = this.propStateRegistrations.get(a)) == null ? void 0 : c.get(m), $ = f == null ? void 0 : f.filter((d) => d.elementId !== e);
132
+ $ && ((S = this.propStateRegistrations.get(a)) == null || S.set(m, $));
133
+ });
134
+ });
135
+ const g = this.eventListenerRegistrations.get(e);
136
+ g == null || g.forEach(([i, a, l]) => {
137
+ const m = R(a.toString());
138
+ r(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${m}" on "${i.tagName}"`), i.removeEventListener(m, l);
139
+ }), delete this.registeredComponents[e];
140
+ }
141
+ getStore(t) {
142
+ const e = this.stores[t];
143
+ if (!e)
144
+ throw new Error(`[${this.hostTagName}] Store "${t.toString()}" not found.`);
145
+ return e;
146
+ }
147
+ async setupStoreListeners() {
148
+ const t = this;
149
+ Object.entries(this.stores).forEach(([e, g]) => {
150
+ r(`[${t.hostTagName}] (setupStoreListeners) Listening for changes in "${e}" store.`), g.use({
151
+ set(i, a, l) {
152
+ var $;
153
+ if (r(`[${t.hostTagName}] (setupStoreListeners) Store "${e}" state "${i.toString()}" changed`, { newValue: a, oldValue: l }), a === l) {
154
+ r(`[${t.hostTagName}] (setupStoreListeners) Store "${e}" state "${i.toString()}" unchanged. Skipping.`);
155
+ return;
156
+ }
157
+ const m = t.registeredComponents;
158
+ if (!m) {
159
+ r(`[${t.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);
160
+ return;
161
+ }
162
+ const f = (($ = t.propStateRegistrations.get(e)) == null ? void 0 : $.get(i.toString())) || [];
163
+ r(`[${t.hostTagName}] (setupStoreListeners) Found ${f.length} prop(s) registered for "${i.toString()}" store.`, {
164
+ props: f,
165
+ propStateRegistrations: t.propStateRegistrations
166
+ }), f.forEach(({ elementId: c, propKey: S }) => {
167
+ const d = m[c];
168
+ if (!d) {
169
+ r(`[${t.hostTagName}] (setupStoreListeners) Component "${c}" not found. Skipping.`, { component: d });
170
+ return;
171
+ }
172
+ const s = t.getStore(e).state[i];
173
+ d.element[S.toString()] = s, r(`[${t.hostTagName}] (setupStoreListeners) Setting "${d.name}" prop "${S.toString()}" to "${i.toString()}" value.`, { stateValue: s });
174
+ });
175
+ }
176
+ });
177
+ });
178
+ }
179
+ get hostTagName() {
180
+ var t, e;
181
+ return ((e = (t = this.host) == null ? void 0 : t.tagName) == null ? void 0 : e.toLowerCase()) ?? "nylas-provider";
182
+ }
183
+ }
184
+ class W extends I {
185
+ }
186
+ const b = (o, t, e) => {
187
+ const g = o.get(t);
188
+ g ? g.includes(e) || g.push(e) : o.set(t, [e]);
189
+ }, O = (o, t) => {
190
+ let e;
191
+ return (...g) => {
192
+ e && clearTimeout(e), e = setTimeout(() => {
193
+ e = 0, o(...g);
194
+ }, t);
195
+ };
196
+ }, M = (o) => !("isConnected" in o) || o.isConnected, P = O((o) => {
197
+ for (let t of o.keys())
198
+ o.set(t, o.get(t).filter(M));
199
+ }, 2e3), A = () => {
200
+ if (typeof w != "function")
201
+ return {};
202
+ const o = /* @__PURE__ */ new Map();
203
+ return {
204
+ dispose: () => o.clear(),
205
+ get: (t) => {
206
+ const e = w();
207
+ e && b(o, t, e);
208
+ },
209
+ set: (t) => {
210
+ const e = o.get(t);
211
+ e && o.set(t, e.filter(y)), P(o);
212
+ },
213
+ reset: () => {
214
+ o.forEach((t) => t.forEach(y)), P(o);
215
+ }
216
+ };
217
+ }, v = (o) => typeof o == "function" ? o() : o, D = (o, t = (e, g) => e !== g) => {
218
+ const e = v(o);
219
+ let g = new Map(Object.entries(e ?? {}));
220
+ const i = {
221
+ dispose: [],
222
+ get: [],
223
+ set: [],
224
+ reset: []
225
+ }, a = () => {
226
+ var s;
227
+ g = new Map(Object.entries((s = v(o)) !== null && s !== void 0 ? s : {})), i.reset.forEach((n) => n());
228
+ }, l = () => {
229
+ i.dispose.forEach((s) => s()), a();
230
+ }, m = (s) => (i.get.forEach((n) => n(s)), g.get(s)), f = (s, n) => {
231
+ const h = g.get(s);
232
+ t(n, h, s) && (g.set(s, n), i.set.forEach((p) => p(s, n, h)));
233
+ }, $ = typeof Proxy > "u" ? {} : new Proxy(e, {
234
+ get(s, n) {
235
+ return m(n);
236
+ },
237
+ ownKeys(s) {
238
+ return Array.from(g.keys());
239
+ },
240
+ getOwnPropertyDescriptor() {
241
+ return {
242
+ enumerable: !0,
243
+ configurable: !0
244
+ };
245
+ },
246
+ has(s, n) {
247
+ return g.has(n);
248
+ },
249
+ set(s, n, h) {
250
+ return f(n, h), !0;
251
+ }
252
+ }), c = (s, n) => (i[s].push(n), () => {
253
+ U(i[s], n);
254
+ });
255
+ return {
256
+ state: $,
257
+ get: m,
258
+ set: f,
259
+ on: c,
260
+ onChange: (s, n) => {
261
+ const h = c("set", (C, T) => {
262
+ C === s && n(T);
263
+ }), p = c("reset", () => n(v(o)[s]));
264
+ return () => {
265
+ h(), p();
266
+ };
267
+ },
268
+ use: (...s) => {
269
+ const n = s.reduce((h, p) => (p.set && h.push(c("set", p.set)), p.get && h.push(c("get", p.get)), p.reset && h.push(c("reset", p.reset)), p.dispose && h.push(c("dispose", p.dispose)), h), []);
270
+ return () => n.forEach((h) => h());
271
+ },
272
+ dispose: l,
273
+ reset: a,
274
+ forceUpdate: (s) => {
275
+ const n = g.get(s);
276
+ i.set.forEach((h) => h(s, n, n));
277
+ }
278
+ };
279
+ }, U = (o, t) => {
280
+ const e = o.indexOf(t);
281
+ e >= 0 && (o[e] = o[o.length - 1], o.length--);
282
+ }, _ = (o, t) => {
283
+ const e = D(o, t);
284
+ return e.use(A()), e;
285
+ };
286
+ export {
287
+ W as N,
288
+ _ as c
289
+ };
@@ -0,0 +1 @@
1
+ "use strict";const n=require("./utils-31933f5d-1d4c81ab.cjs"),b=require("./index-f42fe591.cjs");class w{constructor(t,e,g=!0,i){this.automaticComponentRegistration=!0,this.registeredComponents={},this.propStateRegistrations=new Map,this.eventListenerRegistrations=new Map,this.host=t,this.stores=e,this.automaticComponentRegistration=g,this.eventOverrides=i,n.debug(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:i}),this.registerComponent=this.registerComponent.bind(this),this.getStore=this.getStore.bind(this),Object.keys(this.stores).forEach(a=>{this.propStateRegistrations.set(a,new Map)})}async componentWillLoad(t){n.debug(`[${this.hostTagName}] Will load`),this.setupStoreListeners(),this.nylasConnector=t;const e=Array.from(this.host.querySelectorAll("*")).filter(i=>i.tagName.toLowerCase().startsWith("nylas-"));n.debug(`[${this.hostTagName}] Found ${e.length} child component(s).`,{childComponents:e});const g=e.map(async i=>{const a=i;if(!a){n.debug(`[~${this.hostTagName}] (componentWillLoad) Component ${a.tagName} does not have a name. Skipping.`);return}if(!a.registerNylasComponent){n.debug(`[~${this.hostTagName}] (componentWillLoad) Component ${a.tagName} is not a component that can be registered. Skipping.`,{component:a});return}const p={element:a,name:a.tagName.toLowerCase(),getStoresToProp:a.getStoresToProp,storeToProps:a.storeToProps,stateToProps:a.stateToProps,authToProp:a.authToProp,eventToProps:a.eventToProps,connectorToProp:a.connectorToProp,localPropsToProp:a.localPropsToProp};await this.registerComponent(p)});await Promise.all(g)}async componentDidLoad(){n.debug(`[~${this.hostTagName}] (componentDidLoad) Did load`)}async componentDisconnected(){Object.values(this.stores).forEach(t=>{t.dispose()})}async registerComponentHandler(t){if(t.stopPropagation(),!this.automaticComponentRegistration){n.debug(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${t.detail.name}.`);return}await this.registerComponent(t.detail)}async unregisterComponentHandler(t){if(t.stopPropagation(),!this.automaticComponentRegistration){n.debug(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${t.detail.name}.`);return}this.unregisterComponent(t.detail)}async registerComponent(t){n.debug(`~[${this.hostTagName}] (registerComponent) Registering component ${t.name}.`);const e=t.element.dataset.nylasId;e&&this.registeredComponents[e]?(n.debug(`[${this.hostTagName}] (registerComponent) Component ${t.name} already registered. Updating registration.`),this.cleanupComponentRegistration(e,!1)):t.element.dataset.nylasId=e||n.uniqueID();const i=t.element.dataset.nylasId;i&&(this.registeredComponents[i]=t),n.debug(`[${this.hostTagName}] (registerComponent) Waiting for "${t.element.localName}" component to be defined`,{component:t});try{await customElements.whenDefined(t.element.tagName.toLowerCase()),n.debug(`[${this.hostTagName}] (registerComponent) Component "${t.element.localName}" is now defined`)}catch(f){n.debug(`[${this.hostTagName}] (registerComponent) Error waiting for component "${t.element.localName}" to be defined:`,f)}const a=this.eventOverrides,{stateToProps:p,getStoresToProp:d,eventToProps:u,storeToProps:$,connectorToProp:m,localPropsToProp:S,element:c}=t;u==null||u.forEach((f,s)=>{var N;const o=this.nylasConnector,h=async T=>{n.debug(`[${this.hostTagName}] (registerComponent) Handling "${t.name}" prop "${String(s)}" event.`,{event:T}),s in a&&(n.debug(`[${this.hostTagName}] (registerComponent) Found event override for "${String(s)}" event. Calling override.`),await a[s](T,o)),T.defaultPrevented||await f(T,o)},l=t.element.dataset.nylasId;l&&!this.eventListenerRegistrations.has(l)&&this.eventListenerRegistrations.set(l,[]),l&&((N=this.eventListenerRegistrations.get(l))==null||N.push([c,s,h])),n.debug(`[${this.hostTagName}] (registerComponent) Setting "${t.name}" event "${String(s)}" to automcially call NylasConnector method.`);const C=n.formatEventName(s.toString());n.debug(`[${this.hostTagName}] (registerComponent) Adding event listener for "${C}" on "${c.tagName}"`),c.addEventListener(C,h)}),p==null||p.forEach((f,s)=>{var N,T,v,E;const[o,h]=s.split("."),C=this.getStore(o).state[h];if(!c.dataset.nylasId){n.debug(`[${this.hostTagName}] (registerComponent) Component "${t.name}" not registered. Skipping.`,{component:t});return}this.propStateRegistrations.has(o)||this.propStateRegistrations.set(o,new Map),(N=this.propStateRegistrations.get(o))!=null&&N.has(h)?(E=(v=this.propStateRegistrations.get(o))==null?void 0:v.get(h))==null||E.push({elementId:c.dataset.nylasId,propKey:f}):(T=this.propStateRegistrations.get(o))==null||T.set(h,[{elementId:c.dataset.nylasId,propKey:f}]),c[f.toString()]=C,n.debug(`[${this.hostTagName}] Setting "${t.name}" prop "${f.toString()}" to "${s}" value.`,{stateValue:C})}),S==null||S.forEach((f,s)=>{const o=this.host[s];c[f.toString()]=o,n.debug(`[${this.hostTagName}] Setting "${t.name}" prop "${f.toString()}" to the value of "${s}" value.`,{value:s,mappedPropValue:o})}),d&&(c[d==null?void 0:d.toString()]=this.getStore,n.debug(`[${this.hostTagName}] Setting "${t.name}" prop "${d.toString()}" to "getStore" method.`)),$==null||$.forEach((f,s)=>{const o=this.getStore(s);c[f.toString()]=o,n.debug(`[${this.hostTagName}] Setting "${t.name}" prop "${f.toString()}" to "${s}" store.`,{store:o})}),m&&(c[m==null?void 0:m.toString()]=this.nylasConnector,n.debug(`[${this.hostTagName}] Setting "${t.name}" prop "${m.toString()}" to "nylasConnector" value.`,{connectorToProp:m})),typeof c.registerCallback=="function"&&(n.debug(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${t.name}".`),await c.registerCallback()),n.debug(`[${this.hostTagName}] (registerComponent) Component ${t.name} registered.`)}cleanupComponentRegistration(t,e=!0){const g=this.eventListenerRegistrations.get(t);g&&(g.forEach(([i,a,p])=>{const d=n.formatEventName(a.toString());n.debug(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${d}" on "${i.tagName}"`),i.removeEventListener(d,p)}),this.eventListenerRegistrations.delete(t)),this.propStateRegistrations.forEach((i,a)=>{i.forEach((p,d)=>{var $;const u=p.filter(m=>m.elementId!==t);u.length!==p.length&&(($=this.propStateRegistrations.get(a))==null||$.set(d,u))})}),e&&delete this.registeredComponents[t]}unregisterComponent(t){n.debug(`[${this.hostTagName}] Unregistering component ${t.name}.`);const e=t.element.dataset.nylasId;if(!e){n.debug(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${t.name}.`);return}if(this.registeredComponents[e]){n.debug(`[${this.hostTagName}] (unregisterComponent) Component ${t.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach((i,a)=>{i.forEach((p,d)=>{var m,S;const u=(m=this.propStateRegistrations.get(a))==null?void 0:m.get(d),$=u==null?void 0:u.filter(c=>c.elementId!==e);$&&((S=this.propStateRegistrations.get(a))==null||S.set(d,$))})});const g=this.eventListenerRegistrations.get(e);g==null||g.forEach(([i,a,p])=>{const d=n.formatEventName(a.toString());n.debug(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${d}" on "${i.tagName}"`),i.removeEventListener(d,p)}),delete this.registeredComponents[e]}getStore(t){const e=this.stores[t];if(!e)throw new Error(`[${this.hostTagName}] Store "${t.toString()}" not found.`);return e}async setupStoreListeners(){const t=this;Object.entries(this.stores).forEach(([e,g])=>{n.debug(`[${t.hostTagName}] (setupStoreListeners) Listening for changes in "${e}" store.`),g.use({set(i,a,p){var $;if(n.debug(`[${t.hostTagName}] (setupStoreListeners) Store "${e}" state "${i.toString()}" changed`,{newValue:a,oldValue:p}),a===p){n.debug(`[${t.hostTagName}] (setupStoreListeners) Store "${e}" state "${i.toString()}" unchanged. Skipping.`);return}const d=t.registeredComponents;if(!d){n.debug(`[${t.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);return}const u=(($=t.propStateRegistrations.get(e))==null?void 0:$.get(i.toString()))||[];n.debug(`[${t.hostTagName}] (setupStoreListeners) Found ${u.length} prop(s) registered for "${i.toString()}" store.`,{props:u,propStateRegistrations:t.propStateRegistrations}),u.forEach(({elementId:m,propKey:S})=>{const c=d[m];if(!c){n.debug(`[${t.hostTagName}] (setupStoreListeners) Component "${m}" not found. Skipping.`,{component:c});return}const s=t.getStore(e).state[i];c.element[S.toString()]=s,n.debug(`[${t.hostTagName}] (setupStoreListeners) Setting "${c.name}" prop "${S.toString()}" to "${i.toString()}" value.`,{stateValue:s})})}})})}get hostTagName(){var t,e;return((e=(t=this.host)==null?void 0:t.tagName)==null?void 0:e.toLowerCase())??"nylas-provider"}}class y extends w{}const P=(r,t,e)=>{const g=r.get(t);g?g.includes(e)||g.push(e):r.set(t,[e])},I=(r,t)=>{let e;return(...g)=>{e&&clearTimeout(e),e=setTimeout(()=>{e=0,r(...g)},t)}},k=r=>!("isConnected"in r)||r.isConnected,L=I(r=>{for(let t of r.keys())r.set(t,r.get(t).filter(k))},2e3),O=()=>{if(typeof b.getRenderingRef!="function")return{};const r=new Map;return{dispose:()=>r.clear(),get:t=>{const e=b.getRenderingRef();e&&P(r,t,e)},set:t=>{const e=r.get(t);e&&r.set(t,e.filter(b.forceUpdate)),L(r)},reset:()=>{r.forEach(t=>t.forEach(b.forceUpdate)),L(r)}}},R=r=>typeof r=="function"?r():r,M=(r,t=(e,g)=>e!==g)=>{const e=R(r);let g=new Map(Object.entries(e??{}));const i={dispose:[],get:[],set:[],reset:[]},a=()=>{var s;g=new Map(Object.entries((s=R(r))!==null&&s!==void 0?s:{})),i.reset.forEach(o=>o())},p=()=>{i.dispose.forEach(s=>s()),a()},d=s=>(i.get.forEach(o=>o(s)),g.get(s)),u=(s,o)=>{const h=g.get(s);t(o,h,s)&&(g.set(s,o),i.set.forEach(l=>l(s,o,h)))},$=typeof Proxy>"u"?{}:new Proxy(e,{get(s,o){return d(o)},ownKeys(s){return Array.from(g.keys())},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},has(s,o){return g.has(o)},set(s,o,h){return u(o,h),!0}}),m=(s,o)=>(i[s].push(o),()=>{A(i[s],o)});return{state:$,get:d,set:u,on:m,onChange:(s,o)=>{const h=m("set",(C,N)=>{C===s&&o(N)}),l=m("reset",()=>o(R(r)[s]));return()=>{h(),l()}},use:(...s)=>{const o=s.reduce((h,l)=>(l.set&&h.push(m("set",l.set)),l.get&&h.push(m("get",l.get)),l.reset&&h.push(m("reset",l.reset)),l.dispose&&h.push(m("dispose",l.dispose)),h),[]);return()=>o.forEach(h=>h())},dispose:p,reset:a,forceUpdate:s=>{const o=g.get(s);i.set.forEach(h=>h(s,o,o))}}},A=(r,t)=>{const e=r.indexOf(t);e>=0&&(r[e]=r[r.length-1],r.length--)},U=(r,t)=>{const e=M(r,t);return e.use(O()),e};exports.NylasBaseProvider=y;exports.createStore=U;