@nylas/react 1.1.0-canary.14 → 1.1.0-canary.15

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 (130) hide show
  1. package/dist/add-circle-icon_2.entry-00dc2c13.cjs +1 -0
  2. package/dist/add-circle-icon_2.entry-3f834b47.js +26 -0
  3. package/dist/{archive-icon_7.entry-60311199.cjs → archive-icon_7.entry-25d8b2f0.cjs} +1 -1
  4. package/dist/{archive-icon_7.entry-0dfc9782.js → archive-icon_7.entry-ca8262ff.js} +15 -15
  5. package/dist/{arrow-icon.entry-eb53c4cb.cjs → arrow-icon.entry-01192ecf.cjs} +1 -1
  6. package/dist/{arrow-icon.entry-f38f3014.js → arrow-icon.entry-991ba7cd.js} +2 -2
  7. package/dist/{bold-icon_3.entry-20e74265.js → bold-icon_3.entry-81a3ff1e.js} +10 -10
  8. package/dist/{bold-icon_3.entry-d5100ffa.cjs → bold-icon_3.entry-e94dcf5b.cjs} +1 -1
  9. package/dist/{calendar-cancel-icon.entry-e5d1bc0a.cjs → calendar-cancel-icon.entry-9088fa8b.cjs} +1 -1
  10. package/dist/{calendar-cancel-icon.entry-0bdee178.js → calendar-cancel-icon.entry-f646c147.js} +5 -5
  11. package/dist/{calendar-check-icon_2.entry-10af2017.cjs → calendar-check-icon_2.entry-4dc1391a.cjs} +1 -1
  12. package/dist/{calendar-check-icon_2.entry-f18a2ddb.js → calendar-check-icon_2.entry-a7e4d0e6.js} +7 -7
  13. package/dist/{calendar-icon.entry-12ca0ae4.js → calendar-icon.entry-1658930c.js} +2 -2
  14. package/dist/{calendar-icon.entry-bc6f0808.cjs → calendar-icon.entry-1e2acd5c.cjs} +1 -1
  15. package/dist/{add-circle-icon_22.entry-ab0d5ede.js → calendar-info-icon_25.entry-493c5547.js} +966 -704
  16. package/dist/calendar-info-icon_25.entry-7513d798.cjs +1 -0
  17. package/dist/chevron-icon_3.entry-52b97043.cjs +1 -0
  18. package/dist/chevron-icon_3.entry-b3c7eb44.js +126 -0
  19. package/dist/{clock-icon_2.entry-ffc9e057.js → clock-icon_2.entry-58f07042.js} +3 -3
  20. package/dist/{clock-icon_2.entry-7cddf901.cjs → clock-icon_2.entry-882249ee.cjs} +1 -1
  21. package/dist/close-icon.entry-4a39816a.js +15 -0
  22. package/dist/close-icon.entry-f1166251.cjs +1 -0
  23. package/dist/{constants-f34b9c6e-108993e8.cjs → constants-f34b9c6e-1da5094b.cjs} +1 -1
  24. package/dist/{constants-f34b9c6e-37cabe82.js → constants-f34b9c6e-628beaa8.js} +1 -1
  25. package/dist/{document-refresh-icon.entry-d1f6259a.cjs → document-refresh-icon.entry-4f581bf4.cjs} +1 -1
  26. package/dist/{document-refresh-icon.entry-e4636c8e.js → document-refresh-icon.entry-b53316b4.js} +2 -2
  27. package/dist/elements/index.d.ts +9 -0
  28. package/dist/{elements-dc5b338e-a37a0510.cjs → elements-dc5b338e-3284591d.cjs} +1 -1
  29. package/dist/{elements-dc5b338e-c6f2806c.js → elements-dc5b338e-7abe37c6.js} +1 -1
  30. package/dist/{focus-visible-e8093c16-b62197ad.cjs → focus-visible-e8093c16-cb6c97b1.cjs} +1 -1
  31. package/dist/{focus-visible-e8093c16-b0821d89.js → focus-visible-e8093c16-d6612604.js} +1 -1
  32. package/dist/{forward-icon_6.entry-2a694e7c.js → forward-icon_6.entry-d54244f7.js} +9 -9
  33. package/dist/{forward-icon_6.entry-b81b22f6.cjs → forward-icon_6.entry-e402ad1e.cjs} +2 -2
  34. package/dist/{globe-icon.entry-c037589b.cjs → globe-icon.entry-db7377d9.cjs} +1 -1
  35. package/dist/{globe-icon.entry-e794eb52.js → globe-icon.entry-e83c79c2.js} +4 -4
  36. package/dist/google-logo-icon_4.entry-8818686b.js +429 -0
  37. package/dist/google-logo-icon_4.entry-fa65ae29.cjs +1 -0
  38. package/dist/{index-d61429c6.js → index-2d032bec.js} +1288 -1265
  39. package/dist/index-53420959-41ed02ae.js +5 -0
  40. package/dist/index-53420959-a76f0327.cjs +1 -0
  41. package/dist/{index-ef01c714-1e2feefc.js → index-6d9eeb53-91d36348.js} +2 -2
  42. package/dist/{index-ef01c714-54e17405.cjs → index-6d9eeb53-f478270c.cjs} +1 -1
  43. package/dist/index-9c04361d.cjs +42 -0
  44. package/dist/{index.es-74f70f7d-a22eba35.cjs → index.es-9cc0eb3c-2242baf6.cjs} +1 -1
  45. package/dist/{index.es-74f70f7d-da0e7fcf.js → index.es-9cc0eb3c-ee2ebbe1.js} +1 -1
  46. package/dist/{info-icon_2.entry-23e3fa8a.cjs → info-icon_2.entry-4b257e73.cjs} +1 -1
  47. package/dist/{info-icon_2.entry-647915bb.js → info-icon_2.entry-74eb7415.js} +5 -5
  48. package/dist/input-component.entry-3ef7ce2c.cjs +1 -0
  49. package/dist/input-component.entry-6bb4a5e8.js +45 -0
  50. package/dist/input-dropdown_2.entry-a87714fc.cjs +1 -0
  51. package/dist/input-dropdown_2.entry-f71e4c01.js +209 -0
  52. package/dist/{loading-icon.entry-1ddd0244.js → loading-icon.entry-30724cb0.js} +2 -2
  53. package/dist/{loading-icon.entry-98d65a5d.cjs → loading-icon.entry-bb250f1c.cjs} +1 -1
  54. package/dist/{mailbox-store-050a2914-6fef25fb.js → mailbox-store-64b4ef7c-202f1afd.js} +2 -2
  55. package/dist/{mailbox-store-050a2914-bd0a86bb.cjs → mailbox-store-64b4ef7c-74f959be.cjs} +1 -1
  56. package/dist/{nylas-additional-participants.entry-3c598863.cjs → nylas-additional-participants.entry-567c7c2a.cjs} +1 -1
  57. package/dist/{nylas-additional-participants.entry-0f93e24e.js → nylas-additional-participants.entry-7961be04.js} +5 -5
  58. package/dist/nylas-booked-event-card_10.entry-c2f889ba.cjs +1 -0
  59. package/dist/{nylas-booked-event-card_10.entry-9f7869af.js → nylas-booked-event-card_10.entry-ddfcff5e.js} +371 -299
  60. package/dist/{nylas-custom-booking-flow.entry-877cac85.cjs → nylas-custom-booking-flow.entry-63ed387e.cjs} +1 -1
  61. package/dist/{nylas-custom-booking-flow.entry-69638c50.js → nylas-custom-booking-flow.entry-a1f66d05.js} +10 -10
  62. package/dist/{nylas-form-card.entry-4349d07d.cjs → nylas-form-card.entry-6fece0ff.cjs} +1 -1
  63. package/dist/{nylas-form-card.entry-b2da5266.js → nylas-form-card.entry-ea1153b9.js} +11 -11
  64. package/dist/{nylas-if-state.entry-62474acb.js → nylas-if-state.entry-05f8f66f.js} +3 -3
  65. package/dist/{nylas-if-state.entry-9eade180.cjs → nylas-if-state.entry-b75320f0.cjs} +1 -1
  66. package/dist/{nylas-list-folders.entry-348a784b.js → nylas-list-folders.entry-bd5a1b1d.js} +7 -7
  67. package/dist/{nylas-list-folders.entry-b32ec92a.cjs → nylas-list-folders.entry-edc61b97.cjs} +1 -1
  68. package/dist/{nylas-list-threads.entry-7e8044b2.cjs → nylas-list-threads.entry-79ad0944.cjs} +1 -1
  69. package/dist/{nylas-list-threads.entry-ec1c5fb6.js → nylas-list-threads.entry-f3cd80de.js} +3 -3
  70. package/dist/{nylas-login.entry-0495d0b5.cjs → nylas-login.entry-68873357.cjs} +1 -1
  71. package/dist/{nylas-login.entry-f6f1e306.js → nylas-login.entry-b3207e82.js} +7 -7
  72. package/dist/{nylas-mailbox-pagination.entry-24c82c53.js → nylas-mailbox-pagination.entry-22c5b9ca.js} +2 -2
  73. package/dist/{nylas-mailbox-pagination.entry-22385ead.cjs → nylas-mailbox-pagination.entry-2ef5b88a.cjs} +1 -1
  74. package/dist/{nylas-mailbox-toolbar-button.entry-b13b2a58.js → nylas-mailbox-toolbar-button.entry-95bb58b5.js} +9 -9
  75. package/dist/{nylas-mailbox-toolbar-button.entry-e8e52474.cjs → nylas-mailbox-toolbar-button.entry-f2fa3a8e.cjs} +1 -1
  76. package/dist/{nylas-mailbox.entry-77f4c37e.cjs → nylas-mailbox.entry-4b1d320f.cjs} +1 -1
  77. package/dist/{nylas-mailbox.entry-0365fbb0.js → nylas-mailbox.entry-4ef7d18d.js} +6 -6
  78. package/dist/{nylas-provider.entry-11239372.js → nylas-provider.entry-7f7e098a.js} +6 -6
  79. package/dist/{nylas-provider.entry-d454a4d1.cjs → nylas-provider.entry-b629340a.cjs} +1 -1
  80. package/dist/{nylas-scheduler-editor.entry-16473950.cjs → nylas-scheduler-editor.entry-19a29c4c.cjs} +2 -2
  81. package/dist/{nylas-scheduler-editor.entry-c4d38853.js → nylas-scheduler-editor.entry-2d19593f.js} +13 -7
  82. package/dist/nylas-scheduling.entry-70454242.cjs +1 -0
  83. package/dist/{nylas-scheduling.entry-cc2535a9.js → nylas-scheduling.entry-753cb746.js} +61 -61
  84. package/dist/{nylas-threads-refresh.entry-725ef87d.cjs → nylas-threads-refresh.entry-0a832631.cjs} +1 -1
  85. package/dist/{nylas-threads-refresh.entry-5a6378fe.js → nylas-threads-refresh.entry-5a774ad7.js} +4 -4
  86. package/dist/{nylas-threads-search.entry-5e7b6a03.js → nylas-threads-search.entry-451c6d5c.js} +9 -9
  87. package/dist/nylas-threads-search.entry-5b57688b.cjs +1 -0
  88. package/dist/{nylas-view-thread.entry-98f8e35b.cjs → nylas-view-thread.entry-7b273955.cjs} +1 -1
  89. package/dist/{nylas-view-thread.entry-249f0b65.js → nylas-view-thread.entry-e0af8998.js} +3 -3
  90. package/dist/{people-icon.entry-0ab4b752.cjs → people-icon.entry-c7fb7f6c.cjs} +1 -1
  91. package/dist/{people-icon.entry-0ed95db0.js → people-icon.entry-de3fada0.js} +6 -6
  92. package/dist/{play-icon_2.entry-433a8722.js → play-icon_2.entry-58592b64.js} +5 -5
  93. package/dist/play-icon_2.entry-5b22a7ca.cjs +1 -0
  94. package/dist/react.cjs +1 -1
  95. package/dist/react.js +98 -89
  96. package/dist/{refresh-icon.entry-508a246d.cjs → refresh-icon.entry-876b8aea.cjs} +1 -1
  97. package/dist/{refresh-icon.entry-b5bee0f4.js → refresh-icon.entry-90756bc6.js} +4 -4
  98. package/dist/{register-component-e4dc8778-7812a275.cjs → register-component-a5a9ca5d-1fbb27d2.cjs} +1 -1
  99. package/dist/{register-component-e4dc8778-53fe0729.js → register-component-a5a9ca5d-8bede801.js} +1 -1
  100. package/dist/{scheduler-config-store-ec3b6190-435c84ca.cjs → scheduler-config-store-ec3b6190-104df545.cjs} +1 -1
  101. package/dist/{scheduler-config-store-ec3b6190-01892765.js → scheduler-config-store-ec3b6190-cbc40d60.js} +1 -1
  102. package/dist/scheduler-store-f02ce045-1d93c571.js +390 -0
  103. package/dist/scheduler-store-f02ce045-712c600c.cjs +1 -0
  104. package/dist/textarea-component.entry-3ea161d6.js +35 -0
  105. package/dist/textarea-component.entry-9d6b5cdc.cjs +1 -0
  106. package/dist/toggle-switch.entry-10aa0c1a.cjs +1 -0
  107. package/dist/toggle-switch.entry-a08c1027.js +25 -0
  108. package/dist/{translate-icon.entry-f77cfd3d.cjs → translate-icon.entry-04dde6b1.cjs} +1 -1
  109. package/dist/{translate-icon.entry-c34bad94.js → translate-icon.entry-be9c3401.js} +6 -6
  110. package/dist/{warning-icon.entry-f781a623.js → warning-icon.entry-347d77af.js} +5 -5
  111. package/dist/{warning-icon.entry-f73b31bf.cjs → warning-icon.entry-84121a43.cjs} +1 -1
  112. package/package.json +3 -3
  113. package/dist/add-circle-icon_22.entry-c165f0de.cjs +0 -1
  114. package/dist/chevron-icon_3.entry-55eb864f.js +0 -117
  115. package/dist/chevron-icon_3.entry-a18c373d.cjs +0 -1
  116. package/dist/close-icon.entry-7c67181c.js +0 -15
  117. package/dist/close-icon.entry-918dd254.cjs +0 -1
  118. package/dist/google-logo-icon_4.entry-748af8c3.cjs +0 -1
  119. package/dist/google-logo-icon_4.entry-b4464873.js +0 -393
  120. package/dist/index-53420959-31867ccf.js +0 -5
  121. package/dist/index-53420959-535906ce.cjs +0 -1
  122. package/dist/index-6a4ee4f8.cjs +0 -42
  123. package/dist/nylas-booked-event-card_10.entry-912e4a89.cjs +0 -1
  124. package/dist/nylas-scheduling.entry-5b156a28.cjs +0 -1
  125. package/dist/nylas-threads-search.entry-a2553cbe.cjs +0 -1
  126. package/dist/play-icon_2.entry-f9c0b647.cjs +0 -1
  127. package/dist/scheduler-store-04e15f8a-5d06eaf3.cjs +0 -1
  128. package/dist/scheduler-store-04e15f8a-69eb8d7a.js +0 -376
  129. package/dist/time-period-selector.entry-77a6debf.cjs +0 -1
  130. package/dist/time-period-selector.entry-a29c8ffa.js +0 -76
