@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
@@ -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
+ };