@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,380 @@
|
|
|
1
|
+
import { d as o, e as f } from "./index-5ccfd9df.js";
|
|
2
|
+
import { X as u, Z as d } from "./index.es-c9454237-00ccd1e6.js";
|
|
3
|
+
class S {
|
|
4
|
+
constructor(t, e) {
|
|
5
|
+
this.nylasAuth = t, this.nylasAuthStore = e;
|
|
6
|
+
}
|
|
7
|
+
async validateSession() {
|
|
8
|
+
const t = await this.isAccessTokenValid();
|
|
9
|
+
if (!t)
|
|
10
|
+
this.logout();
|
|
11
|
+
else {
|
|
12
|
+
let e = await this.nylasAuth.getTokenInfo();
|
|
13
|
+
if (e) {
|
|
14
|
+
const a = Math.floor(Date.now() / 1e3);
|
|
15
|
+
if (e.expires_in && e.expires_in - a < 3e5 && (o("[NylasAuthConnectorMixin] Refreshing access token"), e = await this.nylasAuth.refreshAccessToken(), !e)) {
|
|
16
|
+
o("[NylasAuthConnectorMixin] Token is expired and could not be refreshed. Logging out."), this.logout();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.nylasAuthStore.state.tokenInfo = e;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
this.nylasAuthStore.state.isAuthenticated = t;
|
|
23
|
+
}
|
|
24
|
+
async isAuthenticated() {
|
|
25
|
+
return this.nylasAuth.isAuthenticated();
|
|
26
|
+
}
|
|
27
|
+
async getTokenInfo() {
|
|
28
|
+
return this.nylasAuth.getTokenInfo();
|
|
29
|
+
}
|
|
30
|
+
async isAccessTokenValid() {
|
|
31
|
+
return this.nylasAuth.isAccessTokenValid();
|
|
32
|
+
}
|
|
33
|
+
async logout() {
|
|
34
|
+
await this.nylasAuth.logout();
|
|
35
|
+
}
|
|
36
|
+
async getHostedAuthRedirectURL(t, e, s) {
|
|
37
|
+
return this.nylasAuth.getHostedAuthRedirectURL(t, e, s);
|
|
38
|
+
}
|
|
39
|
+
async manageHostedAuthCodeExchange(t) {
|
|
40
|
+
const s = new URL(t).searchParams.get("code");
|
|
41
|
+
if (s) {
|
|
42
|
+
const a = await this.nylasAuth.exchangeAuthCodeForTokenInfo(s);
|
|
43
|
+
if (a)
|
|
44
|
+
return this.nylasAuthStore.state.tokenInfo = a, this.nylasAuthStore.state.isAuthenticated = !0, a;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class A {
|
|
50
|
+
constructor(t, e, s) {
|
|
51
|
+
this.nylasAuth = t, this.nylasAuthStore = e, this.nylasMailboxStore = s;
|
|
52
|
+
}
|
|
53
|
+
async getMessages() {
|
|
54
|
+
var n;
|
|
55
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
56
|
+
throw new Error("Not authenticated");
|
|
57
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
58
|
+
throw new Error("Missing message:read-only scope");
|
|
59
|
+
this.nylasMailboxStore.state.state = "loading";
|
|
60
|
+
const t = this.nylasMailboxStore.state.messgeQueryParams, e = new URLSearchParams();
|
|
61
|
+
for (const i in t) {
|
|
62
|
+
const l = (n = t[i]) == null ? void 0 : n.toString();
|
|
63
|
+
l && e.append(i, l);
|
|
64
|
+
}
|
|
65
|
+
const s = `/v3/grants/me/messages?${e.toString()}`, a = await this.nylasAuth.nylasAPIRequest(s);
|
|
66
|
+
if (u(a))
|
|
67
|
+
throw new d(a.error);
|
|
68
|
+
const r = a.data;
|
|
69
|
+
return this.nylasMailboxStore.state.messages = r, this.nylasMailboxStore.state.state = "ready", r;
|
|
70
|
+
}
|
|
71
|
+
async getThreadMessages(t) {
|
|
72
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
73
|
+
throw new Error("Not authenticated");
|
|
74
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
75
|
+
throw new Error("Missing message:read-only scope");
|
|
76
|
+
const e = await this.nylasAuth.nylasAPIRequest(`/v3/grants/me/messages?thread_id=${t}&fields=include_headers`);
|
|
77
|
+
if (u(e))
|
|
78
|
+
throw new d(e.error);
|
|
79
|
+
const s = e.data;
|
|
80
|
+
return this.nylasMailboxStore.state.messages = s, s;
|
|
81
|
+
}
|
|
82
|
+
downloadMessageAttachments(t) {
|
|
83
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
84
|
+
throw new Error("Not authenticated");
|
|
85
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
86
|
+
throw new Error("Missing message:read-only scope");
|
|
87
|
+
const e = [], s = t.attachments || [];
|
|
88
|
+
for (const a of s) {
|
|
89
|
+
const r = this.nylasAuth.nylasDownloadFileRequest(`/v3/grants/me/attachments/${a.id}?message_id=${t.id}`);
|
|
90
|
+
e.push(r);
|
|
91
|
+
}
|
|
92
|
+
return e;
|
|
93
|
+
}
|
|
94
|
+
async summarizeText(t) {
|
|
95
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
96
|
+
throw new Error("Not authenticated");
|
|
97
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
98
|
+
throw new Error("Missing message:read-only scope");
|
|
99
|
+
const e = await this.nylasAuth.nylasAPIRequest("/v3/grants/me/mailbox/summarize", "POST", {
|
|
100
|
+
message: {
|
|
101
|
+
body: t
|
|
102
|
+
}
|
|
103
|
+
}, !0, this.nylasAuth.config.elementsApiUri);
|
|
104
|
+
if (u(e))
|
|
105
|
+
throw new d(e.error);
|
|
106
|
+
return e.data.summary;
|
|
107
|
+
}
|
|
108
|
+
async textToSpeech(t, e) {
|
|
109
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
110
|
+
throw new Error("Not authenticated");
|
|
111
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
112
|
+
throw new Error("Missing message:read-only scope");
|
|
113
|
+
return this.nylasAuth.nylasAPIRequest("/v3/grants/me/mailbox/tts", "POST", {
|
|
114
|
+
text: t
|
|
115
|
+
}, !1, this.nylasAuth.config.elementsApiUri, {
|
|
116
|
+
...e ? { signal: e == null ? void 0 : e.signal } : {}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
class T {
|
|
121
|
+
constructor(t, e, s, a) {
|
|
122
|
+
this.nylasAuth = t, this.nylasAuthStore = e, this.nylasMailboxStore = s, this.router = a;
|
|
123
|
+
}
|
|
124
|
+
async getThreads(t, e = "overwrite", s = !0) {
|
|
125
|
+
var y;
|
|
126
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
127
|
+
throw new Error("Not authenticated");
|
|
128
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
129
|
+
throw new Error("Missing thread:read-only scope");
|
|
130
|
+
s && (this.nylasMailboxStore.state.state = "loading");
|
|
131
|
+
const a = t || this.nylasMailboxStore.state.threadsQueryParams, r = new URLSearchParams();
|
|
132
|
+
for (const g in a) {
|
|
133
|
+
const c = (y = a[g]) == null ? void 0 : y.toString();
|
|
134
|
+
typeof c < "u" && c !== null && r.append(g, c);
|
|
135
|
+
}
|
|
136
|
+
a.search_query_native ? this.router.navigate(`/?query=${a.search_query_native}`, !0) : this.nylasMailboxStore.state.threadsQueryParams.search_query_native && !a.search_query_native && this.router.navigate("/", !0), a.page_token || (this.nylasMailboxStore.state.previousThreadPageTokens = []), this.nylasMailboxStore.state.threadsQueryParams = a;
|
|
137
|
+
const n = `/v3/grants/me/threads?${r.toString()}`, i = await this.nylasAuth.nylasAPIRequest(n);
|
|
138
|
+
if (u(i))
|
|
139
|
+
throw new d(i.error);
|
|
140
|
+
const l = i.data;
|
|
141
|
+
switch (e) {
|
|
142
|
+
case "prepend":
|
|
143
|
+
this.nylasMailboxStore.state.threads = [...l, ...this.nylasMailboxStore.state.threads];
|
|
144
|
+
break;
|
|
145
|
+
case "append":
|
|
146
|
+
this.nylasMailboxStore.state.threads = [...this.nylasMailboxStore.state.threads, ...l];
|
|
147
|
+
break;
|
|
148
|
+
case "overwrite":
|
|
149
|
+
default:
|
|
150
|
+
this.nylasMailboxStore.state.threads = l;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
return i.next_cursor ? this.nylasMailboxStore.state.nextThreadPageToken = i.next_cursor : this.nylasMailboxStore.state.nextThreadPageToken = null, s && (this.nylasMailboxStore.state.state = "ready"), l;
|
|
154
|
+
}
|
|
155
|
+
async getThread(t) {
|
|
156
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
157
|
+
throw new Error("Not authenticated");
|
|
158
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
159
|
+
throw new Error("Missing thread:read-only scope");
|
|
160
|
+
const e = this.nylasMailboxStore.state.threads.find((n) => n.id === t);
|
|
161
|
+
if (e)
|
|
162
|
+
return e;
|
|
163
|
+
this.nylasMailboxStore.state.state = "loading";
|
|
164
|
+
const s = `/v3/grants/me/threads/${t}`, a = await this.nylasAuth.nylasAPIRequest(s);
|
|
165
|
+
if (u(a))
|
|
166
|
+
throw new d(a.error);
|
|
167
|
+
const r = a.data;
|
|
168
|
+
return this.nylasMailboxStore.state.threads = this.nylasMailboxStore.state.threads.map((n) => n.id === r.id ? r : n), this.nylasMailboxStore.state.state = "ready", r;
|
|
169
|
+
}
|
|
170
|
+
async nextThreadPage(t = "overwrite", e = !0) {
|
|
171
|
+
if (!this.nylasMailboxStore.state.nextThreadPageToken)
|
|
172
|
+
throw new Error("No next page token");
|
|
173
|
+
this.nylasMailboxStore.state.previousThreadPageTokens = Array.from(/* @__PURE__ */ new Set([...this.nylasMailboxStore.state.previousThreadPageTokens, this.nylasMailboxStore.state.threadsQueryParams.page_token ?? null]));
|
|
174
|
+
const s = this.nylasMailboxStore.state.nextThreadPageToken;
|
|
175
|
+
return this.getThreads({
|
|
176
|
+
...this.nylasMailboxStore.state.threadsQueryParams,
|
|
177
|
+
page_token: s
|
|
178
|
+
}, t, e);
|
|
179
|
+
}
|
|
180
|
+
async previousThreadPage(t = "overwrite", e = !0) {
|
|
181
|
+
if (!this.nylasMailboxStore.state.previousThreadPageTokens.length)
|
|
182
|
+
throw new Error("No previous page token");
|
|
183
|
+
const s = [...this.nylasMailboxStore.state.previousThreadPageTokens], a = s.pop();
|
|
184
|
+
return this.nylasMailboxStore.state.previousThreadPageTokens = s, this.getThreads({
|
|
185
|
+
...this.nylasMailboxStore.state.threadsQueryParams,
|
|
186
|
+
page_token: a ?? void 0
|
|
187
|
+
}, t, e);
|
|
188
|
+
}
|
|
189
|
+
updateThreadQueryParams(t) {
|
|
190
|
+
this.nylasMailboxStore.state.threadsQueryParams = {
|
|
191
|
+
...this.nylasMailboxStore.state.threadsQueryParams,
|
|
192
|
+
...t
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
back() {
|
|
196
|
+
this.router.navigate("/", !0), this.nylasMailboxStore.state.selectedThread = null;
|
|
197
|
+
}
|
|
198
|
+
unSelectThread() {
|
|
199
|
+
this.nylasMailboxStore.state.selectedThread = null;
|
|
200
|
+
}
|
|
201
|
+
async selectThread(t) {
|
|
202
|
+
this.router.navigate(`/thread/${t.id}`, !0), this.nylasMailboxStore.state.selectedThread = t, t.unread && this.markThreadAsRead(t).catch((e) => {
|
|
203
|
+
o("Error marking thread as read", e);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
async markThreadAsRead(t) {
|
|
207
|
+
return this.updateThread(t, { unread: !1 });
|
|
208
|
+
}
|
|
209
|
+
async updateThread(t, e) {
|
|
210
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
211
|
+
throw new Error("Not authenticated");
|
|
212
|
+
if (!this.nylasAuth.hasScopeByType("email", "modify"))
|
|
213
|
+
throw new Error("Missing thread:modify scope");
|
|
214
|
+
const s = `/v3/grants/me/threads/${t.id}`, a = await this.nylasAuth.nylasAPIRequest(s, "PUT", e);
|
|
215
|
+
if (u(a))
|
|
216
|
+
throw new d(a.error);
|
|
217
|
+
const r = a.data;
|
|
218
|
+
return this.nylasMailboxStore.state.threads = this.nylasMailboxStore.state.threads.map((n) => n.id === r.id ? r : n), this.nylasMailboxStore.state.selectedThread = r, r;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
class x {
|
|
222
|
+
constructor(t, e, s) {
|
|
223
|
+
this.nylasAuth = t, this.nylasAuthStore = e, this.nylasMailboxStore = s;
|
|
224
|
+
}
|
|
225
|
+
async getFolders() {
|
|
226
|
+
if (!this.nylasAuthStore.state.isAuthenticated)
|
|
227
|
+
throw new Error("Not authenticated");
|
|
228
|
+
if (!this.nylasAuth.hasScopeByType("email", ["read-only", "modify"]))
|
|
229
|
+
throw new Error("Missing thread:read-only scope");
|
|
230
|
+
this.nylasMailboxStore.state.state = "loading";
|
|
231
|
+
const t = "/v3/grants/me/folders", e = await this.nylasAuth.nylasAPIRequest(t);
|
|
232
|
+
if (u(e))
|
|
233
|
+
throw new d(e.error);
|
|
234
|
+
const s = e.data;
|
|
235
|
+
return this.nylasMailboxStore.state.folders = s, this.nylasMailboxStore.state.state = "ready", s;
|
|
236
|
+
}
|
|
237
|
+
async selectFolder(t) {
|
|
238
|
+
this.nylasMailboxStore.state.threadsQueryParams = {
|
|
239
|
+
in: t.id,
|
|
240
|
+
...this.nylasMailboxStore.state.threadsQueryParams || {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
class m extends Event {
|
|
245
|
+
constructor(t, e) {
|
|
246
|
+
super(t, e), this.oldURL = e.oldURL, this.newURL = e.newURL;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
class P {
|
|
250
|
+
constructor() {
|
|
251
|
+
this.routeChangeListeners = [], o("HashRouter constructor");
|
|
252
|
+
}
|
|
253
|
+
destroy() {
|
|
254
|
+
o("HashRouter destroy"), window.removeEventListener("hashchange", this.onRouteChange.bind(this));
|
|
255
|
+
}
|
|
256
|
+
init() {
|
|
257
|
+
if (o("HashRouter init"), window.addEventListener("hashchange", this.onRouteChange.bind(this)), typeof HashChangeEvent < "u") {
|
|
258
|
+
const t = new HashChangeEvent("hashchange", { oldURL: "", newURL: window.location.href });
|
|
259
|
+
this.onRouteChange(t);
|
|
260
|
+
} else {
|
|
261
|
+
const t = new m("hashchange", { oldURL: "", newURL: window.location.href });
|
|
262
|
+
this.onRouteChange(t);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
addRouteChangeListener(t, e) {
|
|
266
|
+
o("HashRouter addRouteChangeListener"), this.routeChangeListeners.push([t, e]);
|
|
267
|
+
}
|
|
268
|
+
navigate(t, e) {
|
|
269
|
+
if (o("HashRouter navigate"), e)
|
|
270
|
+
return window.history.pushState(null, "", `#${t}`);
|
|
271
|
+
window.location.hash = t;
|
|
272
|
+
}
|
|
273
|
+
setRoute(t) {
|
|
274
|
+
o("HashRouter setRoute"), window.location.hash = t;
|
|
275
|
+
}
|
|
276
|
+
matchRoute(t, e) {
|
|
277
|
+
const s = t.split("/"), a = e.split("/");
|
|
278
|
+
if (o(`HashRouter matchRoute route=${t} path=${e}`, { routeParts: s, pathParts: a }), s[1] === "" && a[0] === "")
|
|
279
|
+
return !0;
|
|
280
|
+
if (s.length !== a.length)
|
|
281
|
+
return !1;
|
|
282
|
+
for (let r = 0; r < s.length; r++) {
|
|
283
|
+
const n = s[r], i = a[r];
|
|
284
|
+
if (!n.startsWith(":") && n !== i)
|
|
285
|
+
return !1;
|
|
286
|
+
}
|
|
287
|
+
return !0;
|
|
288
|
+
}
|
|
289
|
+
getRouteParams(t) {
|
|
290
|
+
o("HashRouter getRouteParams");
|
|
291
|
+
const e = {}, s = t.split("/"), a = window.location.hash.split("/");
|
|
292
|
+
return s.forEach((r, n) => {
|
|
293
|
+
if (r.startsWith(":")) {
|
|
294
|
+
const i = r.substring(1);
|
|
295
|
+
e[i] = a[n];
|
|
296
|
+
}
|
|
297
|
+
}), e;
|
|
298
|
+
}
|
|
299
|
+
getRouteWithParams(t, e) {
|
|
300
|
+
o("HashRouter getRouteWithParams");
|
|
301
|
+
let s = t;
|
|
302
|
+
return Object.keys(e).forEach((a) => {
|
|
303
|
+
s = s.replace(`:${a}`, e[a]);
|
|
304
|
+
}), s;
|
|
305
|
+
}
|
|
306
|
+
getRoute() {
|
|
307
|
+
return o("HashRouter getRoute"), window.location.hash;
|
|
308
|
+
}
|
|
309
|
+
onRouteChange(t) {
|
|
310
|
+
this.routeChangeListeners.forEach(async ([e, s]) => {
|
|
311
|
+
const a = t.newURL.indexOf("#") === -1 ? "" : t.newURL.substring(t.newURL.indexOf("#") + 1);
|
|
312
|
+
if (o(`HashRouter onRouteChange route=${e} path=${a}`, { event: t }), !this.matchRoute(e, a)) {
|
|
313
|
+
o(`HashRouter onRouteChange route=${e} path=${a} does not match`);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const r = this.getRouteParams(e);
|
|
317
|
+
await s(e, a, r);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
getBasePath() {
|
|
321
|
+
return o("HashRouter getBasePath"), "";
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function b(h = {}) {
|
|
325
|
+
const t = {
|
|
326
|
+
isAuthenticated: !1,
|
|
327
|
+
tokenInfo: null,
|
|
328
|
+
state: "ready",
|
|
329
|
+
...h
|
|
330
|
+
}, e = f(t);
|
|
331
|
+
return e.reset = () => {
|
|
332
|
+
for (const s in t) {
|
|
333
|
+
const a = t[s];
|
|
334
|
+
e.set(s, a);
|
|
335
|
+
}
|
|
336
|
+
}, e;
|
|
337
|
+
}
|
|
338
|
+
function M(h = {}) {
|
|
339
|
+
const t = {
|
|
340
|
+
state: "ready",
|
|
341
|
+
messages: [],
|
|
342
|
+
threads: [],
|
|
343
|
+
folders: [],
|
|
344
|
+
selectedThread: null,
|
|
345
|
+
nextThreadPageToken: null,
|
|
346
|
+
previousThreadPageTokens: [],
|
|
347
|
+
searchQuery: "",
|
|
348
|
+
hasNextThreadPage: !1,
|
|
349
|
+
hasPreviousThreadPage: !1,
|
|
350
|
+
selectedFolder: "inbox",
|
|
351
|
+
threadsQueryParams: {
|
|
352
|
+
in: "inbox"
|
|
353
|
+
},
|
|
354
|
+
messgeQueryParams: {
|
|
355
|
+
fields: "include_headers"
|
|
356
|
+
},
|
|
357
|
+
...h
|
|
358
|
+
}, e = f({ ...t });
|
|
359
|
+
return e.onChange("nextThreadPageToken", (s) => {
|
|
360
|
+
e.set("hasNextThreadPage", s !== null);
|
|
361
|
+
}), e.onChange("previousThreadPageTokens", (s) => {
|
|
362
|
+
e.set("hasPreviousThreadPage", s.length > 0);
|
|
363
|
+
}), e.onChange("threadsQueryParams", (s) => {
|
|
364
|
+
e.set("selectedFolder", s.in || "inbox"), e.set("searchQuery", s.search_query_native || "");
|
|
365
|
+
}), e.reset = () => {
|
|
366
|
+
for (const s in t) {
|
|
367
|
+
const a = t[s];
|
|
368
|
+
e.set(s, a);
|
|
369
|
+
}
|
|
370
|
+
}, e;
|
|
371
|
+
}
|
|
372
|
+
export {
|
|
373
|
+
b as C,
|
|
374
|
+
P as H,
|
|
375
|
+
S as N,
|
|
376
|
+
M as a,
|
|
377
|
+
T as b,
|
|
378
|
+
A as c,
|
|
379
|
+
x as d
|
|
380
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-eb33703c.cjs");require("react");require("react-dom");const r=':host{display:block;width:inherit;--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}.dropdown{display:inline-block;width:100%;position:relative}.dropdown .dropdown-label{display:flex;align-items:center;gap:0.25rem;color:var(--nylas-base-800)}.dropdown span.error{color:var(--nylas-error);font-size:14px}.dropbtn{width:inherit;height:48px;color:black;padding:0.5rem;font-size:1rem;cursor:pointer;display:flex;gap:0.5rem;justify-content:space-between;align-items:center;background:transparent;border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.dropbtn.focus{background:transparent}.dropbtn.error{border:1px solid var(--nylas-error)}.dropbtn:hover,.dropbtn:active{border:1px solid var(--nylas-primary)}.dropbtn:active{outline:2px solid var(--nylas-primary)}.dropbtn span.open{transform:rotate(90deg)}.dropbtn span.closed{transform:rotate(270deg)}.dropdown-content{display:block;margin-top:0.5rem;background-color:var(--nylas-base-0);width:100%;max-height:336px;overflow:auto;z-index:1;border-radius:4px;position:absolute;top:72px;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.0509803922);box-shadow:0px 10px 15px -3px rgba(0, 0, 0, 0.1019607843)}.dropdown-content ul{padding:0;list-style-type:none;color:var(--nylas-base-900);max-height:336px}.dropdown-content ul li{padding:16px, 12px, 16px, 12px;color:black;padding:12px 16px;text-decoration:none;display:block;font-family:inherit;font-size:14px;font-weight:400;line-height:20px;letter-spacing:0px;text-align:left;cursor:pointer}.dropdown-content ul li:hover,.dropdown-content ul li:focus{background-color:var(--nylas-base-100)}.dropdown-content ul li label{display:flex;align-items:center;gap:0.5rem}.dropdown-content ul li label input{margin:0}.selected-options{display:flex;flex-wrap:wrap;gap:0.5rem;padding:0.5rem 0;margin-top:0.25rem;background:var(--nylas-base-0)}.selected-options .selected-option{display:flex;align-items:center;gap:0.5rem;padding:4px 8px;border-radius:var(--nylas-border-radius-2x);background:var(--nylas-base-100);color:var(--nylas-base-800);font-size:16px;font-weight:500;line-height:1.5rem;letter-spacing:0.5px}.selected-options .selected-option button{background:transparent;border:none;cursor:pointer;padding:0}.selected-options .selected-option button:hover{color:var(--nylas-primary)}',l=r,o=class{constructor(e){s.registerInstance(this,e),this.selectedOptionsChanged=s.createEvent(this,"selectedOptionsChanged",7),this.name=void 0,this.label=void 0,this.options=[],this.error="",this.availableOptions=this.options,this.isOpen=!1,this.ariaActivedescendant="",this.shouldFocusFirstOption=!1}componentDidRender(){s.debug("multi-select-dropdown","componentDidRender"),this.isOpen&&this.shouldFocusFirstOption&&(this.ariaActivedescendant=this.availableOptions[0].value,this.focusOption(0),this.shouldFocusFirstOption=!1)}handleOutsideClick(e){!e.composedPath().includes(this.el)&&this.isOpen&&(this.isOpen=!1)}selectOption(e){this.availableOptions=this.availableOptions.map(t=>(t.value===e.value&&(t.selected=!e.selected),t));const a=this.availableOptions.filter(t=>t.selected).map(t=>t.value);this.selectedOptionsChanged.emit({value:a,name:this.name})}toggleDropdown(){this.isOpen=!this.isOpen,this.isOpen?this.shouldFocusFirstOption=!0:this.ariaActivedescendant=""}handleSelectButtonKeyDown(e){switch(e.key){case"ArrowDown":case"Enter":e.preventDefault(),this.isOpen||this.toggleDropdown();break;case"Escape":this.isOpen=!1;break}}handleListboxKeydown(e){const a=this.availableOptions,t=a.findIndex(n=>n.value===this.ariaActivedescendant);switch(e.key){case"ArrowDown":case"Tab":if(e.shiftKey){e.preventDefault();const i=t-1>=0?t-1:a.length-1;this.ariaActivedescendant=a[i].value,this.focusOption(i)}else{e.preventDefault();const i=t+1<a.length?t+1:0;this.ariaActivedescendant=a[i].value,this.focusOption(i)}break;case"ArrowUp":e.preventDefault();const n=t-1>=0?t-1:a.length-1;this.ariaActivedescendant=a[n].value,this.focusOption(n);break;case"Enter":e.preventDefault(),this.ariaActivedescendant&&this.selectOption(a[t]);break;case"Escape":this.isOpen=!1;break}}focusOption(e){var i;const a=this.availableOptions[e];if(!a)return;const t=a.value,n=(i=this.el.shadowRoot)==null?void 0:i.getElementById(t);n&&(n.focus(),n.scrollIntoView({behavior:"smooth",block:"nearest"}))}getSelectedOptions(){return this.availableOptions.filter(e=>e.selected)}renderOption(e){return s.h("li",{key:e.value,id:e.value,role:"option",tabindex:"0","aria-selected":e.selected?"true":"false",onClick:a=>{a.stopImmediatePropagation(),this.selectOption(e)},class:{selected:!!e.selected}},s.h("label",{htmlFor:e.value},s.h("input",{"aria-hidden":"true",id:e.value,type:"checkbox",checked:e.selected}),s.h("span",null,e.label)))}render(){var e,a;return s.h(s.Host,{key:"ebdbb5947ea3046827153a6b015118d5e6cd5fc6"},s.h("div",{key:"7e730c4b5bc924dbe6fd4214137a15bd65db1db7",class:"dropdown",part:"msd_dropdown"},s.h("label",{key:"7489c7b95c0a68768f0f1d3142510a54e77a11f0",class:"dropdown-label"},this.label,s.h("slot",{key:"aa58521e004ae82463426b8fc130c36c7a2f9464",name:"label-icon","aria-hidden":"true"})),s.h("button",{key:"b1f2b45fb76c2b24ae8ed6c72c361657d2431414",name:this.name,part:`msd_dropdown-button ${this.error?"msd_dropdown-button--error":""}`,class:{dropbtn:!0,open:this.isOpen,error:!!this.error},onClick:()=>this.toggleDropdown(),"aria-haspopup":"listbox","aria-expanded":this.isOpen?"true":"false","aria-label":this.name,onKeyDown:t=>this.handleSelectButtonKeyDown(t)},s.h("slot",{key:"e153c1846999fea97e4c9f9ca2a819339ef25550",name:"select-icon","aria-hidden":"true"}),s.h("span",{key:"368142b157dd006f1c1babbfe008e32fbef26784",class:"selected-option",part:"msd_dropdown-button-selected-label"},this.getSelectedOptions().length>1?"Multiple options selected":((e=this.availableOptions.filter(t=>t.selected)[0])==null?void 0:e.label)??((a=this.availableOptions[0])==null?void 0:a.label)),s.h("span",{key:"ed3a9c7f34bcacc22656aec7121b7e5af340a51c",class:this.isOpen?"open":"closed","aria-hidden":"true"},s.h("chevron-icon",{key:"ddaedf77798b67858f8d6426b821f43e321290eb",width:"16",height:"16"}))),this.error?s.h("span",{class:"error"},this.error):null,this.isOpen?null:s.h("div",{class:"selected-options"},this.getSelectedOptions().map(t=>s.h("span",{class:"selected-option"},t.label,s.h("button",{key:t.label,onClick:()=>this.selectOption(t)},s.h("close-icon",null))))),this.isOpen?s.h("div",{class:"dropdown-content",part:"msd_dropdown-content"},s.h("ul",{tabindex:"-1",role:"listbox","aria-label":this.name,"aria-multiselectable":!0,"aria-activedescendant":this.ariaActivedescendant,onKeyDown:t=>this.handleListboxKeydown(t)},this.availableOptions.map(t=>this.renderOption(t)))):null))}get el(){return s.getElement(this)}};o.style=l;exports.multi_select_dropdown=o;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { r as o, c as r, d as l, h as s, H as d, g as c } from "./index-5ccfd9df.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import "react-dom";
|
|
4
|
+
const p = ':host{display:block;width:inherit;--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}.dropdown{display:inline-block;width:100%;position:relative}.dropdown .dropdown-label{display:flex;align-items:center;gap:0.25rem;color:var(--nylas-base-800)}.dropdown span.error{color:var(--nylas-error);font-size:14px}.dropbtn{width:inherit;height:48px;color:black;padding:0.5rem;font-size:1rem;cursor:pointer;display:flex;gap:0.5rem;justify-content:space-between;align-items:center;background:transparent;border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.dropbtn.focus{background:transparent}.dropbtn.error{border:1px solid var(--nylas-error)}.dropbtn:hover,.dropbtn:active{border:1px solid var(--nylas-primary)}.dropbtn:active{outline:2px solid var(--nylas-primary)}.dropbtn span.open{transform:rotate(90deg)}.dropbtn span.closed{transform:rotate(270deg)}.dropdown-content{display:block;margin-top:0.5rem;background-color:var(--nylas-base-0);width:100%;max-height:336px;overflow:auto;z-index:1;border-radius:4px;position:absolute;top:72px;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.0509803922);box-shadow:0px 10px 15px -3px rgba(0, 0, 0, 0.1019607843)}.dropdown-content ul{padding:0;list-style-type:none;color:var(--nylas-base-900);max-height:336px}.dropdown-content ul li{padding:16px, 12px, 16px, 12px;color:black;padding:12px 16px;text-decoration:none;display:block;font-family:inherit;font-size:14px;font-weight:400;line-height:20px;letter-spacing:0px;text-align:left;cursor:pointer}.dropdown-content ul li:hover,.dropdown-content ul li:focus{background-color:var(--nylas-base-100)}.dropdown-content ul li label{display:flex;align-items:center;gap:0.5rem}.dropdown-content ul li label input{margin:0}.selected-options{display:flex;flex-wrap:wrap;gap:0.5rem;padding:0.5rem 0;margin-top:0.25rem;background:var(--nylas-base-0)}.selected-options .selected-option{display:flex;align-items:center;gap:0.5rem;padding:4px 8px;border-radius:var(--nylas-border-radius-2x);background:var(--nylas-base-100);color:var(--nylas-base-800);font-size:16px;font-weight:500;line-height:1.5rem;letter-spacing:0.5px}.selected-options .selected-option button{background:transparent;border:none;cursor:pointer;padding:0}.selected-options .selected-option button:hover{color:var(--nylas-primary)}', b = p, h = class {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
o(this, e), this.selectedOptionsChanged = r(this, "selectedOptionsChanged", 7), this.name = void 0, this.label = void 0, this.options = [], this.error = "", this.availableOptions = this.options, this.isOpen = !1, this.ariaActivedescendant = "", this.shouldFocusFirstOption = !1;
|
|
7
|
+
}
|
|
8
|
+
componentDidRender() {
|
|
9
|
+
l("multi-select-dropdown", "componentDidRender"), this.isOpen && this.shouldFocusFirstOption && (this.ariaActivedescendant = this.availableOptions[0].value, this.focusOption(0), this.shouldFocusFirstOption = !1);
|
|
10
|
+
}
|
|
11
|
+
handleOutsideClick(e) {
|
|
12
|
+
!e.composedPath().includes(this.el) && this.isOpen && (this.isOpen = !1);
|
|
13
|
+
}
|
|
14
|
+
selectOption(e) {
|
|
15
|
+
this.availableOptions = this.availableOptions.map((t) => (t.value === e.value && (t.selected = !e.selected), t));
|
|
16
|
+
const a = this.availableOptions.filter((t) => t.selected).map((t) => t.value);
|
|
17
|
+
this.selectedOptionsChanged.emit({
|
|
18
|
+
value: a,
|
|
19
|
+
name: this.name
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
toggleDropdown() {
|
|
23
|
+
this.isOpen = !this.isOpen, this.isOpen ? this.shouldFocusFirstOption = !0 : this.ariaActivedescendant = "";
|
|
24
|
+
}
|
|
25
|
+
handleSelectButtonKeyDown(e) {
|
|
26
|
+
switch (e.key) {
|
|
27
|
+
case "ArrowDown":
|
|
28
|
+
case "Enter":
|
|
29
|
+
e.preventDefault(), this.isOpen || this.toggleDropdown();
|
|
30
|
+
break;
|
|
31
|
+
case "Escape":
|
|
32
|
+
this.isOpen = !1;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
handleListboxKeydown(e) {
|
|
37
|
+
const a = this.availableOptions, t = a.findIndex((n) => n.value === this.ariaActivedescendant);
|
|
38
|
+
switch (e.key) {
|
|
39
|
+
case "ArrowDown":
|
|
40
|
+
case "Tab":
|
|
41
|
+
if (e.shiftKey) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
const i = t - 1 >= 0 ? t - 1 : a.length - 1;
|
|
44
|
+
this.ariaActivedescendant = a[i].value, this.focusOption(i);
|
|
45
|
+
} else {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
const i = t + 1 < a.length ? t + 1 : 0;
|
|
48
|
+
this.ariaActivedescendant = a[i].value, this.focusOption(i);
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case "ArrowUp":
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
const n = t - 1 >= 0 ? t - 1 : a.length - 1;
|
|
54
|
+
this.ariaActivedescendant = a[n].value, this.focusOption(n);
|
|
55
|
+
break;
|
|
56
|
+
case "Enter":
|
|
57
|
+
e.preventDefault(), this.ariaActivedescendant && this.selectOption(a[t]);
|
|
58
|
+
break;
|
|
59
|
+
case "Escape":
|
|
60
|
+
this.isOpen = !1;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
focusOption(e) {
|
|
65
|
+
var i;
|
|
66
|
+
const a = this.availableOptions[e];
|
|
67
|
+
if (!a)
|
|
68
|
+
return;
|
|
69
|
+
const t = a.value, n = (i = this.el.shadowRoot) == null ? void 0 : i.getElementById(t);
|
|
70
|
+
n && (n.focus(), n.scrollIntoView({ behavior: "smooth", block: "nearest" }));
|
|
71
|
+
}
|
|
72
|
+
getSelectedOptions() {
|
|
73
|
+
return this.availableOptions.filter((e) => e.selected);
|
|
74
|
+
}
|
|
75
|
+
renderOption(e) {
|
|
76
|
+
return s("li", { key: e.value, id: e.value, role: "option", tabindex: "0", "aria-selected": e.selected ? "true" : "false", onClick: (a) => {
|
|
77
|
+
a.stopImmediatePropagation(), this.selectOption(e);
|
|
78
|
+
}, class: { selected: !!e.selected } }, s("label", { htmlFor: e.value }, s("input", { "aria-hidden": "true", id: e.value, type: "checkbox", checked: e.selected }), s("span", null, e.label)));
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
var e, a;
|
|
82
|
+
return s(d, { key: "ebdbb5947ea3046827153a6b015118d5e6cd5fc6" }, s("div", { key: "7e730c4b5bc924dbe6fd4214137a15bd65db1db7", class: "dropdown", part: "msd_dropdown" }, s("label", { key: "7489c7b95c0a68768f0f1d3142510a54e77a11f0", class: "dropdown-label" }, this.label, s("slot", { key: "aa58521e004ae82463426b8fc130c36c7a2f9464", name: "label-icon", "aria-hidden": "true" })), s("button", { key: "b1f2b45fb76c2b24ae8ed6c72c361657d2431414", name: this.name, part: `msd_dropdown-button ${this.error ? "msd_dropdown-button--error" : ""}`, class: { dropbtn: !0, open: this.isOpen, error: !!this.error }, onClick: () => this.toggleDropdown(), "aria-haspopup": "listbox", "aria-expanded": this.isOpen ? "true" : "false", "aria-label": this.name, onKeyDown: (t) => this.handleSelectButtonKeyDown(t) }, s("slot", { key: "e153c1846999fea97e4c9f9ca2a819339ef25550", name: "select-icon", "aria-hidden": "true" }), s("span", { key: "368142b157dd006f1c1babbfe008e32fbef26784", class: "selected-option", part: "msd_dropdown-button-selected-label" }, this.getSelectedOptions().length > 1 ? "Multiple options selected" : ((e = this.availableOptions.filter((t) => t.selected)[0]) == null ? void 0 : e.label) ?? ((a = this.availableOptions[0]) == null ? void 0 : a.label)), s("span", { key: "ed3a9c7f34bcacc22656aec7121b7e5af340a51c", class: this.isOpen ? "open" : "closed", "aria-hidden": "true" }, s("chevron-icon", { key: "ddaedf77798b67858f8d6426b821f43e321290eb", width: "16", height: "16" }))), this.error ? s("span", { class: "error" }, this.error) : null, this.isOpen ? null : s("div", { class: "selected-options" }, this.getSelectedOptions().map((t) => s("span", { class: "selected-option" }, t.label, s("button", { key: t.label, onClick: () => this.selectOption(t) }, s("close-icon", null))))), this.isOpen ? s("div", { class: "dropdown-content", part: "msd_dropdown-content" }, s("ul", { tabindex: "-1", role: "listbox", "aria-label": this.name, "aria-multiselectable": !0, "aria-activedescendant": this.ariaActivedescendant, onKeyDown: (t) => this.handleListboxKeydown(t) }, this.availableOptions.map((t) => this.renderOption(t)))) : null));
|
|
83
|
+
}
|
|
84
|
+
get el() {
|
|
85
|
+
return c(this);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
h.style = b;
|
|
89
|
+
export {
|
|
90
|
+
h as multi_select_dropdown
|
|
91
|
+
};
|