@nylas/react 2.1.0 → 2.2.1

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 (148) hide show
  1. package/dist/cjs/connect.js +1 -0
  2. package/dist/cjs/elements.js +1 -0
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/notetaker.js +62 -0
  5. package/dist/cjs/utils.js +11 -0
  6. package/dist/connect.d.ts +1 -0
  7. package/dist/elements.d.ts +1 -0
  8. package/dist/es/connect.js +279 -0
  9. package/dist/es/elements.js +1319 -0
  10. package/dist/es/index.js +281 -0
  11. package/dist/es/notetaker.js +5784 -0
  12. package/dist/es/utils.js +12396 -0
  13. package/dist/lib/connect/types.d.ts +1 -1
  14. package/dist/lib/connect/useNylasConnect.d.ts +2 -2
  15. package/dist/lib/connect.d.ts +1 -0
  16. package/dist/lib/elements/components.d.ts +975 -0
  17. package/dist/lib/elements.d.ts +1 -0
  18. package/dist/lib/index.d.ts +3 -6
  19. package/dist/lib/notetaker.d.ts +1 -0
  20. package/dist/lib/utils.d.ts +2 -0
  21. package/dist/notetaker.d.ts +1 -0
  22. package/dist/utils.d.ts +1 -0
  23. package/package.json +36 -16
  24. package/dist/add-circle-icon_2.entry-8c3bb0bb.cjs +0 -1
  25. package/dist/add-circle-icon_2.entry-a3daf6c4.js +0 -28
  26. package/dist/archive-icon.entry-46ad0ff3.cjs +0 -1
  27. package/dist/archive-icon.entry-d5141486.js +0 -18
  28. package/dist/arrow-icon.entry-1b89ce78.js +0 -18
  29. package/dist/arrow-icon.entry-f696de4f.cjs +0 -1
  30. package/dist/bold-icon.entry-7827cd4e.cjs +0 -1
  31. package/dist/bold-icon.entry-c117b4cf.js +0 -18
  32. package/dist/button-component_2.entry-8cd4c5f3.cjs +0 -1
  33. package/dist/button-component_2.entry-e68caa9b.js +0 -29
  34. package/dist/calendar-agenda-fill-icon_37.entry-52bdc8b3.js +0 -5234
  35. package/dist/calendar-agenda-fill-icon_37.entry-8c592cfa.cjs +0 -6
  36. package/dist/calendar-cancel-icon.entry-7facfa05.cjs +0 -1
  37. package/dist/calendar-cancel-icon.entry-f5f1d499.js +0 -18
  38. package/dist/calendar-check-icon.entry-55320137.js +0 -18
  39. package/dist/calendar-check-icon.entry-72108702.cjs +0 -1
  40. package/dist/calendar-icon.entry-afea361e.js +0 -18
  41. package/dist/calendar-icon.entry-f5c6730f.cjs +0 -1
  42. package/dist/checkbox-component.entry-5722d263.cjs +0 -1
  43. package/dist/checkbox-component.entry-89fa6edd.js +0 -54
  44. package/dist/checkbox-group_4.entry-30e8af17.cjs +0 -28
  45. package/dist/checkbox-group_4.entry-51f03009.js +0 -10014
  46. package/dist/checkmark-circle-icon.entry-ae11049d.cjs +0 -1
  47. package/dist/checkmark-circle-icon.entry-dfe67e22.js +0 -18
  48. package/dist/checkmark-icon_15.entry-4c3979db.js +0 -1415
  49. package/dist/checkmark-icon_15.entry-e59c0f53.cjs +0 -5
  50. package/dist/chevron-icon_3.entry-1f3c3ca6.js +0 -159
  51. package/dist/chevron-icon_3.entry-ea791750.cjs +0 -1
  52. package/dist/clock-icon_4.entry-172fed74.cjs +0 -1
  53. package/dist/clock-icon_4.entry-78878cb8.js +0 -48
  54. package/dist/constants-f51538ef-cd2a67c4.cjs +0 -1
  55. package/dist/constants-f51538ef-e0a5f026.js +0 -876
  56. package/dist/customParseFormat-b5d95b34-a6b6fcba.cjs +0 -1
  57. package/dist/customParseFormat-b5d95b34-ce80820c.js +0 -135
  58. package/dist/delete-icon.entry-a8c0bf03.cjs +0 -1
  59. package/dist/delete-icon.entry-cebdc90f.js +0 -18
  60. package/dist/document-refresh-icon.entry-2d9a529d.cjs +0 -1
  61. package/dist/document-refresh-icon.entry-8780a2b8.js +0 -18
  62. package/dist/feedbackSync-92220b42-fbebe1f9.cjs +0 -448
  63. package/dist/feedbackSync-92220b42-fd5f5610.js +0 -6048
  64. package/dist/folder-icon.entry-3e61ccca.cjs +0 -1
  65. package/dist/folder-icon.entry-6ffd5191.js +0 -18
  66. package/dist/forward-icon.entry-c7d88db8.cjs +0 -1
  67. package/dist/forward-icon.entry-c9c4bf5b.js +0 -18
  68. package/dist/globe-icon.entry-0b93cab8.cjs +0 -1
  69. package/dist/globe-icon.entry-7c0dca7b.js +0 -18
  70. package/dist/google-logo-icon_6.entry-deef91ee.js +0 -1765
  71. package/dist/google-logo-icon_6.entry-e25ce3e7.cjs +0 -2
  72. package/dist/google-meet-icon_5.entry-214347f0.cjs +0 -1
  73. package/dist/google-meet-icon_5.entry-f8b5a92a.js +0 -58
  74. package/dist/inbox-icon.entry-873062c3.js +0 -18
  75. package/dist/inbox-icon.entry-f08f2fd5.cjs +0 -1
  76. package/dist/index-025be398.js +0 -7187
  77. package/dist/index-c510313d-1318f67a.js +0 -289
  78. package/dist/index-c510313d-b0508eee.cjs +0 -1
  79. package/dist/index-f42fe591.cjs +0 -65
  80. package/dist/index.es-488bc919-d02dd50a.cjs +0 -7
  81. package/dist/index.es-488bc919-ea63a7e9.js +0 -2724
  82. package/dist/info-icon_2.entry-442b9097.cjs +0 -1
  83. package/dist/info-icon_2.entry-60fb8648.js +0 -37
  84. package/dist/input-component.entry-5898a52e.js +0 -96
  85. package/dist/input-component.entry-7274fd28.cjs +0 -1
  86. package/dist/input-dropdown_2.entry-4534436c.js +0 -255
  87. package/dist/input-dropdown_2.entry-9b72f637.cjs +0 -1
  88. package/dist/italic-icon.entry-62052cd8.js +0 -18
  89. package/dist/italic-icon.entry-9bdbbd37.cjs +0 -1
  90. package/dist/lib/elements/index.d.ts +0 -133
  91. package/dist/lib/elements/react-component-lib/createComponent.d.ts +0 -10
  92. package/dist/lib/elements/react-component-lib/createOverlayComponent.d.ts +0 -21
  93. package/dist/lib/elements/react-component-lib/index.d.ts +0 -2
  94. package/dist/lib/elements/react-component-lib/interfaces.d.ts +0 -29
  95. package/dist/lib/elements/react-component-lib/utils/attachProps.d.ts +0 -9
  96. package/dist/lib/elements/react-component-lib/utils/case.d.ts +0 -2
  97. package/dist/lib/elements/react-component-lib/utils/dev.d.ts +0 -2
  98. package/dist/lib/elements/react-component-lib/utils/index.d.ts +0 -10
  99. package/dist/multi-select-dropdown.entry-77752d46.cjs +0 -1
  100. package/dist/multi-select-dropdown.entry-9c9d05c1.js +0 -133
  101. package/dist/nylas-booked-event-card_11.entry-32b2e9f1.js +0 -1410
  102. package/dist/nylas-booked-event-card_11.entry-4aba5146.cjs +0 -1
  103. package/dist/nylas-date-component_2.entry-6b058796.cjs +0 -1
  104. package/dist/nylas-date-component_2.entry-a869519f.js +0 -310
  105. package/dist/nylas-form-card.entry-5390459f.js +0 -75
  106. package/dist/nylas-form-card.entry-c2f34d73.cjs +0 -1
  107. package/dist/nylas-notification_2.entry-054392cf.cjs +0 -1
  108. package/dist/nylas-notification_2.entry-f46e88e5.js +0 -88
  109. package/dist/nylas-scheduler-editor.entry-40a48f47.js +0 -1854
  110. package/dist/nylas-scheduler-editor.entry-e29fdf07.cjs +0 -2
  111. package/dist/nylas-scheduling.entry-115b1752.js +0 -1002
  112. package/dist/nylas-scheduling.entry-79cb1d9c.cjs +0 -1
  113. package/dist/person-icon.entry-2cae306c.cjs +0 -1
  114. package/dist/person-icon.entry-fd668b89.js +0 -18
  115. package/dist/play-icon.entry-7fc3c0fd.js +0 -18
  116. package/dist/play-icon.entry-9989a520.cjs +0 -1
  117. package/dist/radio-button-group.entry-03385b5f.cjs +0 -1
  118. package/dist/radio-button-group.entry-9df82cd0.js +0 -58
  119. package/dist/react.cjs +0 -1
  120. package/dist/react.js +0 -164
  121. package/dist/refresh-icon.entry-310954ba.cjs +0 -1
  122. package/dist/refresh-icon.entry-c56e5623.js +0 -18
  123. package/dist/register-component-3acd57e7-5a79a90a.cjs +0 -1
  124. package/dist/register-component-3acd57e7-cb09c05e.js +0 -110
  125. package/dist/reply-all-icon.entry-32e0e000.js +0 -18
  126. package/dist/reply-all-icon.entry-68388f97.cjs +0 -1
  127. package/dist/reply-icon.entry-3ac2e736.js +0 -18
  128. package/dist/reply-icon.entry-e616a9a4.cjs +0 -1
  129. package/dist/sent-icon.entry-0622ed04.js +0 -18
  130. package/dist/sent-icon.entry-543eb3c4.cjs +0 -1
  131. package/dist/spam-icon.entry-74bcfd4f.js +0 -18
  132. package/dist/spam-icon.entry-e341ee3e.cjs +0 -1
  133. package/dist/star-icon.entry-864d2bf9.js +0 -18
  134. package/dist/star-icon.entry-c90d40f6.cjs +0 -1
  135. package/dist/stop-icon.entry-835908c5.js +0 -18
  136. package/dist/stop-icon.entry-ffc46b42.cjs +0 -1
  137. package/dist/textarea-component.entry-6adcf6a6.js +0 -58
  138. package/dist/textarea-component.entry-dae8eb5c.cjs +0 -1
  139. package/dist/toggle-switch.entry-5ee29867.cjs +0 -1
  140. package/dist/toggle-switch.entry-ff2ccb75.js +0 -51
  141. package/dist/translate-icon.entry-372dd808.js +0 -18
  142. package/dist/translate-icon.entry-5606067d.cjs +0 -1
  143. package/dist/trash-fill-icon.entry-01b4379e.js +0 -18
  144. package/dist/trash-fill-icon.entry-daed6c0a.cjs +0 -1
  145. package/dist/underline-icon.entry-2020ee64.cjs +0 -1
  146. package/dist/underline-icon.entry-464b900d.js +0 -18
  147. package/dist/utils-31933f5d-15041585.js +0 -17878
  148. package/dist/utils-31933f5d-1d4c81ab.cjs +0 -54
@@ -1,289 +0,0 @@
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
- };
@@ -1 +0,0 @@
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;