@nylas/react 2.0.6 → 2.2.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 (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/index.d.ts +6 -0
  14. package/dist/lib/connect/types.d.ts +2 -0
  15. package/dist/lib/connect/useNylasConnect.d.ts +28 -0
  16. package/dist/lib/connect/useNylasConnect.test.d.ts +1 -0
  17. package/dist/lib/connect.d.ts +1 -0
  18. package/dist/lib/elements/components.d.ts +975 -0
  19. package/dist/lib/elements.d.ts +1 -0
  20. package/dist/lib/index.d.ts +3 -5
  21. package/dist/lib/notetaker.d.ts +1 -0
  22. package/dist/lib/utils.d.ts +2 -0
  23. package/dist/notetaker.d.ts +1 -0
  24. package/dist/utils.d.ts +1 -0
  25. package/package.json +37 -16
  26. package/dist/abstract-provider-45ada3b4-31e3ed72.cjs +0 -1
  27. package/dist/abstract-provider-45ada3b4-abd3105d.js +0 -187
  28. package/dist/add-circle-icon_2.entry-48953f9c.cjs +0 -1
  29. package/dist/add-circle-icon_2.entry-f6f8b5e5.js +0 -26
  30. package/dist/archive-icon.entry-b3a76711.js +0 -16
  31. package/dist/archive-icon.entry-e2880dc7.cjs +0 -1
  32. package/dist/arrow-icon.entry-84d1e26c.cjs +0 -1
  33. package/dist/arrow-icon.entry-9b3441aa.js +0 -16
  34. package/dist/bold-icon.entry-0749a116.js +0 -16
  35. package/dist/bold-icon.entry-e1d8ab5e.cjs +0 -1
  36. package/dist/button-component_2.entry-1a817230.cjs +0 -1
  37. package/dist/button-component_2.entry-6eb55e97.js +0 -27
  38. package/dist/calendar-agenda-fill-icon_37.entry-0ca8b9f4.cjs +0 -6
  39. package/dist/calendar-agenda-fill-icon_37.entry-4adf73a2.js +0 -5231
  40. package/dist/calendar-cancel-icon.entry-2a29cb3f.js +0 -16
  41. package/dist/calendar-cancel-icon.entry-e0dee585.cjs +0 -1
  42. package/dist/calendar-check-icon.entry-7f96d456.cjs +0 -1
  43. package/dist/calendar-check-icon.entry-c12b63ea.js +0 -16
  44. package/dist/calendar-icon.entry-a2d19ff2.cjs +0 -1
  45. package/dist/calendar-icon.entry-e82a5169.js +0 -16
  46. package/dist/checkbox-component.entry-59612a67.js +0 -52
  47. package/dist/checkbox-component.entry-ddce70bc.cjs +0 -1
  48. package/dist/checkbox-group_4.entry-3311da64.cjs +0 -28
  49. package/dist/checkbox-group_4.entry-7df47ad4.js +0 -10011
  50. package/dist/checkmark-circle-icon.entry-677b0def.js +0 -16
  51. package/dist/checkmark-circle-icon.entry-67df713b.cjs +0 -1
  52. package/dist/checkmark-icon_15.entry-2121e1b7.cjs +0 -5
  53. package/dist/checkmark-icon_15.entry-9fd0ec58.js +0 -1412
  54. package/dist/chevron-icon_3.entry-1a42235c.cjs +0 -1
  55. package/dist/chevron-icon_3.entry-f0ad71d9.js +0 -157
  56. package/dist/clock-icon_4.entry-88822a84.cjs +0 -1
  57. package/dist/clock-icon_4.entry-e7472d5f.js +0 -46
  58. package/dist/constants-f51538ef-cd2a67c4.cjs +0 -1
  59. package/dist/constants-f51538ef-e0a5f026.js +0 -876
  60. package/dist/customParseFormat-eeec04f5-3ad26beb.js +0 -135
  61. package/dist/customParseFormat-eeec04f5-d5957784.cjs +0 -1
  62. package/dist/delete-icon.entry-3cb58910.cjs +0 -1
  63. package/dist/delete-icon.entry-813429d7.js +0 -16
  64. package/dist/document-refresh-icon.entry-ae361b0b.cjs +0 -1
  65. package/dist/document-refresh-icon.entry-c224c778.js +0 -16
  66. package/dist/feedbackSync-0ebd0eda-803c3ebe.js +0 -6048
  67. package/dist/feedbackSync-0ebd0eda-e12b00d5.cjs +0 -448
  68. package/dist/folder-icon.entry-107841af.cjs +0 -1
  69. package/dist/folder-icon.entry-9c1f7c41.js +0 -16
  70. package/dist/forward-icon.entry-4ac22c16.js +0 -16
  71. package/dist/forward-icon.entry-6cec1f94.cjs +0 -1
  72. package/dist/globe-icon.entry-7798c93b.js +0 -16
  73. package/dist/globe-icon.entry-909c1382.cjs +0 -1
  74. package/dist/google-logo-icon_6.entry-1f4ad364.cjs +0 -2
  75. package/dist/google-logo-icon_6.entry-b198c90a.js +0 -1762
  76. package/dist/google-meet-icon_5.entry-82d87e77.cjs +0 -1
  77. package/dist/google-meet-icon_5.entry-fa6dc1dc.js +0 -56
  78. package/dist/inbox-icon.entry-1b123e64.js +0 -16
  79. package/dist/inbox-icon.entry-84f96d31.cjs +0 -1
  80. package/dist/index-140eb219.js +0 -24953
  81. package/dist/index-d8a42c15.cjs +0 -118
  82. package/dist/index.es-57d4a08f-184cbc01.js +0 -2724
  83. package/dist/index.es-57d4a08f-b0a2ca19.cjs +0 -7
  84. package/dist/info-icon_2.entry-f09e7dae.cjs +0 -1
  85. package/dist/info-icon_2.entry-f8b72d08.js +0 -35
  86. package/dist/input-component.entry-44607977.js +0 -93
  87. package/dist/input-component.entry-fd38953d.cjs +0 -1
  88. package/dist/input-dropdown_2.entry-4c2e5e1a.cjs +0 -1
  89. package/dist/input-dropdown_2.entry-6898b420.js +0 -252
  90. package/dist/italic-icon.entry-16aa1ada.js +0 -16
  91. package/dist/italic-icon.entry-beef2254.cjs +0 -1
  92. package/dist/lib/elements/index.d.ts +0 -133
  93. package/dist/lib/elements/react-component-lib/createComponent.d.ts +0 -10
  94. package/dist/lib/elements/react-component-lib/createOverlayComponent.d.ts +0 -21
  95. package/dist/lib/elements/react-component-lib/index.d.ts +0 -2
  96. package/dist/lib/elements/react-component-lib/interfaces.d.ts +0 -29
  97. package/dist/lib/elements/react-component-lib/utils/attachProps.d.ts +0 -9
  98. package/dist/lib/elements/react-component-lib/utils/case.d.ts +0 -2
  99. package/dist/lib/elements/react-component-lib/utils/dev.d.ts +0 -2
  100. package/dist/lib/elements/react-component-lib/utils/index.d.ts +0 -10
  101. package/dist/multi-select-dropdown.entry-50133d29.js +0 -130
  102. package/dist/multi-select-dropdown.entry-c82cd6d4.cjs +0 -1
  103. package/dist/nylas-booked-event-card_11.entry-56768a09.js +0 -1407
  104. package/dist/nylas-booked-event-card_11.entry-eb4b3c5c.cjs +0 -1
  105. package/dist/nylas-date-component_2.entry-93f2f352.cjs +0 -1
  106. package/dist/nylas-date-component_2.entry-df957150.js +0 -307
  107. package/dist/nylas-form-card.entry-4d95a4ad.cjs +0 -1
  108. package/dist/nylas-form-card.entry-7724e61f.js +0 -72
  109. package/dist/nylas-notification_2.entry-448c2cb8.cjs +0 -1
  110. package/dist/nylas-notification_2.entry-af763b6c.js +0 -85
  111. package/dist/nylas-scheduler-editor.entry-0e4ba46d.js +0 -1796
  112. package/dist/nylas-scheduler-editor.entry-e36cdd9d.cjs +0 -2
  113. package/dist/nylas-scheduling.entry-1b207e91.js +0 -999
  114. package/dist/nylas-scheduling.entry-904dd10e.cjs +0 -1
  115. package/dist/person-icon.entry-70d46ca6.cjs +0 -1
  116. package/dist/person-icon.entry-f2979577.js +0 -16
  117. package/dist/play-icon.entry-c2cf0b12.cjs +0 -1
  118. package/dist/play-icon.entry-d387df5d.js +0 -16
  119. package/dist/radio-button-group.entry-45dbd2df.js +0 -56
  120. package/dist/radio-button-group.entry-94e06176.cjs +0 -1
  121. package/dist/react.cjs +0 -1
  122. package/dist/react.js +0 -149
  123. package/dist/refresh-icon.entry-5ab20f26.cjs +0 -1
  124. package/dist/refresh-icon.entry-777cff27.js +0 -16
  125. package/dist/register-component-0aad9e3d-b395364a.js +0 -109
  126. package/dist/register-component-0aad9e3d-d2f2e543.cjs +0 -1
  127. package/dist/reply-all-icon.entry-3c90510e.cjs +0 -1
  128. package/dist/reply-all-icon.entry-e2dd6da9.js +0 -16
  129. package/dist/reply-icon.entry-00a97d9f.js +0 -16
  130. package/dist/reply-icon.entry-d96478be.cjs +0 -1
  131. package/dist/sent-icon.entry-2d16da4e.cjs +0 -1
  132. package/dist/sent-icon.entry-949cf214.js +0 -16
  133. package/dist/spam-icon.entry-3baf9e79.js +0 -16
  134. package/dist/spam-icon.entry-7ee61730.cjs +0 -1
  135. package/dist/star-icon.entry-9fdb278b.js +0 -16
  136. package/dist/star-icon.entry-dc702d73.cjs +0 -1
  137. package/dist/stop-icon.entry-b5ae7e55.cjs +0 -1
  138. package/dist/stop-icon.entry-efa1ea66.js +0 -16
  139. package/dist/textarea-component.entry-247aca42.cjs +0 -1
  140. package/dist/textarea-component.entry-7c6fc4d8.js +0 -55
  141. package/dist/toggle-switch.entry-a0295d17.js +0 -49
  142. package/dist/toggle-switch.entry-d52b0338.cjs +0 -1
  143. package/dist/translate-icon.entry-219cab17.js +0 -16
  144. package/dist/translate-icon.entry-985b3b29.cjs +0 -1
  145. package/dist/trash-fill-icon.entry-03c90559.js +0 -16
  146. package/dist/trash-fill-icon.entry-4dfd7d24.cjs +0 -1
  147. package/dist/underline-icon.entry-58fa18b5.js +0 -16
  148. package/dist/underline-icon.entry-c60b77a6.cjs +0 -1
@@ -0,0 +1 @@
1
+ export * from './lib/connect'
@@ -0,0 +1 @@
1
+ export * from './lib/elements'
@@ -0,0 +1,279 @@
1
+ import { useRef as m, useEffect as f, useState as D, useCallback as i } from "react";
2
+ import { NylasConnect as O } from "@nylas/connect";
3
+ import { BrowserTokenStorage as z, ConfigError as G, MemoryTokenStorage as K, NetworkError as V, NylasConnect as B, NylasConnectError as W, OAuthError as X, PopupError as j, TokenError as q, isAuthCallback as F, logger as J, parseAuthCallback as Q } from "@nylas/connect";
4
+ function M(E) {
5
+ const {
6
+ autoRefreshInterval: d,
7
+ initialLoadingState: y = !0,
8
+ retryAttempts: u = 0,
9
+ enableAutoRecovery: b = !1,
10
+ ...P
11
+ } = E, h = m(null);
12
+ h.current || (h.current = new O(P));
13
+ const n = h.current, w = m({
14
+ isProcessing: !1,
15
+ processedUrl: null,
16
+ hasProcessed: !1
17
+ });
18
+ f(() => {
19
+ var r;
20
+ const s = ((r = globalThis.window) == null ? void 0 : r.location.href) || "", t = w.current;
21
+ !(s.includes("code=") && s.includes("state=")) && t.hasProcessed && (t.hasProcessed = !1, t.processedUrl = null);
22
+ }), f(() => n.isAutoCallbackEnabled() ? ((async () => {
23
+ var o, a, g;
24
+ const t = ((o = globalThis.window) == null ? void 0 : o.location.href) || "", e = w.current;
25
+ if (!(e.isProcessing || e.processedUrl === t || e.hasProcessed || !(t.includes("code=") && t.includes("state=")))) {
26
+ try {
27
+ if (await n.getSession()) {
28
+ e.hasProcessed = !0, e.processedUrl = t;
29
+ return;
30
+ }
31
+ } catch {
32
+ }
33
+ e.isProcessing = !0, e.processedUrl = t;
34
+ try {
35
+ if (await n.callback(), e.hasProcessed = !0, (g = (a = globalThis.window) == null ? void 0 : a.history) != null && g.replaceState) {
36
+ const c = new URL(globalThis.window.location.href), U = ["code", "state", "error", "error_description"];
37
+ let C = !1;
38
+ U.forEach((S) => {
39
+ c.searchParams.has(S) && (c.searchParams.delete(S), C = !0);
40
+ }), C && globalThis.window.history.replaceState(
41
+ globalThis.window.history.state,
42
+ document.title,
43
+ c.toString()
44
+ );
45
+ }
46
+ } catch (c) {
47
+ console.log("callback error", c), e.isProcessing = !1, e.processedUrl = null;
48
+ } finally {
49
+ e.isProcessing = !1;
50
+ }
51
+ }
52
+ })(), () => {
53
+ const t = w.current;
54
+ t.isProcessing || (t.processedUrl = null, t.hasProcessed = !1);
55
+ }) : void 0, [n]);
56
+ const [L, l] = D({
57
+ isConnected: !1,
58
+ grant: null,
59
+ isLoading: y,
60
+ error: null
61
+ });
62
+ f(() => {
63
+ let s = !0;
64
+ return (async () => {
65
+ try {
66
+ const e = await n.getSession(), r = await n.isConnected();
67
+ s && l((o) => ({
68
+ ...o,
69
+ isConnected: r,
70
+ grant: (e == null ? void 0 : e.grantInfo) || null,
71
+ isLoading: !1,
72
+ error: null
73
+ }));
74
+ } catch (e) {
75
+ s && l((r) => ({
76
+ ...r,
77
+ isConnected: !1,
78
+ grant: null,
79
+ isLoading: !1,
80
+ error: e
81
+ }));
82
+ }
83
+ })(), () => {
84
+ s = !1;
85
+ };
86
+ }, [n]), f(() => {
87
+ if (!d || d <= 0)
88
+ return;
89
+ const s = setInterval(async () => {
90
+ try {
91
+ const t = await n.getSession(), e = await n.isConnected();
92
+ l((r) => ({
93
+ ...r,
94
+ isConnected: e,
95
+ grant: (t == null ? void 0 : t.grantInfo) || null,
96
+ error: null
97
+ }));
98
+ } catch (t) {
99
+ b ? console.debug(
100
+ "Auto-refresh failed, will retry next interval:",
101
+ t
102
+ ) : l((e) => ({
103
+ ...e,
104
+ error: t
105
+ }));
106
+ }
107
+ }, d);
108
+ return () => clearInterval(s);
109
+ }, [n, d, b]), f(() => {
110
+ const s = (e, r, o) => {
111
+ l((a) => {
112
+ switch (e) {
113
+ case "AUTH_STARTED":
114
+ return {
115
+ ...a,
116
+ isLoading: !0,
117
+ error: null
118
+ };
119
+ case "SIGNED_IN":
120
+ case "SESSION_RESTORED":
121
+ return {
122
+ ...a,
123
+ isConnected: !0,
124
+ grant: (r == null ? void 0 : r.grantInfo) || null,
125
+ isLoading: !1,
126
+ error: null
127
+ };
128
+ case "SIGNED_OUT":
129
+ return {
130
+ ...a,
131
+ isConnected: !1,
132
+ grant: null,
133
+ isLoading: !1,
134
+ error: null
135
+ };
136
+ case "AUTH_ERROR":
137
+ case "NETWORK_ERROR":
138
+ case "TOKEN_VALIDATION_ERROR":
139
+ return {
140
+ ...a,
141
+ isLoading: !1,
142
+ error: (o == null ? void 0 : o.error) || new Error("Authentication error")
143
+ };
144
+ case "AUTH_CANCELLED":
145
+ return {
146
+ ...a,
147
+ isLoading: !1,
148
+ error: null
149
+ };
150
+ case "SESSION_EXPIRED":
151
+ case "SESSION_INVALID":
152
+ return {
153
+ ...a,
154
+ isConnected: !1,
155
+ grant: null,
156
+ isLoading: !1,
157
+ error: null
158
+ };
159
+ default:
160
+ return a;
161
+ }
162
+ });
163
+ };
164
+ return n.onAuthStateChange(
165
+ s
166
+ );
167
+ }, [n]);
168
+ const A = i(
169
+ async (s = {}) => {
170
+ l((r) => ({ ...r, isLoading: !0, error: null }));
171
+ let t;
172
+ const e = u + 1;
173
+ for (let r = 1; r <= e; r++)
174
+ try {
175
+ return await n.connect(s);
176
+ } catch (o) {
177
+ if (t = o, r < e) {
178
+ const a = Math.min(1e3 * Math.pow(2, r - 1), 5e3);
179
+ await new Promise((g) => setTimeout(g, a));
180
+ }
181
+ }
182
+ throw t;
183
+ },
184
+ [n, u]
185
+ ), p = i(
186
+ async (s) => {
187
+ l((r) => ({ ...r, isLoading: !0, error: null }));
188
+ let t;
189
+ const e = u + 1;
190
+ for (let r = 1; r <= e; r++)
191
+ try {
192
+ await n.logout(s);
193
+ return;
194
+ } catch (o) {
195
+ if (t = o, r < e) {
196
+ const a = Math.min(1e3 * Math.pow(2, r - 1), 3e3);
197
+ await new Promise((g) => setTimeout(g, a));
198
+ }
199
+ }
200
+ throw l((r) => ({
201
+ ...r,
202
+ isLoading: !1,
203
+ error: t
204
+ })), t;
205
+ },
206
+ [n, u]
207
+ ), T = i(async () => {
208
+ l((e) => ({ ...e, isLoading: !0, error: null }));
209
+ let s;
210
+ const t = u + 1;
211
+ for (let e = 1; e <= t; e++)
212
+ try {
213
+ const r = await n.getSession(), o = await n.isConnected();
214
+ l((a) => ({
215
+ ...a,
216
+ isConnected: o,
217
+ grant: (r == null ? void 0 : r.grantInfo) || null,
218
+ isLoading: !1,
219
+ error: null
220
+ }));
221
+ return;
222
+ } catch (r) {
223
+ if (s = r, e < t) {
224
+ const o = Math.min(1e3 * Math.pow(2, e - 1), 3e3);
225
+ await new Promise((a) => setTimeout(a, o));
226
+ }
227
+ }
228
+ throw l((e) => ({
229
+ ...e,
230
+ isConnected: !1,
231
+ grant: null,
232
+ isLoading: !1,
233
+ error: s
234
+ })), s;
235
+ }, [n, u]), k = i(
236
+ (s) => n.onAuthStateChange(s),
237
+ [n]
238
+ ), R = i(() => {
239
+ n.enableDebug();
240
+ }, [n]), I = i(() => {
241
+ n.disableDebug();
242
+ }, [n]), N = i(
243
+ (s) => {
244
+ n.setLogLevel(s);
245
+ },
246
+ [n]
247
+ );
248
+ return {
249
+ // State
250
+ ...L,
251
+ // Actions
252
+ connect: A,
253
+ logout: p,
254
+ refreshSession: T,
255
+ subscribe: k,
256
+ // Logger controls
257
+ enableDebug: R,
258
+ disableDebug: I,
259
+ setLogLevel: N,
260
+ // Direct access
261
+ authClient: n,
262
+ logger: n.logger
263
+ };
264
+ }
265
+ export {
266
+ z as BrowserTokenStorage,
267
+ G as ConfigError,
268
+ K as MemoryTokenStorage,
269
+ V as NetworkError,
270
+ B as NylasConnect,
271
+ W as NylasConnectError,
272
+ X as OAuthError,
273
+ j as PopupError,
274
+ q as TokenError,
275
+ F as isAuthCallback,
276
+ J as logger,
277
+ Q as parseAuthCallback,
278
+ M as useNylasConnect
279
+ };