@nylas/react 1.1.0-canary.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -2
- package/dist/add-circle-icon_2.entry-7165bd0e.js +25 -0
- package/dist/add-circle-icon_2.entry-f1ddca18.cjs +1 -0
- package/dist/archive-icon_7.entry-7411c224.js +75 -0
- package/dist/archive-icon_7.entry-e3df60ed.cjs +1 -0
- package/dist/arrow-icon.entry-280e18b0.cjs +1 -0
- package/dist/arrow-icon.entry-38949317.js +15 -0
- package/dist/bold-icon_3.entry-5963945c.js +35 -0
- package/dist/bold-icon_3.entry-5dffbedd.cjs +1 -0
- package/dist/button-component_2.entry-237733b4.js +26 -0
- package/dist/button-component_2.entry-b29d2873.cjs +1 -0
- package/dist/calendar-agenda-fill-icon_48.entry-9afba869.js +5105 -0
- package/dist/calendar-agenda-fill-icon_48.entry-d3830dbb.cjs +7 -0
- package/dist/calendar-cancel-icon.entry-77ccf227.cjs +1 -0
- package/dist/calendar-cancel-icon.entry-780723a6.js +15 -0
- package/dist/calendar-check-icon_2.entry-2c89c230.js +25 -0
- package/dist/calendar-check-icon_2.entry-b37ac7f0.cjs +1 -0
- package/dist/calendar-icon.entry-02dd3990.js +15 -0
- package/dist/calendar-icon.entry-ffc93569.cjs +1 -0
- package/dist/checkbox-component_2.entry-00b6a1e9.cjs +1 -0
- package/dist/checkbox-component_2.entry-ee9d0e6c.js +56 -0
- package/dist/chevron-icon_3.entry-468abc26.cjs +1 -0
- package/dist/chevron-icon_3.entry-f62e9ef1.js +129 -0
- package/dist/clock-icon_4.entry-766a1b23.js +45 -0
- package/dist/clock-icon_4.entry-7dc2cc4a.cjs +1 -0
- package/dist/constants-50c3e067-8a40a5fe.js +3883 -0
- package/dist/constants-50c3e067-9f2a6372.cjs +15 -0
- package/dist/copy-icon.entry-2a841508.js +15 -0
- package/dist/copy-icon.entry-e5251410.cjs +1 -0
- package/dist/core-js-38e53e34.cjs +4 -0
- package/dist/core-js-a9d3b6e1.js +3297 -0
- package/dist/delete-icon_2.entry-1a5c39dc.cjs +1 -0
- package/dist/delete-icon_2.entry-64555a2f.js +25 -0
- package/dist/document-refresh-icon.entry-4bf6398b.js +15 -0
- package/dist/document-refresh-icon.entry-fdc7ddda.cjs +1 -0
- package/dist/dom-68f08be9.cjs +15 -0
- package/dist/dom-86e17616.js +664 -0
- package/dist/{types/elements → elements}/index.d.ts +47 -1
- package/dist/elements-dc5b338e-2da1fe61.js +28031 -0
- package/dist/elements-dc5b338e-c8016c3d.cjs +16516 -0
- package/dist/flow-40ff9cea-6f8c30e2.cjs +9 -0
- package/dist/flow-40ff9cea-ee70fdf5.js +505 -0
- package/dist/focus-visible-e8093c16-0a38a184.cjs +1 -0
- package/dist/focus-visible-e8093c16-9d0c98c0.js +84 -0
- package/dist/forward-icon_6.entry-390ef70a.js +953 -0
- package/dist/forward-icon_6.entry-7238ef38.cjs +3 -0
- package/dist/globe-icon.entry-81f42f89.cjs +1 -0
- package/dist/globe-icon.entry-8d106260.js +15 -0
- package/dist/google-logo-icon_4.entry-aabd3886.js +680 -0
- package/dist/google-logo-icon_4.entry-fa2b8999.cjs +1 -0
- package/dist/index-53420959-5fc8ad2b.js +5 -0
- package/dist/index-53420959-fcf45780.cjs +1 -0
- package/dist/index-5ccfd9df.js +7859 -0
- package/dist/index-6d9eeb53-58c8980a.js +4971 -0
- package/dist/index-6d9eeb53-b2a6d09f.cjs +41 -0
- package/dist/index-eb33703c.cjs +42 -0
- package/dist/index.es-c9454237-00ccd1e6.js +3135 -0
- package/dist/index.es-c9454237-b64161d1.cjs +7 -0
- package/dist/info-icon_2.entry-b2e11336.cjs +1 -0
- package/dist/info-icon_2.entry-bb8ed71c.js +34 -0
- package/dist/input-component.entry-378b1ccc.cjs +1 -0
- package/dist/input-component.entry-cb86170f.js +65 -0
- package/dist/input-dropdown.entry-98954c93.cjs +1 -0
- package/dist/input-dropdown.entry-a76c339e.js +134 -0
- package/dist/mailbox-store-edc386fc-156b7236.cjs +1 -0
- package/dist/mailbox-store-edc386fc-8bc7558b.js +380 -0
- package/dist/multi-select-dropdown.entry-40b855e1.cjs +1 -0
- package/dist/multi-select-dropdown.entry-6b686695.js +91 -0
- package/dist/nylas-booked-event-card_12.entry-9d693125.cjs +1 -0
- package/dist/nylas-booked-event-card_12.entry-e861bb16.js +1134 -0
- package/dist/nylas-form-card.entry-b158d789.js +57 -0
- package/dist/nylas-form-card.entry-ca4a8746.cjs +1 -0
- package/dist/nylas-if-state.entry-8e4d922c.js +94 -0
- package/dist/nylas-if-state.entry-95fac42d.cjs +1 -0
- package/dist/nylas-list-folders.entry-83c39684.js +120 -0
- package/dist/nylas-list-folders.entry-8a22e0c8.cjs +1 -0
- package/dist/nylas-list-threads.entry-54c582af.cjs +1 -0
- package/dist/nylas-list-threads.entry-7ea370e1.js +70 -0
- package/dist/nylas-login.entry-9115fd81.js +73 -0
- package/dist/nylas-login.entry-fb627e40.cjs +1 -0
- package/dist/nylas-mailbox-pagination.entry-04626d27.cjs +1 -0
- package/dist/nylas-mailbox-pagination.entry-3ff02cf9.js +101 -0
- package/dist/nylas-mailbox-toolbar-button.entry-8d00c789.cjs +1 -0
- package/dist/nylas-mailbox-toolbar-button.entry-f752e925.js +82 -0
- package/dist/nylas-mailbox.entry-99c27b6c.js +134 -0
- package/dist/nylas-mailbox.entry-b3974f4e.cjs +1 -0
- package/dist/nylas-provider.entry-a3ad02a5.cjs +1 -0
- package/dist/nylas-provider.entry-c206aa32.js +145 -0
- package/dist/nylas-reminder-emails.entry-414ce6fe.js +129 -0
- package/dist/nylas-reminder-emails.entry-59c07bfe.cjs +4 -0
- package/dist/nylas-reminder-time_2.entry-197d83a0.js +105 -0
- package/dist/nylas-reminder-time_2.entry-d79dcd85.cjs +1 -0
- package/dist/nylas-scheduler-editor.entry-7f389982.js +1447 -0
- package/dist/nylas-scheduler-editor.entry-f1c6964a.cjs +2 -0
- package/dist/nylas-scheduling.entry-1a8bd6fc.cjs +1 -0
- package/dist/nylas-scheduling.entry-4fa5381d.js +345 -0
- package/dist/nylas-threads-refresh.entry-20602e7b.js +74 -0
- package/dist/nylas-threads-refresh.entry-56b53449.cjs +1 -0
- package/dist/nylas-threads-search.entry-8872473c.js +69 -0
- package/dist/nylas-threads-search.entry-8e0ec3ae.cjs +1 -0
- package/dist/nylas-time-window-picker.entry-9ac542b7.js +316 -0
- package/dist/nylas-time-window-picker.entry-ca47f721.cjs +1 -0
- package/dist/nylas-view-thread.entry-1f758e43.cjs +1 -0
- package/dist/nylas-view-thread.entry-dcd3d5be.js +203 -0
- package/dist/person-icon.entry-63b28ace.cjs +1 -0
- package/dist/person-icon.entry-93130c05.js +15 -0
- package/dist/play-icon_2.entry-6a99c32d.js +25 -0
- package/dist/play-icon_2.entry-b67fb649.cjs +1 -0
- package/dist/react.cjs +1 -0
- package/dist/react.js +144 -0
- package/dist/refresh-icon.entry-84783c91.js +15 -0
- package/dist/refresh-icon.entry-b49792fc.cjs +1 -0
- package/dist/register-component-887199a9-003f96c5.cjs +1 -0
- package/dist/register-component-887199a9-b41dfa7a.js +109 -0
- package/dist/scheduler-config-store-2a3b403d-73610089.js +27 -0
- package/dist/scheduler-config-store-2a3b403d-a5e3433a.cjs +1 -0
- package/dist/scheduler-store-fe281404-bddb1b6a.js +469 -0
- package/dist/scheduler-store-fe281404-c3e477f6.cjs +1 -0
- package/dist/textarea-component.entry-28c4bc05.cjs +1 -0
- package/dist/textarea-component.entry-40e959e5.js +36 -0
- package/dist/time-period-selector.entry-af71523a.cjs +1 -0
- package/dist/time-period-selector.entry-da5d8652.js +93 -0
- package/dist/translate-icon.entry-92b83635.js +15 -0
- package/dist/translate-icon.entry-a2ed4f76.cjs +1 -0
- package/dist/warning-icon.entry-19f721c3.js +15 -0
- package/dist/warning-icon.entry-3ab9a59e.cjs +1 -0
- package/package.json +12 -8
- package/dist/elements/index.js +0 -92
- package/dist/elements/index.js.map +0 -1
- package/dist/elements/react-component-lib/createComponent.js +0 -65
- package/dist/elements/react-component-lib/createComponent.js.map +0 -1
- package/dist/elements/react-component-lib/createOverlayComponent.js +0 -98
- package/dist/elements/react-component-lib/createOverlayComponent.js.map +0 -1
- package/dist/elements/react-component-lib/index.js +0 -3
- package/dist/elements/react-component-lib/index.js.map +0 -1
- package/dist/elements/react-component-lib/interfaces.js +0 -2
- package/dist/elements/react-component-lib/interfaces.js.map +0 -1
- package/dist/elements/react-component-lib/utils/attachProps.js +0 -92
- package/dist/elements/react-component-lib/utils/attachProps.js.map +0 -1
- package/dist/elements/react-component-lib/utils/case.js +0 -7
- package/dist/elements/react-component-lib/utils/case.js.map +0 -1
- package/dist/elements/react-component-lib/utils/dev.js +0 -13
- package/dist/elements/react-component-lib/utils/dev.js.map +0 -1
- package/dist/elements/react-component-lib/utils/index.js +0 -31
- package/dist/elements/react-component-lib/utils/index.js.map +0 -1
- package/dist/index.js +0 -29
- package/dist/index.js.map +0 -1
- /package/dist/{types/elements → elements}/react-component-lib/createComponent.d.ts +0 -0
- /package/dist/{types/elements → elements}/react-component-lib/createOverlayComponent.d.ts +0 -0
- /package/dist/{types/elements → elements}/react-component-lib/index.d.ts +0 -0
- /package/dist/{types/elements → elements}/react-component-lib/interfaces.d.ts +0 -0
- /package/dist/{types/elements → elements}/react-component-lib/utils/attachProps.d.ts +0 -0
- /package/dist/{types/elements → elements}/react-component-lib/utils/case.d.ts +0 -0
- /package/dist/{types/elements → elements}/react-component-lib/utils/dev.d.ts +0 -0
- /package/dist/{types/elements → elements}/react-component-lib/utils/index.d.ts +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { d as b, e as $, k as d, m as R } from "./index-5ccfd9df.js";
|
|
2
|
+
var w;
|
|
3
|
+
(function(a) {
|
|
4
|
+
a.Component = "component", a.Api = "api", a.Auth = "auth";
|
|
5
|
+
})(w || (w = {}));
|
|
6
|
+
var D;
|
|
7
|
+
(function(a) {
|
|
8
|
+
a.endtime_not_in_future = "endtime_not_in_future", a.no_booking_info = "no_booking_info", a.no_timeslot_selected = "no_timeslot_selected", a.no_timezone_selected = "no_timezone_selected", a.no_booking_id = "no_booking_id", a.no_salt = "no_salt", a.invalid_start_time = "invalid_start_time", a.invalid_end_time = "invalid_end_time", a.invalid_timezone = "invalid_timezone";
|
|
9
|
+
})(D || (D = {}));
|
|
10
|
+
var A;
|
|
11
|
+
(function(a) {
|
|
12
|
+
a.invalid_session = "invalid_session", a.general_error = "general_error", a.internal_error = "internal_error", a.invalid_request_error = "invalid_request_error", a.timeslot_not_available = "timeslot_not_available", a.provider_error = "provider_error", a.not_found_error = "not_found_error";
|
|
13
|
+
})(A || (A = {}));
|
|
14
|
+
class C {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.component = (e) => {
|
|
17
|
+
const t = w.Component, s = `${e} Error`;
|
|
18
|
+
return {
|
|
19
|
+
endtime_not_in_future: (i = '"endtime" can not be in the future') => ({
|
|
20
|
+
title: s,
|
|
21
|
+
message: i,
|
|
22
|
+
category: t
|
|
23
|
+
}),
|
|
24
|
+
no_booking_info: (i = "No booking info provided") => ({
|
|
25
|
+
title: s,
|
|
26
|
+
message: i,
|
|
27
|
+
category: t
|
|
28
|
+
}),
|
|
29
|
+
no_timeslot_selected: (i = "No timeslot selected") => ({
|
|
30
|
+
title: s,
|
|
31
|
+
message: i,
|
|
32
|
+
category: t
|
|
33
|
+
}),
|
|
34
|
+
no_timezone_selected: (i = "No timezone selected") => ({
|
|
35
|
+
title: s,
|
|
36
|
+
message: i,
|
|
37
|
+
category: t
|
|
38
|
+
}),
|
|
39
|
+
no_booking_id: (i = "No booking id provided") => ({
|
|
40
|
+
title: s,
|
|
41
|
+
message: i,
|
|
42
|
+
category: t
|
|
43
|
+
}),
|
|
44
|
+
no_salt: (i = "No salt provided") => ({
|
|
45
|
+
title: s,
|
|
46
|
+
message: i,
|
|
47
|
+
category: t
|
|
48
|
+
}),
|
|
49
|
+
invalid_start_time: (i = "Invalid start time") => ({
|
|
50
|
+
title: s,
|
|
51
|
+
message: i,
|
|
52
|
+
category: t
|
|
53
|
+
}),
|
|
54
|
+
invalid_end_time: (i = "Invalid end time") => ({
|
|
55
|
+
title: s,
|
|
56
|
+
message: i,
|
|
57
|
+
category: t
|
|
58
|
+
}),
|
|
59
|
+
invalid_timezone: (i = "Invalid timezone") => ({
|
|
60
|
+
title: s,
|
|
61
|
+
message: i,
|
|
62
|
+
category: t
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
}, this.api = (e) => {
|
|
66
|
+
const t = w.Api, s = `${e} Error`;
|
|
67
|
+
return {
|
|
68
|
+
invalid_session: (i) => ({
|
|
69
|
+
title: s,
|
|
70
|
+
message: i,
|
|
71
|
+
category: t
|
|
72
|
+
}),
|
|
73
|
+
general_error: (i) => ({
|
|
74
|
+
title: s,
|
|
75
|
+
message: i,
|
|
76
|
+
category: t
|
|
77
|
+
}),
|
|
78
|
+
internal_error: (i) => ({
|
|
79
|
+
title: s,
|
|
80
|
+
message: i,
|
|
81
|
+
category: t
|
|
82
|
+
}),
|
|
83
|
+
invalid_request_error: (i) => ({
|
|
84
|
+
title: s,
|
|
85
|
+
message: i,
|
|
86
|
+
category: t
|
|
87
|
+
}),
|
|
88
|
+
timeslot_not_available: (i) => ({
|
|
89
|
+
title: s,
|
|
90
|
+
message: i,
|
|
91
|
+
category: t
|
|
92
|
+
}),
|
|
93
|
+
provider_error: (i) => ({
|
|
94
|
+
title: s,
|
|
95
|
+
message: i,
|
|
96
|
+
category: t
|
|
97
|
+
}),
|
|
98
|
+
not_found_error: (i) => ({
|
|
99
|
+
title: s,
|
|
100
|
+
message: i,
|
|
101
|
+
category: t
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
class U {
|
|
108
|
+
constructor({ schedulerAPIURL: e, schedulerStore: t, sessionId: s, configId: i, slug: n, clientId: r }) {
|
|
109
|
+
this.errors = new C(), this.schedulerStore = t, this.schedulerAPIURL = e, this.sessionId = s, this.configId = i, this.slug = n, this.clientId = r;
|
|
110
|
+
}
|
|
111
|
+
getHeaders() {
|
|
112
|
+
return this.sessionId ? {
|
|
113
|
+
Authorization: `Bearer ${this.sessionId}`
|
|
114
|
+
} : {};
|
|
115
|
+
}
|
|
116
|
+
async makeAPIRequest(e, t, s, i = {}) {
|
|
117
|
+
try {
|
|
118
|
+
const n = new URL(this.schedulerAPIURL);
|
|
119
|
+
return n.pathname = e, await (await fetch(decodeURIComponent(n.toString()), {
|
|
120
|
+
method: t,
|
|
121
|
+
headers: {
|
|
122
|
+
"Content-Type": "application/json",
|
|
123
|
+
Origin: window.location.origin,
|
|
124
|
+
...i
|
|
125
|
+
},
|
|
126
|
+
body: s
|
|
127
|
+
})).json();
|
|
128
|
+
} catch (n) {
|
|
129
|
+
return {
|
|
130
|
+
error: {
|
|
131
|
+
message: n.message,
|
|
132
|
+
title: "API request failed",
|
|
133
|
+
type: "api"
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
getErrorMessage(e) {
|
|
139
|
+
var s, i, n, r;
|
|
140
|
+
let t = (e == null ? void 0 : e.message) || (e == null ? void 0 : e.title) || "Something went wrong";
|
|
141
|
+
return (e == null ? void 0 : e.type) === "provider_error" && (t = ((i = (s = e == null ? void 0 : e.provider_error) == null ? void 0 : s.error) == null ? void 0 : i.message) || ((r = (n = e == null ? void 0 : e.provider_error) == null ? void 0 : n.error) == null ? void 0 : r.title) || "Something went wrong"), t;
|
|
142
|
+
}
|
|
143
|
+
setConfigId(e) {
|
|
144
|
+
this.configId = e;
|
|
145
|
+
}
|
|
146
|
+
selectDate(e) {
|
|
147
|
+
this.schedulerStore.set("selectedDate", e), this.schedulerStore.set("selectedTimeslot", null);
|
|
148
|
+
}
|
|
149
|
+
selectTime(e) {
|
|
150
|
+
this.schedulerStore.set("selectedTimeslot", e);
|
|
151
|
+
}
|
|
152
|
+
selectTimezone(e) {
|
|
153
|
+
this.schedulerStore.set("selectedTimezone", e);
|
|
154
|
+
}
|
|
155
|
+
selectLanguage(e) {
|
|
156
|
+
this.schedulerStore.set("selectedLanguage", e), d.changeLanguage(e);
|
|
157
|
+
}
|
|
158
|
+
async toggleAdditionalData(e) {
|
|
159
|
+
e || await this.refetchAvailability(), this.schedulerStore.set("showBookingForm", e);
|
|
160
|
+
}
|
|
161
|
+
setParticipantName(e) {
|
|
162
|
+
const { bookingInfo: t } = this.schedulerStore.state;
|
|
163
|
+
this.schedulerStore.set("bookingInfo", {
|
|
164
|
+
...t,
|
|
165
|
+
primaryParticipant: {
|
|
166
|
+
...t == null ? void 0 : t.primaryParticipant,
|
|
167
|
+
name: e
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
setParticipantEmail(e) {
|
|
172
|
+
const { bookingInfo: t } = this.schedulerStore.state;
|
|
173
|
+
this.schedulerStore.set("bookingInfo", {
|
|
174
|
+
...t,
|
|
175
|
+
primaryParticipant: {
|
|
176
|
+
...t == null ? void 0 : t.primaryParticipant,
|
|
177
|
+
email: e
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async refetchAvailability() {
|
|
182
|
+
const e = /* @__PURE__ */ new Date(), t = new Date(e.getFullYear(), e.getMonth(), 1).getTime() / 1e3, s = t < e.getTime() / 1e3 ? Math.floor(e.getTime() / 1e3) : t, i = new Date(e.getFullYear(), e.getMonth() + 1, 1).getTime() / 1e3;
|
|
183
|
+
return await this.getAvailability(s, i);
|
|
184
|
+
}
|
|
185
|
+
async resetStoreStateAndFetchAvailability() {
|
|
186
|
+
const e = /* @__PURE__ */ new Date(), t = await this.refetchAvailability(), s = this.schedulerStore.get("availability").find((n) => new Date(n.start_time) > /* @__PURE__ */ new Date());
|
|
187
|
+
let i = e;
|
|
188
|
+
return s && (i = s.start_time), this.schedulerStore.set("selectedDate", i), this.schedulerStore.set("eventInfo", null), this.schedulerStore.set("showBookingForm", !1), this.schedulerStore.set("selectedTimeslot", null), t;
|
|
189
|
+
}
|
|
190
|
+
async setReschedule(e) {
|
|
191
|
+
this.schedulerStore.set("isLoading", !0);
|
|
192
|
+
const t = this.schedulerStore.state.eventInfo;
|
|
193
|
+
return t && this.schedulerStore.set("reschedulingEventInfo", t), this.schedulerStore.set("rescheduleBookingId", e), await this.resetStoreStateAndFetchAvailability().finally(() => {
|
|
194
|
+
this.schedulerStore.set("isLoading", !1);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
async setCancel(e) {
|
|
198
|
+
this.schedulerStore.set("cancelBookingId", e);
|
|
199
|
+
}
|
|
200
|
+
async setReject(e) {
|
|
201
|
+
this.schedulerStore.set("rejectBookingId", e);
|
|
202
|
+
}
|
|
203
|
+
async resetCancel() {
|
|
204
|
+
const e = await this.resetStoreStateAndFetchAvailability();
|
|
205
|
+
return this.schedulerStore.set("cancelBookingId", ""), this.schedulerStore.set("rejectBookingId", ""), this.schedulerStore.set("cancelledEventInfo", null), e;
|
|
206
|
+
}
|
|
207
|
+
async goBack() {
|
|
208
|
+
this.schedulerStore.set("cancelBookingId", "");
|
|
209
|
+
}
|
|
210
|
+
async resetConfirm() {
|
|
211
|
+
const e = await this.resetStoreStateAndFetchAvailability();
|
|
212
|
+
return this.schedulerStore.set("organizerConfirmationBookingId", ""), this.schedulerStore.set("confirmedEventInfo", void 0), e;
|
|
213
|
+
}
|
|
214
|
+
async bookTimeslot(e) {
|
|
215
|
+
var I;
|
|
216
|
+
this.schedulerStore.set("isLoading", !0);
|
|
217
|
+
const { selectedTimeslot: t, selectedTimezone: s, bookingInfo: i, selectedLanguage: n } = this.schedulerStore.state;
|
|
218
|
+
if (!e && !i)
|
|
219
|
+
return { error: this.errors.component(d.t("createBookingErrorTitle")).no_booking_info() };
|
|
220
|
+
const r = (e == null ? void 0 : e.timeslot) || t;
|
|
221
|
+
if (!r)
|
|
222
|
+
return { error: this.errors.component(d.t("createBookingErrorTitle")).no_timeslot_selected() };
|
|
223
|
+
const o = e && (e != null && e.timezone) ? e == null ? void 0 : e.timezone : s;
|
|
224
|
+
if (!o)
|
|
225
|
+
return { error: this.errors.component(d.t("createBookingErrorTitle")).no_timezone_selected() };
|
|
226
|
+
const u = this.schedulerStore.get("availabilityOrderEmails");
|
|
227
|
+
let g = "";
|
|
228
|
+
if (u.length > 0) {
|
|
229
|
+
const m = r.emails;
|
|
230
|
+
for (let p = 0; p < u.length; p++)
|
|
231
|
+
if (m.includes(u[p])) {
|
|
232
|
+
g = u[p];
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const l = e ? e == null ? void 0 : e.primaryParticipant : i == null ? void 0 : i.primaryParticipant, v = e ? (e == null ? void 0 : e.guests) || [] : (i == null ? void 0 : i.guests) || [], f = e ? e == null ? void 0 : e.additionalFields : i == null ? void 0 : i.additionalFields, _ = this.getHeaders(), h = `/v3/scheduling/bookings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : ""}`, c = await this.makeAPIRequest(decodeURIComponent(h), "POST", JSON.stringify({
|
|
237
|
+
participants: g ? [{ email: g }] : void 0,
|
|
238
|
+
additional_fields: f,
|
|
239
|
+
additional_guests: v,
|
|
240
|
+
guest: { ...l },
|
|
241
|
+
start_time: r.start_time.getTime() / 1e3,
|
|
242
|
+
end_time: r.end_time.getTime() / 1e3,
|
|
243
|
+
timezone: o,
|
|
244
|
+
email_language: this.getTwoLetterLanguageCode(n)
|
|
245
|
+
}), _);
|
|
246
|
+
if ("error" in c) {
|
|
247
|
+
this.schedulerStore.set("isLoading", !1);
|
|
248
|
+
const m = (I = c.error) == null ? void 0 : I.type;
|
|
249
|
+
let p = c.error;
|
|
250
|
+
if (m && m in this.errors.api("Create Booking")) {
|
|
251
|
+
const L = this.getErrorMessage(p);
|
|
252
|
+
p = this.errors.api("Create Booking")[m](L);
|
|
253
|
+
}
|
|
254
|
+
return { error: p };
|
|
255
|
+
}
|
|
256
|
+
return "data" in c && this.schedulerStore.set("eventInfo", c == null ? void 0 : c.data), this.schedulerStore.set("isLoading", !1), c;
|
|
257
|
+
}
|
|
258
|
+
async getUISettings() {
|
|
259
|
+
var n;
|
|
260
|
+
this.schedulerStore.set("isLoading", !0);
|
|
261
|
+
const e = this.getHeaders(), s = `/v3/scheduling/ui-settings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : ""}`, i = await this.makeAPIRequest(s, "GET", void 0, e);
|
|
262
|
+
if ("error" in i) {
|
|
263
|
+
this.schedulerStore.set("isLoading", !1);
|
|
264
|
+
const r = (n = i.error) == null ? void 0 : n.type;
|
|
265
|
+
let o = i.error;
|
|
266
|
+
return r && r in this.errors.api(d.t("getUISettingErrorTitle")) && (o = this.errors.api(d.t("getUISettingErrorTitle"))[r]((o == null ? void 0 : o.message) || (o == null ? void 0 : o.title) || "Something went wrong")), { error: o };
|
|
267
|
+
}
|
|
268
|
+
return "data" in i && this.schedulerStore.set("configSettings", i.data), this.schedulerStore.set("isLoading", !1), i;
|
|
269
|
+
}
|
|
270
|
+
getTwoLetterLanguageCode(e) {
|
|
271
|
+
return e.split("-")[0];
|
|
272
|
+
}
|
|
273
|
+
getStartTimeWithMinBookingNotice(e) {
|
|
274
|
+
var i;
|
|
275
|
+
const t = (i = this.schedulerStore.get("configSettings")) == null ? void 0 : i.scheduler, s = t == null ? void 0 : t.min_booking_notice;
|
|
276
|
+
return s ? e + s * 60 : e;
|
|
277
|
+
}
|
|
278
|
+
getEndTimeForAvailableDaysInFuture(e) {
|
|
279
|
+
var r, o;
|
|
280
|
+
const t = /* @__PURE__ */ new Date(), s = (o = (r = this.schedulerStore.get("configSettings")) == null ? void 0 : r.scheduler) == null ? void 0 : o.available_days_in_future, i = Math.floor(R(t, s).getTime() / 1e3);
|
|
281
|
+
return Math.min(i, e);
|
|
282
|
+
}
|
|
283
|
+
async getAvailability(e = 0, t = 0) {
|
|
284
|
+
var v, f, _, S;
|
|
285
|
+
this.schedulerStore.set("isLoading", !0);
|
|
286
|
+
const s = new URLSearchParams(), i = /* @__PURE__ */ new Date(), n = i.getTime();
|
|
287
|
+
if (t && t < n / 1e3)
|
|
288
|
+
return this.schedulerStore.set("isLoading", !1), { error: this.errors.component(d.t("getAvailabilityErrorTitle")).endtime_not_in_future() };
|
|
289
|
+
if (!e) {
|
|
290
|
+
const h = new Date(i.getFullYear(), i.getMonth(), 1);
|
|
291
|
+
e = Math.floor(h.getTime() / 1e3);
|
|
292
|
+
}
|
|
293
|
+
if (e = this.getStartTimeWithMinBookingNotice(e), !t) {
|
|
294
|
+
const h = new Date(i.getFullYear(), i.getMonth() + 1, 0);
|
|
295
|
+
t = Math.floor(h.getTime() / 1e3);
|
|
296
|
+
}
|
|
297
|
+
t = this.getEndTimeForAvailableDaysInFuture(t), s.append("start_time", encodeURIComponent(e.toString())), s.append("end_time", encodeURIComponent(t.toString())), this.configId && !this.sessionId ? s.append("configuration_id", encodeURIComponent(this.configId)) : this.slug && this.clientId && !this.sessionId && (s.append("slug", encodeURIComponent(this.slug)), s.append("client_id", encodeURIComponent(this.clientId)));
|
|
298
|
+
const r = this.schedulerStore.get("rescheduleBookingId");
|
|
299
|
+
r && s.append("booking_id", encodeURIComponent(r));
|
|
300
|
+
const o = s.toString(), u = `/v3/scheduling/availability${o ? `?${o}` : ""}`, g = this.getHeaders(), l = await this.makeAPIRequest(decodeURIComponent(u), "GET", void 0, g);
|
|
301
|
+
if ("error" in l) {
|
|
302
|
+
this.schedulerStore.set("availability", []), this.schedulerStore.set("isLoading", !1);
|
|
303
|
+
const h = (v = l.error) == null ? void 0 : v.type;
|
|
304
|
+
let c = l.error;
|
|
305
|
+
if (h && h in this.errors.api(d.t("getAvailabilityErrorTitle"))) {
|
|
306
|
+
const I = this.getErrorMessage(c);
|
|
307
|
+
c = this.errors.api(d.t("getAvailabilityErrorTitle"))[h](I);
|
|
308
|
+
}
|
|
309
|
+
return { error: c };
|
|
310
|
+
}
|
|
311
|
+
if ("data" in l) {
|
|
312
|
+
const c = (((_ = (f = l.data) == null ? void 0 : f.time_slots) == null ? void 0 : _.map((m) => ({
|
|
313
|
+
...m,
|
|
314
|
+
start_time: new Date(m.start_time * 1e3),
|
|
315
|
+
end_time: new Date(m.end_time * 1e3)
|
|
316
|
+
}))) || []).filter((m) => m.start_time.getTime() > n);
|
|
317
|
+
this.schedulerStore.set("availability", c);
|
|
318
|
+
const I = ((S = l.data) == null ? void 0 : S.order) || [];
|
|
319
|
+
this.schedulerStore.set("availabilityOrderEmails", I);
|
|
320
|
+
}
|
|
321
|
+
return this.schedulerStore.set("isLoading", !1), l;
|
|
322
|
+
}
|
|
323
|
+
async cancelBooking(e, t) {
|
|
324
|
+
var o;
|
|
325
|
+
if (this.schedulerStore.set("isLoading", !0), !e)
|
|
326
|
+
return { error: this.errors.component(d.t("cancelBookingErrorTitle")).no_booking_id() };
|
|
327
|
+
const s = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : "", i = `/v3/scheduling/bookings/${e}${s}`, n = this.getHeaders(), r = await this.makeAPIRequest(decodeURIComponent(i), "DELETE", JSON.stringify({
|
|
328
|
+
action: "cancel",
|
|
329
|
+
cancellation_reason: t
|
|
330
|
+
}), n);
|
|
331
|
+
if ("error" in r) {
|
|
332
|
+
this.schedulerStore.set("isLoading", !1);
|
|
333
|
+
const u = (o = r.error) == null ? void 0 : o.type;
|
|
334
|
+
let g = r.error;
|
|
335
|
+
if (u && u in this.errors.api(d.t("cancelBookingErrorTitle"))) {
|
|
336
|
+
const l = this.getErrorMessage(g);
|
|
337
|
+
g = this.errors.api(d.t("cancelBookingErrorTitle"))[u](l);
|
|
338
|
+
}
|
|
339
|
+
return { error: g };
|
|
340
|
+
}
|
|
341
|
+
return this.schedulerStore.set("cancelledEventInfo", {
|
|
342
|
+
booking_id: e
|
|
343
|
+
}), this.schedulerStore.set("rescheduleBookingId", ""), this.schedulerStore.set("isLoading", !1), r;
|
|
344
|
+
}
|
|
345
|
+
async rescheduleBooking(e, t) {
|
|
346
|
+
var E;
|
|
347
|
+
if (this.schedulerStore.set("isLoading", !0), !e)
|
|
348
|
+
return { error: this.errors.component(d.t("rescheduleBookingErrorTitle")).no_booking_id() };
|
|
349
|
+
const s = this.errors.api(d.t("rescheduleBookingErrorTitle")), i = this.errors.component(d.t("rescheduleBookingErrorTitle")), { bookingInfo: n, selectedTimeslot: r, selectedTimezone: o, selectedLanguage: u } = this.schedulerStore.state, { startTime: g, endTime: l, timezone: v } = t, f = g || (r == null ? void 0 : r.start_time);
|
|
350
|
+
if (!f)
|
|
351
|
+
return { error: i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
|
|
352
|
+
const _ = l || (r == null ? void 0 : r.end_time);
|
|
353
|
+
if (!_)
|
|
354
|
+
return { error: i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
|
|
355
|
+
const S = this.schedulerStore.get("availabilityOrderEmails");
|
|
356
|
+
let h = "";
|
|
357
|
+
if (S.length > 0) {
|
|
358
|
+
const T = (r == null ? void 0 : r.emails) || [];
|
|
359
|
+
for (let k = 0; k < S.length; k++)
|
|
360
|
+
if (T.includes(S[k])) {
|
|
361
|
+
h = S[k];
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const c = v || o;
|
|
366
|
+
if (!c)
|
|
367
|
+
return { error: i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.') };
|
|
368
|
+
const I = t ? t == null ? void 0 : t.primaryParticipant : n == null ? void 0 : n.primaryParticipant, m = t ? (t == null ? void 0 : t.guests) || [] : (n == null ? void 0 : n.guests) || [], p = t ? t == null ? void 0 : t.additionalFields : n == null ? void 0 : n.additionalFields, L = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : "", P = `/v3/scheduling/bookings/${e}${L}`, z = this.getHeaders(), y = await this.makeAPIRequest(decodeURIComponent(P), "PATCH", JSON.stringify({
|
|
369
|
+
start_time: f.getTime() / 1e3,
|
|
370
|
+
end_time: _.getTime() / 1e3,
|
|
371
|
+
timezone: c,
|
|
372
|
+
additional_fields: p,
|
|
373
|
+
guest: { ...I },
|
|
374
|
+
additional_guests: m,
|
|
375
|
+
participants: h ? [{ email: h }] : void 0,
|
|
376
|
+
email_language: this.getTwoLetterLanguageCode(u)
|
|
377
|
+
}), z);
|
|
378
|
+
if ("error" in y) {
|
|
379
|
+
this.schedulerStore.set("isLoading", !1);
|
|
380
|
+
const T = (E = y.error) == null ? void 0 : E.type;
|
|
381
|
+
let k = y.error;
|
|
382
|
+
if (T && T in s) {
|
|
383
|
+
const M = this.getErrorMessage(k);
|
|
384
|
+
k = s[T](M);
|
|
385
|
+
}
|
|
386
|
+
return { error: k };
|
|
387
|
+
}
|
|
388
|
+
const B = this.schedulerStore.get("reschedulingEventInfo");
|
|
389
|
+
if ("data" in y)
|
|
390
|
+
this.schedulerStore.set("eventInfo", y == null ? void 0 : y.data);
|
|
391
|
+
else if (B)
|
|
392
|
+
this.schedulerStore.set("eventInfo", B);
|
|
393
|
+
else {
|
|
394
|
+
const T = {
|
|
395
|
+
booking_id: e
|
|
396
|
+
};
|
|
397
|
+
this.schedulerStore.set("eventInfo", T);
|
|
398
|
+
}
|
|
399
|
+
return this.schedulerStore.set("isLoading", !1), y;
|
|
400
|
+
}
|
|
401
|
+
async updateBooking(e) {
|
|
402
|
+
var v;
|
|
403
|
+
this.schedulerStore.set("isLoading", !0);
|
|
404
|
+
const { bookingId: t, status: s, reason: i } = e, n = this.schedulerStore.get("organizerConfirmationSalt"), r = s === "confirmed" ? d.t("confirmBookingErrorTitle") : d.t("rejectBookingErrorTitle");
|
|
405
|
+
if (!t)
|
|
406
|
+
return { error: this.errors.component(r).no_booking_id() };
|
|
407
|
+
if (!n)
|
|
408
|
+
return { error: this.errors.component(r).no_salt() };
|
|
409
|
+
const o = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : "", u = `/v3/scheduling/bookings/${t}${o}`, g = this.getHeaders(), l = await this.makeAPIRequest(decodeURIComponent(u), "PUT", JSON.stringify({
|
|
410
|
+
status: s,
|
|
411
|
+
cancellation_reason: i,
|
|
412
|
+
salt: n
|
|
413
|
+
}), g);
|
|
414
|
+
if ("error" in l) {
|
|
415
|
+
this.schedulerStore.set("isLoading", !1);
|
|
416
|
+
const f = (v = l.error) == null ? void 0 : v.type;
|
|
417
|
+
let _ = l.error;
|
|
418
|
+
if (f && f in this.errors.api(r)) {
|
|
419
|
+
const S = this.getErrorMessage(_);
|
|
420
|
+
_ = this.errors.api(r)[f](S);
|
|
421
|
+
}
|
|
422
|
+
return { error: _ };
|
|
423
|
+
}
|
|
424
|
+
return "data" in l && s === "confirmed" ? this.schedulerStore.set("confirmedEventInfo", l == null ? void 0 : l.data) : "request_id" in l && s === "cancelled" && this.schedulerStore.set("cancelledEventInfo", {
|
|
425
|
+
booking_id: t
|
|
426
|
+
}), this.schedulerStore.set("organizerConfirmationBookingId", ""), this.schedulerStore.set("isLoading", !1), l;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function N(a = {}) {
|
|
430
|
+
const e = {
|
|
431
|
+
selectedDate: null,
|
|
432
|
+
selectedLanguage: navigator.language,
|
|
433
|
+
selectedTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
434
|
+
selectedTimeslot: null,
|
|
435
|
+
showBookingForm: !1,
|
|
436
|
+
availabilityOrderEmails: [],
|
|
437
|
+
selectableDates: null,
|
|
438
|
+
availability: [],
|
|
439
|
+
eventDuration: 0,
|
|
440
|
+
state: "ready",
|
|
441
|
+
eventInfo: null,
|
|
442
|
+
cancelledEventInfo: null,
|
|
443
|
+
isLoading: !1,
|
|
444
|
+
nylasBranding: !0,
|
|
445
|
+
...a
|
|
446
|
+
};
|
|
447
|
+
b("[defaultNylasStoreState]: ", e);
|
|
448
|
+
const t = $(e);
|
|
449
|
+
return t.onChange("availability", (s) => {
|
|
450
|
+
b("[availability]: ", s);
|
|
451
|
+
const i = s.map((o) => o.start_time);
|
|
452
|
+
b("[selectableDates]: ", i), t.set("selectableDates", i);
|
|
453
|
+
const n = s[0];
|
|
454
|
+
if (!n)
|
|
455
|
+
return;
|
|
456
|
+
const r = Math.floor((n.end_time.getTime() - n.start_time.getTime()) / 6e4);
|
|
457
|
+
b("[durationMinutes]: ", r), t.set("eventDuration", r);
|
|
458
|
+
}), t.reset = () => {
|
|
459
|
+
for (const s in e) {
|
|
460
|
+
const i = e[s];
|
|
461
|
+
t.set(s, i);
|
|
462
|
+
}
|
|
463
|
+
}, t;
|
|
464
|
+
}
|
|
465
|
+
export {
|
|
466
|
+
N as C,
|
|
467
|
+
w as E,
|
|
468
|
+
U as N
|
|
469
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("./index-eb33703c.cjs");exports.ErrorCategory=void 0;(function(a){a.Component="component",a.Api="api",a.Auth="auth"})(exports.ErrorCategory||(exports.ErrorCategory={}));var E;(function(a){a.endtime_not_in_future="endtime_not_in_future",a.no_booking_info="no_booking_info",a.no_timeslot_selected="no_timeslot_selected",a.no_timezone_selected="no_timezone_selected",a.no_booking_id="no_booking_id",a.no_salt="no_salt",a.invalid_start_time="invalid_start_time",a.invalid_end_time="invalid_end_time",a.invalid_timezone="invalid_timezone"})(E||(E={}));var B;(function(a){a.invalid_session="invalid_session",a.general_error="general_error",a.internal_error="internal_error",a.invalid_request_error="invalid_request_error",a.timeslot_not_available="timeslot_not_available",a.provider_error="provider_error",a.not_found_error="not_found_error"})(B||(B={}));class C{constructor(){this.component=e=>{const t=exports.ErrorCategory.Component,s=`${e} Error`;return{endtime_not_in_future:(i='"endtime" can not be in the future')=>({title:s,message:i,category:t}),no_booking_info:(i="No booking info provided")=>({title:s,message:i,category:t}),no_timeslot_selected:(i="No timeslot selected")=>({title:s,message:i,category:t}),no_timezone_selected:(i="No timezone selected")=>({title:s,message:i,category:t}),no_booking_id:(i="No booking id provided")=>({title:s,message:i,category:t}),no_salt:(i="No salt provided")=>({title:s,message:i,category:t}),invalid_start_time:(i="Invalid start time")=>({title:s,message:i,category:t}),invalid_end_time:(i="Invalid end time")=>({title:s,message:i,category:t}),invalid_timezone:(i="Invalid timezone")=>({title:s,message:i,category:t})}},this.api=e=>{const t=exports.ErrorCategory.Api,s=`${e} Error`;return{invalid_session:i=>({title:s,message:i,category:t}),general_error:i=>({title:s,message:i,category:t}),internal_error:i=>({title:s,message:i,category:t}),invalid_request_error:i=>({title:s,message:i,category:t}),timeslot_not_available:i=>({title:s,message:i,category:t}),provider_error:i=>({title:s,message:i,category:t}),not_found_error:i=>({title:s,message:i,category:t})}}}}class z{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:s,configId:i,slug:n,clientId:r}){this.errors=new C,this.schedulerStore=t,this.schedulerAPIURL=e,this.sessionId=s,this.configId=i,this.slug=n,this.clientId=r}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,s,i={}){try{const n=new URL(this.schedulerAPIURL);return n.pathname=e,await(await fetch(decodeURIComponent(n.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,...i},body:s})).json()}catch(n){return{error:{message:n.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){var s,i,n,r;let t=(e==null?void 0:e.message)||(e==null?void 0:e.title)||"Something went wrong";return(e==null?void 0:e.type)==="provider_error"&&(t=((i=(s=e==null?void 0:e.provider_error)==null?void 0:s.error)==null?void 0:i.message)||((r=(n=e==null?void 0:e.provider_error)==null?void 0:n.error)==null?void 0:r.title)||"Something went wrong"),t}setConfigId(e){this.configId=e}selectDate(e){this.schedulerStore.set("selectedDate",e),this.schedulerStore.set("selectedTimeslot",null)}selectTime(e){this.schedulerStore.set("selectedTimeslot",e)}selectTimezone(e){this.schedulerStore.set("selectedTimezone",e)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e),c.instance.changeLanguage(e)}async toggleAdditionalData(e){e||await this.refetchAvailability(),this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,name:e}})}setParticipantEmail(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,email:e}})}async refetchAvailability(){const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,s=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t,i=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;return await this.getAvailability(s,i)}async resetStoreStateAndFetchAvailability(){const e=new Date,t=await this.refetchAvailability(),s=this.schedulerStore.get("availability").find(n=>new Date(n.start_time)>new Date);let i=e;return s&&(i=s.start_time),this.schedulerStore.set("selectedDate",i),this.schedulerStore.set("eventInfo",null),this.schedulerStore.set("showBookingForm",!1),this.schedulerStore.set("selectedTimeslot",null),t}async setReschedule(e){this.schedulerStore.set("isLoading",!0);const t=this.schedulerStore.state.eventInfo;return t&&this.schedulerStore.set("reschedulingEventInfo",t),this.schedulerStore.set("rescheduleBookingId",e),await this.resetStoreStateAndFetchAvailability().finally(()=>{this.schedulerStore.set("isLoading",!1)})}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async setReject(e){this.schedulerStore.set("rejectBookingId",e)}async resetCancel(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("cancelBookingId",""),this.schedulerStore.set("rejectBookingId",""),this.schedulerStore.set("cancelledEventInfo",null),e}async goBack(){this.schedulerStore.set("cancelBookingId","")}async resetConfirm(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("confirmedEventInfo",void 0),e}async bookTimeslot(e){var v;this.schedulerStore.set("isLoading",!0);const{selectedTimeslot:t,selectedTimezone:s,bookingInfo:i,selectedLanguage:n}=this.schedulerStore.state;if(!e&&!i)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_booking_info()};const r=(e==null?void 0:e.timeslot)||t;if(!r)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_timeslot_selected()};const o=e&&(e!=null&&e.timezone)?e==null?void 0:e.timezone:s;if(!o)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_timezone_selected()};const u=this.schedulerStore.get("availabilityOrderEmails");let g="";if(u.length>0){const m=r.emails;for(let p=0;p<u.length;p++)if(m.includes(u[p])){g=u[p];break}}const l=e?e==null?void 0:e.primaryParticipant:i==null?void 0:i.primaryParticipant,I=e?(e==null?void 0:e.guests)||[]:(i==null?void 0:i.guests)||[],f=e?e==null?void 0:e.additionalFields:i==null?void 0:i.additionalFields,_=this.getHeaders(),h=`/v3/scheduling/bookings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:""}`,d=await this.makeAPIRequest(decodeURIComponent(h),"POST",JSON.stringify({participants:g?[{email:g}]:void 0,additional_fields:f,additional_guests:I,guest:{...l},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:o,email_language:this.getTwoLetterLanguageCode(n)}),_);if("error"in d){this.schedulerStore.set("isLoading",!1);const m=(v=d.error)==null?void 0:v.type;let p=d.error;if(m&&m in this.errors.api("Create Booking")){const b=this.getErrorMessage(p);p=this.errors.api("Create Booking")[m](b)}return{error:p}}return"data"in d&&this.schedulerStore.set("eventInfo",d==null?void 0:d.data),this.schedulerStore.set("isLoading",!1),d}async getUISettings(){var n;this.schedulerStore.set("isLoading",!0);const e=this.getHeaders(),s=`/v3/scheduling/ui-settings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:""}`,i=await this.makeAPIRequest(s,"GET",void 0,e);if("error"in i){this.schedulerStore.set("isLoading",!1);const r=(n=i.error)==null?void 0:n.type;let o=i.error;return r&&r in this.errors.api(c.instance.t("getUISettingErrorTitle"))&&(o=this.errors.api(c.instance.t("getUISettingErrorTitle"))[r]((o==null?void 0:o.message)||(o==null?void 0:o.title)||"Something went wrong")),{error:o}}return"data"in i&&this.schedulerStore.set("configSettings",i.data),this.schedulerStore.set("isLoading",!1),i}getTwoLetterLanguageCode(e){return e.split("-")[0]}getStartTimeWithMinBookingNotice(e){var i;const t=(i=this.schedulerStore.get("configSettings"))==null?void 0:i.scheduler,s=t==null?void 0:t.min_booking_notice;return s?e+s*60:e}getEndTimeForAvailableDaysInFuture(e){var r,o;const t=new Date,s=(o=(r=this.schedulerStore.get("configSettings"))==null?void 0:r.scheduler)==null?void 0:o.available_days_in_future,i=Math.floor(c.addDaysToCurrentDate(t,s).getTime()/1e3);return Math.min(i,e)}async getAvailability(e=0,t=0){var I,f,_,S;this.schedulerStore.set("isLoading",!0);const s=new URLSearchParams,i=new Date,n=i.getTime();if(t&&t<n/1e3)return this.schedulerStore.set("isLoading",!1),{error:this.errors.component(c.instance.t("getAvailabilityErrorTitle")).endtime_not_in_future()};if(!e){const h=new Date(i.getFullYear(),i.getMonth(),1);e=Math.floor(h.getTime()/1e3)}if(e=this.getStartTimeWithMinBookingNotice(e),!t){const h=new Date(i.getFullYear(),i.getMonth()+1,0);t=Math.floor(h.getTime()/1e3)}t=this.getEndTimeForAvailableDaysInFuture(t),s.append("start_time",encodeURIComponent(e.toString())),s.append("end_time",encodeURIComponent(t.toString())),this.configId&&!this.sessionId?s.append("configuration_id",encodeURIComponent(this.configId)):this.slug&&this.clientId&&!this.sessionId&&(s.append("slug",encodeURIComponent(this.slug)),s.append("client_id",encodeURIComponent(this.clientId)));const r=this.schedulerStore.get("rescheduleBookingId");r&&s.append("booking_id",encodeURIComponent(r));const o=s.toString(),u=`/v3/scheduling/availability${o?`?${o}`:""}`,g=this.getHeaders(),l=await this.makeAPIRequest(decodeURIComponent(u),"GET",void 0,g);if("error"in l){this.schedulerStore.set("availability",[]),this.schedulerStore.set("isLoading",!1);const h=(I=l.error)==null?void 0:I.type;let d=l.error;if(h&&h in this.errors.api(c.instance.t("getAvailabilityErrorTitle"))){const v=this.getErrorMessage(d);d=this.errors.api(c.instance.t("getAvailabilityErrorTitle"))[h](v)}return{error:d}}if("data"in l){const d=(((_=(f=l.data)==null?void 0:f.time_slots)==null?void 0:_.map(m=>({...m,start_time:new Date(m.start_time*1e3),end_time:new Date(m.end_time*1e3)})))||[]).filter(m=>m.start_time.getTime()>n);this.schedulerStore.set("availability",d);const v=((S=l.data)==null?void 0:S.order)||[];this.schedulerStore.set("availabilityOrderEmails",v)}return this.schedulerStore.set("isLoading",!1),l}async cancelBooking(e,t){var o;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(c.instance.t("cancelBookingErrorTitle")).no_booking_id()};const s=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",i=`/v3/scheduling/bookings/${e}${s}`,n=this.getHeaders(),r=await this.makeAPIRequest(decodeURIComponent(i),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),n);if("error"in r){this.schedulerStore.set("isLoading",!1);const u=(o=r.error)==null?void 0:o.type;let g=r.error;if(u&&u in this.errors.api(c.instance.t("cancelBookingErrorTitle"))){const l=this.getErrorMessage(g);g=this.errors.api(c.instance.t("cancelBookingErrorTitle"))[u](l)}return{error:g}}return this.schedulerStore.set("cancelledEventInfo",{booking_id:e}),this.schedulerStore.set("rescheduleBookingId",""),this.schedulerStore.set("isLoading",!1),r}async rescheduleBooking(e,t){var L;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(c.instance.t("rescheduleBookingErrorTitle")).no_booking_id()};const s=this.errors.api(c.instance.t("rescheduleBookingErrorTitle")),i=this.errors.component(c.instance.t("rescheduleBookingErrorTitle")),{bookingInfo:n,selectedTimeslot:r,selectedTimezone:o,selectedLanguage:u}=this.schedulerStore.state,{startTime:g,endTime:l,timezone:I}=t,f=g||(r==null?void 0:r.start_time);if(!f)return{error:i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const _=l||(r==null?void 0:r.end_time);if(!_)return{error:i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const S=this.schedulerStore.get("availabilityOrderEmails");let h="";if(S.length>0){const T=(r==null?void 0:r.emails)||[];for(let k=0;k<S.length;k++)if(T.includes(S[k])){h=S[k];break}}const d=I||o;if(!d)return{error:i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')};const v=t?t==null?void 0:t.primaryParticipant:n==null?void 0:n.primaryParticipant,m=t?(t==null?void 0:t.guests)||[]:(n==null?void 0:n.guests)||[],p=t?t==null?void 0:t.additionalFields:n==null?void 0:n.additionalFields,b=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",A=`/v3/scheduling/bookings/${e}${b}`,D=this.getHeaders(),y=await this.makeAPIRequest(decodeURIComponent(A),"PATCH",JSON.stringify({start_time:f.getTime()/1e3,end_time:_.getTime()/1e3,timezone:d,additional_fields:p,guest:{...v},additional_guests:m,participants:h?[{email:h}]:void 0,email_language:this.getTwoLetterLanguageCode(u)}),D);if("error"in y){this.schedulerStore.set("isLoading",!1);const T=(L=y.error)==null?void 0:L.type;let k=y.error;if(T&&T in s){const P=this.getErrorMessage(k);k=s[T](P)}return{error:k}}const w=this.schedulerStore.get("reschedulingEventInfo");if("data"in y)this.schedulerStore.set("eventInfo",y==null?void 0:y.data);else if(w)this.schedulerStore.set("eventInfo",w);else{const T={booking_id:e};this.schedulerStore.set("eventInfo",T)}return this.schedulerStore.set("isLoading",!1),y}async updateBooking(e){var I;this.schedulerStore.set("isLoading",!0);const{bookingId:t,status:s,reason:i}=e,n=this.schedulerStore.get("organizerConfirmationSalt"),r=s==="confirmed"?c.instance.t("confirmBookingErrorTitle"):c.instance.t("rejectBookingErrorTitle");if(!t)return{error:this.errors.component(r).no_booking_id()};if(!n)return{error:this.errors.component(r).no_salt()};const o=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",u=`/v3/scheduling/bookings/${t}${o}`,g=this.getHeaders(),l=await this.makeAPIRequest(decodeURIComponent(u),"PUT",JSON.stringify({status:s,cancellation_reason:i,salt:n}),g);if("error"in l){this.schedulerStore.set("isLoading",!1);const f=(I=l.error)==null?void 0:I.type;let _=l.error;if(f&&f in this.errors.api(r)){const S=this.getErrorMessage(_);_=this.errors.api(r)[f](S)}return{error:_}}return"data"in l&&s==="confirmed"?this.schedulerStore.set("confirmedEventInfo",l==null?void 0:l.data):"request_id"in l&&s==="cancelled"&&this.schedulerStore.set("cancelledEventInfo",{booking_id:t}),this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("isLoading",!1),l}}function M(a={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:!1,nylasBranding:!0,...a};c.debug("[defaultNylasStoreState]: ",e);const t=c.createStore(e);return t.onChange("availability",s=>{c.debug("[availability]: ",s);const i=s.map(o=>o.start_time);c.debug("[selectableDates]: ",i),t.set("selectableDates",i);const n=s[0];if(!n)return;const r=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);c.debug("[durationMinutes]: ",r),t.set("eventDuration",r)}),t.reset=()=>{for(const s in e){const i=e[s];t.set(s,i)}},t}exports.CreateNylasSchedulerStore=M;exports.NylaSchedulerAPIConnector=z;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-eb33703c.cjs"),r=require("./index-6d9eeb53-b2a6d09f.cjs");require("./index-53420959-fcf45780.cjs");require("react");require("react-dom");const l=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;flex-direction:column;gap:4px;font-family:var(--nylas-font-family);font-size:16px;color:var(--nylas-base-800)}label.error{color:var(--nylas-error)}label span.required{color:var(--nylas-error);padding:0 0.25rem}label p{margin:0;display:flex;gap:4px;align-items:center}label .error{color:var(--nylas-error)}textarea{display:flex;height:48px;padding-left:16px;align-items:center;gap:8px;align-self:stretch;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-300);background:var(--nylas-base-0);width:-webkit-fill-available;color:var(--nylas-base-900);font-size:16px;font-style:normal;font-weight:400;line-height:150%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}',n=l,t=class{constructor(a){e.registerInstance(this,a),this.nylasFormInputChanged=e.createEvent(this,"nylasFormInputChanged",7),this.name="textarea",this.defaultValue="",this.label="",this.placeholder="",this.required=!1,this.readOnly=!1,this.autoFocus=!1,this.maxLength=255,this.type="multi_line_text",this.tooltip="",this.value="",this.error=""}componentWillLoad(){this.value=r.sanitizeHtml$1(this.defaultValue)}handleBookingFormSubmitted(a){this.validate(this.value),this.error&&a.preventDefault()}handleInput(a){const s=a.target;this.value=r.sanitizeHtml$1(s.value),this.nylasFormInputChanged.emit({value:this.value,name:this.name,error:this.error,label:this.label,type:this.type})}validate(a){this.required&&!a?this.error=`${this.label} is required.`:a.length>this.maxLength?this.error=`${this.label} cannot exceed ${this.maxLength} characters.`:this.error=""}render(){return e.h("label",{key:"b7a5eaff4d1b4b5a5e28ff77be0f355497c63add",part:"tc__label",class:{error:!!this.error}},e.h("p",{key:"3f07cee33052ac9209f2ad5e29d4fe58a53d0cde"},e.h("span",{key:"538f808ae20cd4ec60627d9575e8e3ad486c01db",class:"label"},this.label),this.required&&e.h("span",{class:"required"},"*"),this.tooltip&&e.h("tooltip-component",null,e.h("info-icon",{slot:"tooltip-icon"}),e.h("span",{slot:"tooltip-content"},this.tooltip))),e.h("textarea",{key:"ce6b7cb2b2a024ee259e9cc970f9819bb258645d",name:this.name,placeholder:this.placeholder,readOnly:this.readOnly,autoFocus:this.autoFocus,value:this.value,maxLength:this.maxLength,onInput:a=>this.handleInput(a),class:{error:!!this.error},part:"tc__textarea"}),this.error&&e.h("span",{class:"error help-text"},this.error))}};t.style=n;exports.textarea_component=t;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { r as s, c as l, h as a } from "./index-5ccfd9df.js";
|
|
2
|
+
import { s as r } from "./index-6d9eeb53-58c8980a.js";
|
|
3
|
+
import "./index-53420959-5fc8ad2b.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "react-dom";
|
|
6
|
+
const n = ':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;flex-direction:column;gap:4px;font-family:var(--nylas-font-family);font-size:16px;color:var(--nylas-base-800)}label.error{color:var(--nylas-error)}label span.required{color:var(--nylas-error);padding:0 0.25rem}label p{margin:0;display:flex;gap:4px;align-items:center}label .error{color:var(--nylas-error)}textarea{display:flex;height:48px;padding-left:16px;align-items:center;gap:8px;align-self:stretch;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-300);background:var(--nylas-base-0);width:-webkit-fill-available;color:var(--nylas-base-900);font-size:16px;font-style:normal;font-weight:400;line-height:150%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}', i = n, o = class {
|
|
7
|
+
constructor(e) {
|
|
8
|
+
s(this, e), this.nylasFormInputChanged = l(this, "nylasFormInputChanged", 7), this.name = "textarea", this.defaultValue = "", this.label = "", this.placeholder = "", this.required = !1, this.readOnly = !1, this.autoFocus = !1, this.maxLength = 255, this.type = "multi_line_text", this.tooltip = "", this.value = "", this.error = "";
|
|
9
|
+
}
|
|
10
|
+
componentWillLoad() {
|
|
11
|
+
this.value = r(this.defaultValue);
|
|
12
|
+
}
|
|
13
|
+
handleBookingFormSubmitted(e) {
|
|
14
|
+
this.validate(this.value), this.error && e.preventDefault();
|
|
15
|
+
}
|
|
16
|
+
handleInput(e) {
|
|
17
|
+
const t = e.target;
|
|
18
|
+
this.value = r(t.value), this.nylasFormInputChanged.emit({
|
|
19
|
+
value: this.value,
|
|
20
|
+
name: this.name,
|
|
21
|
+
error: this.error,
|
|
22
|
+
label: this.label,
|
|
23
|
+
type: this.type
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
validate(e) {
|
|
27
|
+
this.required && !e ? this.error = `${this.label} is required.` : e.length > this.maxLength ? this.error = `${this.label} cannot exceed ${this.maxLength} characters.` : this.error = "";
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return a("label", { key: "b7a5eaff4d1b4b5a5e28ff77be0f355497c63add", part: "tc__label", class: { error: !!this.error } }, a("p", { key: "3f07cee33052ac9209f2ad5e29d4fe58a53d0cde" }, a("span", { key: "538f808ae20cd4ec60627d9575e8e3ad486c01db", class: "label" }, this.label), this.required && a("span", { class: "required" }, "*"), this.tooltip && a("tooltip-component", null, a("info-icon", { slot: "tooltip-icon" }), a("span", { slot: "tooltip-content" }, this.tooltip))), a("textarea", { key: "ce6b7cb2b2a024ee259e9cc970f9819bb258645d", name: this.name, placeholder: this.placeholder, readOnly: this.readOnly, autoFocus: this.autoFocus, value: this.value, maxLength: this.maxLength, onInput: (e) => this.handleInput(e), class: { error: !!this.error }, part: "tc__textarea" }), this.error && a("span", { class: "error help-text" }, this.error));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
o.style = i;
|
|
34
|
+
export {
|
|
35
|
+
o as textarea_component
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-eb33703c.cjs");require("react");require("react-dom");const s=".time-period-selector.sc-time-period-selector{display:grid;gap:0.5rem;grid-template-columns:auto 1fr}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector,.time-period-selector.sc-time-period-selector input-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.sc-time-period-selector{width:116px}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{width:84px;display:flex;align-items:center}.time-period-selector.sc-time-period-selector select-dropdown#time-period.sc-time-period-selector::part(sd_dropdown-button){width:100%}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown){width:inherit;height:100%}.time-period-selector.sc-time-period-selector input-dropdown#time-number.sc-time-period-selector::part(id_dropdown-input){border:none;border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-input){padding:17px;gap:1rem}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-content){width:100%;max-height:200px}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown){width:inherit}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-button){padding:1rem;gap:1rem;justify-content:space-between}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-content){width:100%;max-height:200px}",n=s,l={hours:"hour",days:"day",weeks:"week",months:"month"},o=class{constructor(t){i.registerInstance(this,t),this.timePeriodChanged=i.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(this.defaultSelectedPeriod||"hour").map(e=>({label:e.toString(),value:e.toString()})),this.timePeriodOptions=this.timePeriods.map(e=>({label:e,value:e}))}defaultSelectedPeriodChangedHandler(t){this.selectedPeriod=t;const e=l[t]??t;this.updateNumberOptionsAndSelectedNumber(e)}defaultSelectedNumberChangedHandler(t){this.selectedNumber=t}timePeriodsChangedHandler(t){this.timePeriodOptions=t.map(e=>({label:e,value:e}))}calculateOptions(t){switch(t){case"hour":return Array.from({length:23},(e,r)=>r+1);case"minute":return Array.from({length:13},(e,r)=>r*5);case"day":return Array.from({length:30},(e,r)=>r+1);case"week":return Array.from({length:4},(e,r)=>r+1);case"month":return Array.from({length:12},(e,r)=>r+1);default:return[]}}inputOptionChangedHandler(t){i.debug("time-period-selector","inputOptionChangedHandler",t.detail);const{value:e,name:r}=t.detail;r==="time-number"&&(this.selectedNumber=e?parseInt(e):this.defaultSelectedNumber);const d={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(d)}nylasFormDropdownChangedHandler(t){i.debug("time-period-selector","nylasFormDropdownChangedHandler",t.detail);const{value:e,name:r}=t.detail;r==="time-period"?(this.selectedPeriod=e,this.updateNumberOptionsAndSelectedNumber(e)):r==="time-number"&&(this.selectedNumber=parseInt(e));const d={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(d)}updateNumberOptionsAndSelectedNumber(t){const e=this.calculateOptions(t);this.numberOptions=e.map(r=>({label:r.toString(),value:r.toString()})),this.selectedNumber=parseInt(this.numberOptions[0].value)}render(){return i.h("div",{key:"2e02e602c84d10f1c2ed8dc8e6a989f7ec4c22f8",class:"time-period-selector"},i.h("input-dropdown",{key:"aaf9b85eb568c308385d41127c91c4e51261cb2f",id:"time-number",name:"time-number",inputValue:this.selectedNumber.toString(),exportparts:"id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content",options:this.numberOptions,defaultInputOption:this.numberOptions.find(t=>t.value==this.selectedNumber.toString())??this.numberOptions[0]}),i.h("select-dropdown",{key:"5537a3e02a876cbf49f5ace4c8f3bb153ed6b3ce",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(t=>t.value==this.selectedPeriod)??this.timePeriodOptions[0],withSearch:!1}))}get host(){return i.getElement(this)}static get watchers(){return{defaultSelectedPeriod:["defaultSelectedPeriodChangedHandler"],defaultSelectedNumber:["defaultSelectedNumberChangedHandler"],timePeriods:["timePeriodsChangedHandler"]}}};o.style=n;exports.time_period_selector=o;
|