@@ -1,376 +0,0 @@
1
- import { d as v, e as L } from "./index-d61429c6.js";
2
- var y;
3
- (function(o) {
4
- o.Component = "component", o.Api = "api", o.Auth = "auth";
5
- })(y || (y = {}));
6
- var P;
7
- (function(o) {
8
- o.endtime_not_in_future = "endtime_not_in_future", o.no_booking_info = "no_booking_info", o.no_timeslot_selected = "no_timeslot_selected", o.no_timezone_selected = "no_timezone_selected", o.no_booking_id = "no_booking_id", o.invalid_start_time = "invalid_start_time", o.invalid_end_time = "invalid_end_time", o.invalid_timezone = "invalid_timezone";
9
- })(P || (P = {}));
10
- var T;
11
- (function(o) {
12
- o.invalid_session = "invalid_session", o.general_error = "general_error", o.internal_error = "internal_error", o.invalid_request_error = "invalid_request_error", o.timeslot_not_available = "timeslot_not_available", o.provider_error = "provider_error", o.not_found_error = "not_found_error";
13
- })(T || (T = {}));
14
- class R {
15
- constructor() {
16
- this.component = (e) => {
17
- const i = y.Component, s = `${e} Error`;
18
- return {
19
- endtime_not_in_future: (t = '"endtime" can not be in the future') => ({
20
- title: s,
21
- message: t,
22
- category: i
23
- }),
24
- no_booking_info: (t = "No booking info provided") => ({
25
- title: s,
26
- message: t,
27
- category: i
28
- }),
29
- no_timeslot_selected: (t = "No timeslot selected") => ({
30
- title: s,
31
- message: t,
32
- category: i
33
- }),
34
- no_timezone_selected: (t = "No timezone selected") => ({
35
- title: s,
36
- message: t,
37
- category: i
38
- }),
39
- no_booking_id: (t = "No booking id provided") => ({
40
- title: s,
41
- message: t,
42
- category: i
43
- }),
44
- invalid_start_time: (t = "Invalid start time") => ({
45
- title: s,
46
- message: t,
47
- category: i
48
- }),
49
- invalid_end_time: (t = "Invalid end time") => ({
50
- title: s,
51
- message: t,
52
- category: i
53
- }),
54
- invalid_timezone: (t = "Invalid timezone") => ({
55
- title: s,
56
- message: t,
57
- category: i
58
- })
59
- };
60
- }, this.api = (e) => {
61
- const i = y.Api, s = `${e} Error`;
62
- return {
63
- invalid_session: (t) => ({
64
- title: s,
65
- message: t,
66
- category: i
67
- }),
68
- general_error: (t) => ({
69
- title: s,
70
- message: t,
71
- category: i
72
- }),
73
- internal_error: (t) => ({
74
- title: s,
75
- message: t,
76
- category: i
77
- }),
78
- invalid_request_error: (t) => ({
79
- title: s,
80
- message: t,
81
- category: i
82
- }),
83
- timeslot_not_available: (t) => ({
84
- title: s,
85
- message: t,
86
- category: i
87
- }),
88
- provider_error: (t) => ({
89
- title: s,
90
- message: t,
91
- category: i
92
- }),
93
- not_found_error: (t) => ({
94
- title: s,
95
- message: t,
96
- category: i
97
- })
98
- };
99
- };
100
- }
101
- }
102
- class M {
103
- constructor({ schedulerAPIURL: e, schedulerStore: i, sessionId: s, configId: t }) {
104
- this.errors = new R(), this.schedulerStore = i, this.schedulerAPIURL = e, this.sessionId = s, this.configId = t;
105
- }
106
- getHeaders() {
107
- return this.configId ? {} : {
108
- Authorization: `Bearer ${this.sessionId}`
109
- };
110
- }
111
- async makeAPIRequest(e, i, s, t = {}) {
112
- try {
113
- const r = new URL(this.schedulerAPIURL);
114
- return r.pathname = e, await (await fetch(decodeURIComponent(r.toString()), {
115
- method: i,
116
- headers: {
117
- "Content-Type": "application/json",
118
- Origin: window.location.origin,
119
- ...t
120
- },
121
- body: s
122
- })).json();
123
- } catch (r) {
124
- return {
125
- error: {
126
- message: r.message,
127
- title: "API request failed",
128
- type: "api"
129
- }
130
- };
131
- }
132
- }
133
- getErrorMessage(e) {
134
- var s, t, r, n;
135
- let i = (e == null ? void 0 : e.message) || (e == null ? void 0 : e.title) || "Something went wrong";
136
- return (e == null ? void 0 : e.type) === "provider_error" && (i = ((t = (s = e == null ? void 0 : e.provider_error) == null ? void 0 : s.error) == null ? void 0 : t.message) || ((n = (r = e == null ? void 0 : e.provider_error) == null ? void 0 : r.error) == null ? void 0 : n.title) || "Something went wrong"), i;
137
- }
138
- setConfigId(e) {
139
- this.configId = e;
140
- }
141
- selectDate(e) {
142
- this.schedulerStore.set("selectedDate", e), this.schedulerStore.set("selectedTimeslot", null);
143
- }
144
- selectTime(e) {
145
- this.schedulerStore.set("selectedTimeslot", e);
146
- }
147
- selectTimezone(e) {
148
- this.schedulerStore.set("selectedTimezone", e);
149
- }
150
- async toggleAdditionalData(e) {
151
- e || await this.refetchAvailability(), this.schedulerStore.set("showBookingForm", e);
152
- }
153
- setParticipantName(e) {
154
- const { bookingInfo: i } = this.schedulerStore.state;
155
- this.schedulerStore.set("bookingInfo", {
156
- ...i,
157
- primaryParticipant: {
158
- ...i == null ? void 0 : i.primaryParticipant,
159
- name: e
160
- }
161
- });
162
- }
163
- setParticipantEmail(e) {
164
- const { bookingInfo: i } = this.schedulerStore.state;
165
- this.schedulerStore.set("bookingInfo", {
166
- ...i,
167
- primaryParticipant: {
168
- ...i == null ? void 0 : i.primaryParticipant,
169
- email: e
170
- }
171
- });
172
- }
173
- async refetchAvailability() {
174
- const e = /* @__PURE__ */ new Date(), i = new Date(e.getFullYear(), e.getMonth(), 1).getTime() / 1e3, s = new Date(e.getFullYear(), e.getMonth() + 1, 1).getTime() / 1e3;
175
- return await this.getAvailability(i, s);
176
- }
177
- async resetStoreStateAndFetchAvailability() {
178
- const e = /* @__PURE__ */ new Date(), i = await this.refetchAvailability(), s = this.schedulerStore.get("availability").find((r) => new Date(r.start_time) > /* @__PURE__ */ new Date());
179
- let t = e;
180
- return s && (t = s.start_time), this.schedulerStore.set("selectedDate", t), this.schedulerStore.set("eventInfo", null), this.schedulerStore.set("showBookingForm", !1), this.schedulerStore.set("selectedTimeslot", null), i;
181
- }
182
- async setReschedule(e) {
183
- const i = this.schedulerStore.state.eventInfo;
184
- i && this.schedulerStore.set("reschedulingEventInfo", i);
185
- const s = await this.resetStoreStateAndFetchAvailability();
186
- return this.schedulerStore.set("rescheduleBookingId", e), s;
187
- }
188
- async setCancel(e) {
189
- this.schedulerStore.set("cancelBookingId", e);
190
- }
191
- async resetCancel() {
192
- const e = await this.resetStoreStateAndFetchAvailability();
193
- return this.schedulerStore.set("cancelBookingId", ""), this.schedulerStore.set("cancelledEventInfo", null), e;
194
- }
195
- async bookTimeslot(e) {
196
- var u;
197
- this.schedulerStore.set("isLoading", !0);
198
- const { selectedTimeslot: i, selectedTimezone: s, bookingInfo: t } = this.schedulerStore.state;
199
- if (!e && !t)
200
- return { error: this.errors.component("Booking").no_booking_info() };
201
- const r = (e == null ? void 0 : e.timeslot) || i;
202
- if (!r)
203
- return { error: this.errors.component("Create Booking").no_timeslot_selected() };
204
- const n = e && (e != null && e.timezone) ? e == null ? void 0 : e.timezone : s;
205
- if (!n)
206
- return { error: this.errors.component("Create Booking").no_timezone_selected() };
207
- const l = e ? e == null ? void 0 : e.primaryParticipant : t == null ? void 0 : t.primaryParticipant, h = e ? (e == null ? void 0 : e.guests) || [] : (t == null ? void 0 : t.guests) || [], c = e ? { ...e == null ? void 0 : e.additionalFields, guests: h } : { ...t == null ? void 0 : t.additionalFields, guests: h }, g = this.getHeaders(), _ = `/v3/scheduling/bookings${this.configId ? `?configuration_id=${this.configId}` : ""}`, a = await this.makeAPIRequest(decodeURIComponent(_), "POST", JSON.stringify({
208
- additional_fields: c,
209
- guest: { ...l },
210
- start_time: r.start_time.getTime() / 1e3,
211
- end_time: r.end_time.getTime() / 1e3,
212
- timezone: n
213
- }), g);
214
- if ("error" in a) {
215
- this.schedulerStore.set("isLoading", !1);
216
- const d = (u = a.error) == null ? void 0 : u.type;
217
- let S = a.error;
218
- if (d && d in this.errors.api("Create Booking")) {
219
- const I = this.getErrorMessage(S);
220
- S = this.errors.api("Create Booking")[d](I);
221
- }
222
- return { error: S };
223
- }
224
- return "data" in a && this.schedulerStore.set("eventInfo", a == null ? void 0 : a.data), this.schedulerStore.set("isLoading", !1), a;
225
- }
226
- async getUISettings() {
227
- var r;
228
- this.schedulerStore.set("isLoading", !0);
229
- const e = this.getHeaders(), s = `/v3/scheduling/ui-settings${this.configId ? `?configuration_id=${this.configId}` : ""}`, t = await this.makeAPIRequest(s, "GET", void 0, e);
230
- if ("error" in t) {
231
- this.schedulerStore.set("isLoading", !1);
232
- const n = (r = t.error) == null ? void 0 : r.type;
233
- let l = t.error;
234
- return n && n in this.errors.api("Get UI Settings") && (l = this.errors.api("Get UI Settings")[n]((l == null ? void 0 : l.message) || (l == null ? void 0 : l.title) || "Something went wrong")), { error: l };
235
- }
236
- return "data" in t && this.schedulerStore.set("configSettings", t.data), this.schedulerStore.set("isLoading", !1), t;
237
- }
238
- async getAvailability(e = 0, i = 0) {
239
- var g, f, _;
240
- this.schedulerStore.set("isLoading", !0);
241
- const s = new URLSearchParams(), t = /* @__PURE__ */ new Date(), r = t.getTime();
242
- if (i && i < r / 1e3)
243
- return this.schedulerStore.set("isLoading", !1), { error: this.errors.component("Get Availability").endtime_not_in_future() };
244
- if (!e) {
245
- const a = new Date(t.getFullYear(), t.getMonth(), 1);
246
- e = Math.floor(a.getTime() / 1e3);
247
- }
248
- if (!i) {
249
- const a = new Date(t.getFullYear(), t.getMonth() + 1, 0);
250
- i = Math.floor(a.getTime() / 1e3);
251
- }
252
- s.append("start_time", encodeURIComponent(e.toString())), s.append("end_time", encodeURIComponent(i.toString())), this.configId && s.append("configuration_id", encodeURIComponent(this.configId));
253
- const n = s.toString(), l = `/v3/scheduling/availability${n ? `?${n}` : ""}`, h = this.getHeaders(), c = await this.makeAPIRequest(decodeURIComponent(l), "GET", void 0, h);
254
- if ("error" in c) {
255
- this.schedulerStore.set("availability", []), this.schedulerStore.set("isLoading", !1);
256
- const a = (g = c.error) == null ? void 0 : g.type;
257
- let u = c.error;
258
- if (a && a in this.errors.api("Get Availability")) {
259
- const d = this.getErrorMessage(u);
260
- u = this.errors.api("Get Availability")[a](d);
261
- }
262
- return { error: u };
263
- }
264
- if ("data" in c) {
265
- const u = (((_ = (f = c.data) == null ? void 0 : f.time_slots) == null ? void 0 : _.map((d) => ({
266
- ...d,
267
- start_time: new Date(d.start_time * 1e3),
268
- end_time: new Date(d.end_time * 1e3)
269
- }))) || []).filter((d) => d.start_time.getTime() > r);
270
- this.schedulerStore.set("availability", u);
271
- }
272
- return this.schedulerStore.set("isLoading", !1), c;
273
- }
274
- async cancelBooking(e, i) {
275
- var l;
276
- if (this.schedulerStore.set("isLoading", !0), !e)
277
- return { error: this.errors.component("Cancel Booking").no_booking_id() };
278
- const s = this.configId ? `?configuration_id=${this.configId}` : "", t = `/v3/scheduling/bookings/${e}${s}`, r = this.getHeaders(), n = await this.makeAPIRequest(decodeURIComponent(t), "DELETE", JSON.stringify({
279
- action: "cancel",
280
- cancellation_reason: i
281
- }), r);
282
- if ("error" in n) {
283
- this.schedulerStore.set("isLoading", !1);
284
- const h = (l = n.error) == null ? void 0 : l.type;
285
- let c = n.error;
286
- if (h && h in this.errors.api("Cancel Booking")) {
287
- const g = this.getErrorMessage(c);
288
- c = this.errors.api("Cancel Booking")[h](g);
289
- }
290
- return { error: c };
291
- }
292
- return this.schedulerStore.set("cancelledEventInfo", {
293
- booking_id: e
294
- }), this.schedulerStore.set("isLoading", !1), n;
295
- }
296
- async rescheduleBooking(e, i) {
297
- var k;
298
- if (this.schedulerStore.set("isLoading", !0), !e)
299
- return { error: this.errors.component("Reschedule Booking").no_booking_id() };
300
- const s = this.errors.api("Reschedule Booking"), t = this.errors.component("Reschedule Booking"), { bookingInfo: r, selectedTimeslot: n, selectedTimezone: l } = this.schedulerStore.state, { startTime: h, endTime: c, timezone: g } = i, f = h || (n == null ? void 0 : n.start_time);
301
- if (!f)
302
- return { error: t.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
303
- const _ = c || (n == null ? void 0 : n.end_time);
304
- if (!_)
305
- return { error: t.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
306
- const a = g || l;
307
- if (!a)
308
- return { error: t.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.') };
309
- const u = i ? i == null ? void 0 : i.primaryParticipant : r == null ? void 0 : r.primaryParticipant, d = i ? (i == null ? void 0 : i.guests) || [] : (r == null ? void 0 : r.guests) || [], S = i ? { ...i == null ? void 0 : i.additionalFields, guests: d } : { ...r == null ? void 0 : r.additionalFields, guests: d }, I = this.configId ? `?configuration_id=${this.configId}` : "", A = `/v3/scheduling/bookings/${e}${I}`, D = this.getHeaders(), m = await this.makeAPIRequest(decodeURIComponent(A), "PATCH", JSON.stringify({
310
- start_time: f.getTime() / 1e3,
311
- end_time: _.getTime() / 1e3,
312
- time_zone: a,
313
- additional_fields: S,
314
- guest: { ...u }
315
- }), D);
316
- if ("error" in m) {
317
- this.schedulerStore.set("isLoading", !1);
318
- const p = (k = m.error) == null ? void 0 : k.type;
319
- let w = m.error;
320
- if (p && p in s) {
321
- const z = this.getErrorMessage(w);
322
- w = s[p](z);
323
- }
324
- return { error: w };
325
- }
326
- const b = this.schedulerStore.get("reschedulingEventInfo");
327
- if ("data" in m)
328
- this.schedulerStore.set("eventInfo", m == null ? void 0 : m.data);
329
- else if (b)
330
- this.schedulerStore.set("eventInfo", b);
331
- else {
332
- const p = {
333
- booking_id: e
334
- };
335
- this.schedulerStore.set("eventInfo", p);
336
- }
337
- return this.schedulerStore.set("isLoading", !1), m;
338
- }
339
- }
340
- function C(o = {}) {
341
- const e = {
342
- selectedDate: null,
343
- selectedLanguage: navigator.language,
344
- selectedTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
345
- selectedTimeslot: null,
346
- showBookingForm: !1,
347
- selectableDates: null,
348
- availability: [],
349
- eventDuration: 0,
350
- state: "ready",
351
- eventInfo: null,
352
- cancelledEventInfo: null,
353
- isLoading: !1,
354
- nylasBranding: !0,
355
- ...o
356
- };
357
- v("[defaultNylasStoreState]: ", e);
358
- const i = L(e);
359
- return i.onChange("availability", (s) => {
360
- v("[availability]: ", s);
361
- const t = s[0], r = Math.floor((t.end_time.getTime() - t.start_time.getTime()) / 6e4);
362
- v("[durationMinutes]: ", r), i.set("eventDuration", r);
363
- const n = s.map((l) => l.start_time);
364
- v("[selectableDates]: ", n), i.set("selectableDates", n);
365
- }), i.reset = () => {
366
- for (const s in e) {
367
- const t = e[s];
368
- i.set(s, t);
369
- }
370
- }, i;
371
- }
372
- export {
373
- C,
374
- y as E,
375
- M as N
376
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-6a4ee4f8.cjs");require("react");require("react-dom");const s=".time-period-selector.sc-time-period-selector{display:flex;gap:0.5rem}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector{border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector select-dropdown#time-period.sc-time-period-selector::part(sd_dropdown-button){min-width:108px}.time-period-selector.sc-time-period-selector select-dropdown#time-number.sc-time-period-selector::part(sd_dropdown-button){min-width:84px}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-button){padding:1rem;gap:1rem}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-content){width:100%;max-height:200px}",n=s,i=class{constructor(e){d.registerInstance(this,e),this.timePeriodChanged=d.createEvent(this,"timePeriodChanged",7),this.timePeriods=["hour","day","week","month"],this.defaultSelectedPeriod="hour",this.defaultSelectedNumber=1,this.selectedPeriod=this.defaultSelectedPeriod,this.selectedNumber=this.defaultSelectedNumber,this.numberOptions=this.calculateOptions("hour").map(t=>({label:t.toString(),value:t.toString()})),this.timePeriodOptions=this.timePeriods.map(t=>({label:t,value:t}))}defaultSelectedPeriodChangedHandler(e){this.selectedPeriod=e,this.updateNumberOptionsAndSelectedNumber(e)}defaultSelectedNumberChangedHandler(e){this.selectedNumber=e}timePeriodsChangedHandler(e){this.timePeriodOptions=e.map(t=>({label:t,value:t}))}calculateOptions(e){switch(e){case"hour":return Array.from({length:23},(t,r)=>r+1);case"minute":return Array.from({length:13},(t,r)=>r*5);case"day":return Array.from({length:30},(t,r)=>r+1);case"week":return Array.from({length:4},(t,r)=>r+1);case"month":return Array.from({length:12},(t,r)=>r+1);default:return[]}}selectedOptionChangedHandler(e){d.debug("time-period-selector","selectedOptionChangedHandler",e.detail);const{value:t,name:r}=e.detail;r==="time-period"?(this.selectedPeriod=t,this.updateNumberOptionsAndSelectedNumber(t)):r==="time-number"&&(this.selectedNumber=parseInt(t));const o={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(o)}updateNumberOptionsAndSelectedNumber(e){const t=this.calculateOptions(e);this.numberOptions=t.map(r=>({label:r.toString(),value:r.toString()})),this.selectedNumber=parseInt(this.numberOptions[0].value)}render(){return d.h("div",{key:"7edc10024c638d484dd2645c1afeff0bbe6c0762",class:"time-period-selector"},d.h("select-dropdown",{key:"de189ba330463c98b0a1b6131ef3607ce35f4680",id:"time-number",name:"time-number",exportparts:"sd__dropdown: tps__number-dropdown, sd__dropdown-button: tps__number-dropdown-button, sd__dropdown-content: tps__number-dropdown-content",options:this.numberOptions,defaultSelectedOption:this.numberOptions.find(e=>e.value==this.selectedNumber.toString())??this.numberOptions[0],withSearch:!1}),d.h("select-dropdown",{key:"707a1ab8d07469c3f38af8c8b9b129be7af833fc",id:"time-period",name:"time-period",options:this.timePeriodOptions,exportparts:"sd__dropdown: tps__period-dropdown, sd__dropdown-button: tps__period-dropdown-button, sd__dropdown-content: tps__period-dropdown-content",pluralizedLabel:this.selectedNumber>1?"s":"",defaultSelectedOption:this.timePeriodOptions.find(e=>e.value==this.selectedPeriod)??this.timePeriodOptions[0],withSearch:!1}))}get host(){return d.getElement(this)}static get watchers(){return{defaultSelectedPeriod:["defaultSelectedPeriodChangedHandler"],defaultSelectedNumber:["defaultSelectedNumberChangedHandler"],timePeriods:["timePeriodsChangedHandler"]}}};i.style=n;exports.time_period_selector=i;
@@ -1,76 +0,0 @@
1
- import { r as i, c as s, d as n, h as d, g as l } from "./index-d61429c6.js";
2
- import "react";
3
- import "react-dom";
4
- const a = ".time-period-selector.sc-time-period-selector{display:flex;gap:0.5rem}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector{border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector select-dropdown#time-period.sc-time-period-selector::part(sd_dropdown-button){min-width:108px}.time-period-selector.sc-time-period-selector select-dropdown#time-number.sc-time-period-selector::part(sd_dropdown-button){min-width:84px}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-button){padding:1rem;gap:1rem}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-content){width:100%;max-height:200px}", c = a, p = class {
5
- constructor(e) {
6
- i(this, e), this.timePeriodChanged = s(this, "timePeriodChanged", 7), this.timePeriods = ["hour", "day", "week", "month"], this.defaultSelectedPeriod = "hour", this.defaultSelectedNumber = 1, this.selectedPeriod = this.defaultSelectedPeriod, this.selectedNumber = this.defaultSelectedNumber, this.numberOptions = this.calculateOptions("hour").map((t) => ({
7
- label: t.toString(),
8
- value: t.toString()
9
- })), this.timePeriodOptions = this.timePeriods.map((t) => ({
10
- label: t,
11
- value: t
12
- }));
13
- }
14
- defaultSelectedPeriodChangedHandler(e) {
15
- this.selectedPeriod = e, this.updateNumberOptionsAndSelectedNumber(e);
16
- }
17
- defaultSelectedNumberChangedHandler(e) {
18
- this.selectedNumber = e;
19
- }
20
- timePeriodsChangedHandler(e) {
21
- this.timePeriodOptions = e.map((t) => ({
22
- label: t,
23
- value: t
24
- }));
25
- }
26
- calculateOptions(e) {
27
- switch (e) {
28
- case "hour":
29
- return Array.from({ length: 23 }, (t, r) => r + 1);
30
- case "minute":
31
- return Array.from({ length: 13 }, (t, r) => r * 5);
32
- case "day":
33
- return Array.from({ length: 30 }, (t, r) => r + 1);
34
- case "week":
35
- return Array.from({ length: 4 }, (t, r) => r + 1);
36
- case "month":
37
- return Array.from({ length: 12 }, (t, r) => r + 1);
38
- default:
39
- return [];
40
- }
41
- }
42
- selectedOptionChangedHandler(e) {
43
- n("time-period-selector", "selectedOptionChangedHandler", e.detail);
44
- const { value: t, name: r } = e.detail;
45
- r === "time-period" ? (this.selectedPeriod = t, this.updateNumberOptionsAndSelectedNumber(t)) : r === "time-number" && (this.selectedNumber = parseInt(t));
46
- const o = {
47
- number: this.selectedNumber,
48
- period: this.selectedPeriod
49
- };
50
- this.timePeriodChanged.emit(o);
51
- }
52
- updateNumberOptionsAndSelectedNumber(e) {
53
- const t = this.calculateOptions(e);
54
- this.numberOptions = t.map((r) => ({
55
- label: r.toString(),
56
- value: r.toString()
57
- })), this.selectedNumber = parseInt(this.numberOptions[0].value);
58
- }
59
- render() {
60
- return d("div", { key: "7edc10024c638d484dd2645c1afeff0bbe6c0762", class: "time-period-selector" }, d("select-dropdown", { key: "de189ba330463c98b0a1b6131ef3607ce35f4680", id: "time-number", name: "time-number", exportparts: "sd__dropdown: tps__number-dropdown, sd__dropdown-button: tps__number-dropdown-button, sd__dropdown-content: tps__number-dropdown-content", options: this.numberOptions, defaultSelectedOption: this.numberOptions.find((e) => e.value == this.selectedNumber.toString()) ?? this.numberOptions[0], withSearch: !1 }), d("select-dropdown", { key: "707a1ab8d07469c3f38af8c8b9b129be7af833fc", id: "time-period", name: "time-period", options: this.timePeriodOptions, exportparts: "sd__dropdown: tps__period-dropdown, sd__dropdown-button: tps__period-dropdown-button, sd__dropdown-content: tps__period-dropdown-content", pluralizedLabel: this.selectedNumber > 1 ? "s" : "", defaultSelectedOption: this.timePeriodOptions.find((e) => e.value == this.selectedPeriod) ?? this.timePeriodOptions[0], withSearch: !1 }));
61
- }
62
- get host() {
63
- return l(this);
64
- }
65
- static get watchers() {
66
- return {
67
- defaultSelectedPeriod: ["defaultSelectedPeriodChangedHandler"],
68
- defaultSelectedNumber: ["defaultSelectedNumberChangedHandler"],
69
- timePeriods: ["timePeriodsChangedHandler"]
70
- };
71
- }
72
- };
73
- p.style = c;
74
- export {
75
- p as time_period_selector
76
- };