@nylas/react 1.0.0-prealpha1
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/LICENSE.md +22 -0
- package/README.md +3 -0
- package/dist/_commonjsHelpers-57e89916-4a3ae7d8.cjs +1 -0
- package/dist/_commonjsHelpers-57e89916-af061c86.js +19 -0
- package/dist/archive-icon_7.entry-53aede1b.js +75 -0
- package/dist/archive-icon_7.entry-8c90815a.cjs +1 -0
- package/dist/arrow-icon.entry-2867f4fb.js +15 -0
- package/dist/arrow-icon.entry-a2f53919.cjs +1 -0
- package/dist/bold-icon_3.entry-ad806730.js +35 -0
- package/dist/bold-icon_3.entry-e0bc6774.cjs +1 -0
- package/dist/calendar-cancel-icon.entry-546b7bd4.cjs +1 -0
- package/dist/calendar-cancel-icon.entry-74051835.js +15 -0
- package/dist/calendar-check-icon_3.entry-42bab0b4.js +35 -0
- package/dist/calendar-check-icon_3.entry-f5846fee.cjs +1 -0
- package/dist/calendar-icon.entry-25474b1e.cjs +1 -0
- package/dist/calendar-icon.entry-c751873f.js +15 -0
- package/dist/chevron-icon.entry-60842fb6.js +15 -0
- package/dist/chevron-icon.entry-97e4621e.cjs +1 -0
- package/dist/close-icon_2.entry-aa015993.cjs +1 -0
- package/dist/close-icon_2.entry-ef03bd27.js +25 -0
- package/dist/core-js-38e53e34.cjs +4 -0
- package/dist/core-js-a9d3b6e1.js +3297 -0
- package/dist/document-refresh-icon.entry-b27207eb.js +15 -0
- package/dist/document-refresh-icon.entry-ca2ef29e.cjs +1 -0
- package/dist/dom-68f08be9.cjs +15 -0
- package/dist/dom-86e17616.js +664 -0
- package/dist/duration-bddc4a13-05d3e3e2.cjs +1 -0
- package/dist/duration-bddc4a13-179ce826.js +41 -0
- package/dist/elements/index.d.ts +56 -0
- package/dist/elements/react-component-lib/createComponent.d.ts +10 -0
- package/dist/elements/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/dist/elements/react-component-lib/index.d.ts +2 -0
- package/dist/elements/react-component-lib/interfaces.d.ts +29 -0
- package/dist/elements/react-component-lib/utils/attachProps.d.ts +9 -0
- package/dist/elements/react-component-lib/utils/case.d.ts +2 -0
- package/dist/elements/react-component-lib/utils/dev.d.ts +2 -0
- package/dist/elements/react-component-lib/utils/index.d.ts +10 -0
- package/dist/elements-60ebdb01-24595598.cjs +16494 -0
- package/dist/elements-60ebdb01-5d144002.js +27455 -0
- package/dist/flow-40ff9cea-6f8c30e2.cjs +9 -0
- package/dist/flow-40ff9cea-ee70fdf5.js +505 -0
- package/dist/focus-visible-e8093c16-28fc08a0.js +82 -0
- package/dist/focus-visible-e8093c16-f380b705.cjs +1 -0
- package/dist/forward-icon_6.entry-725d1be4.cjs +3 -0
- package/dist/forward-icon_6.entry-dc8f7235.js +955 -0
- package/dist/globe-icon.entry-796d3f48.js +15 -0
- package/dist/globe-icon.entry-918cfd35.cjs +1 -0
- package/dist/index-29d0e781.cjs +30 -0
- package/dist/index-2b85580a-bfc3ceac.cjs +7 -0
- package/dist/index-2b85580a-f9211f23.js +3238 -0
- package/dist/index-4f65b6f9.js +1489 -0
- package/dist/index.d.ts +4 -0
- package/dist/loading-icon.entry-8e49fab0.js +15 -0
- package/dist/loading-icon.entry-b2534e3e.cjs +1 -0
- package/dist/mailbox-store-0019772c-06d31a90.js +380 -0
- package/dist/mailbox-store-0019772c-d1254c5c.cjs +1 -0
- package/dist/nylas-booked-event-card_9.entry-d995d7cb.js +4567 -0
- package/dist/nylas-booked-event-card_9.entry-ea02f083.cjs +148 -0
- package/dist/nylas-if-state_3.entry-ce816adb.js +291 -0
- package/dist/nylas-if-state_3.entry-e8c831b7.cjs +1 -0
- package/dist/nylas-list-folders.entry-8134344b.js +121 -0
- package/dist/nylas-list-folders.entry-de8cca60.cjs +1 -0
- package/dist/nylas-list-threads.entry-1367fe30.js +71 -0
- package/dist/nylas-list-threads.entry-93b70a1a.cjs +1 -0
- package/dist/nylas-mailbox-pagination.entry-568ac217.js +102 -0
- package/dist/nylas-mailbox-pagination.entry-6bb0ee37.cjs +1 -0
- package/dist/nylas-mailbox-toolbar-button.entry-9214b283.js +83 -0
- package/dist/nylas-mailbox-toolbar-button.entry-d4ad5c15.cjs +1 -0
- package/dist/nylas-open-hours-picker.entry-109f13f5.js +186 -0
- package/dist/nylas-open-hours-picker.entry-2c19643f.cjs +1 -0
- package/dist/nylas-provider.entry-2cfe5f0e.js +134 -0
- package/dist/nylas-provider.entry-87fa9276.cjs +1 -0
- package/dist/nylas-scheduler.entry-6ec8e574.js +195 -0
- package/dist/nylas-scheduler.entry-b41cbf99.cjs +1 -0
- package/dist/nylas-threads-refresh.entry-6d61a689.cjs +1 -0
- package/dist/nylas-threads-refresh.entry-9111a403.js +75 -0
- package/dist/nylas-threads-search.entry-03073490.cjs +1 -0
- package/dist/nylas-threads-search.entry-2124f663.js +70 -0
- package/dist/nylas-view-thread.entry-4ecbcd78.cjs +1 -0
- package/dist/nylas-view-thread.entry-fe51c1f6.js +204 -0
- package/dist/play-icon_2.entry-8e156535.js +25 -0
- package/dist/play-icon_2.entry-cf1cbc8d.cjs +1 -0
- package/dist/property-0065dde7-83dc9cc4.cjs +23 -0
- package/dist/property-0065dde7-c57b8fa3.js +589 -0
- package/dist/react.cjs +1 -0
- package/dist/react.js +62 -0
- package/dist/refresh-icon.entry-4ddd53b0.js +15 -0
- package/dist/refresh-icon.entry-9f24e833.cjs +1 -0
- package/dist/register-component-55376f31-5eaf8954.js +105 -0
- package/dist/register-component-55376f31-8d6ddee4.cjs +1 -0
- package/dist/scheduler-store-5a39585a-117668e3.js +173 -0
- package/dist/scheduler-store-5a39585a-2c848bec.cjs +1 -0
- package/dist/translate-icon.entry-0cd24de4.cjs +1 -0
- package/dist/translate-icon.entry-db2cdf1d.js +15 -0
- package/dist/utils-5074a070-ce33ee6b.js +119 -0
- package/dist/utils-5074a070-d5ba6add.cjs +2 -0
- package/package.json +47 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { r as m, c as d, h as e, H as p, g as u } from "./index-4f65b6f9.js";
|
|
2
|
+
import { R as v } from "./register-component-55376f31-5eaf8954.js";
|
|
3
|
+
import { d as a } from "./utils-5074a070-ce33ee6b.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "react-dom";
|
|
6
|
+
const y = ":host{display:contents}.container{height:var(--container-height, 100dvh);overflow-y:var(--container-overflow-y, auto)}.pagination{display:flex;justify-content:center;align-items:center;margin:0 auto;padding:0;list-style:none;font-size:0.875rem;font-weight:600;color:var(--nylas-color-primary-600)}.pagination sp-button svg{animation:rotate 1s linear infinite}sp-button{border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-400);color:var(--nylas-color-primary-900);fill:var(--nylas-color-primary-900)}sp-button:hover{background-color:var(--nylas-color-primary-500)}sp-button:disabled{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);cursor:not-allowed}sp-button chevron-icon svg{width:15px;height:15px}.next chevron-icon{transform:rotate(180deg)}@keyframes rotate{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}", f = y;
|
|
7
|
+
var P = function(t, n, i, r) {
|
|
8
|
+
var s = arguments.length, o = s < 3 ? n : r === null ? r = Object.getOwnPropertyDescriptor(n, i) : r, l;
|
|
9
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
|
|
10
|
+
o = Reflect.decorate(t, n, i, r);
|
|
11
|
+
else
|
|
12
|
+
for (var c = t.length - 1; c >= 0; c--)
|
|
13
|
+
(l = t[c]) && (o = (s < 3 ? l(o) : s > 3 ? l(n, i, o) : l(n, i)) || o);
|
|
14
|
+
return s > 3 && o && Object.defineProperty(n, i, o), o;
|
|
15
|
+
}, h = function(t, n) {
|
|
16
|
+
if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
|
|
17
|
+
return Reflect.metadata(t, n);
|
|
18
|
+
};
|
|
19
|
+
const g = class {
|
|
20
|
+
constructor(t) {
|
|
21
|
+
m(this, t), this.next = d(this, "next", 7), this.previous = d(this, "previous", 7), this.state = "ready", this.hasNextPage = !1, this.hasPreviousPage = !1, this.scrollTarget = "container", this.mobileOnlyInfiniteScroll = !0, this.mobileViewPortWidth = 768, a("[nylas-pagination] Constructed"), this.isScrollAtContainerBottom = this.isScrollAtContainerBottom.bind(this), this.isScrollAtPageBottom = this.isScrollAtPageBottom.bind(this), this.nextPage = this.nextPage.bind(this), this.previousPage = this.previousPage.bind(this), this.handlePageScroll = this.handlePageScroll.bind(this), this.handleContainerScroll = this.handleContainerScroll.bind(this);
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
a("[nylas-pagination] Component connected");
|
|
25
|
+
}
|
|
26
|
+
async componentWillLoad() {
|
|
27
|
+
a("[nylas-pagination] Component will load");
|
|
28
|
+
}
|
|
29
|
+
async componentDidLoad() {
|
|
30
|
+
a("[nylas-pagination] Component did load"), this.containerElement && this.containerElement.addEventListener("scroll", this.handleContainerScroll);
|
|
31
|
+
}
|
|
32
|
+
async componentWillRender() {
|
|
33
|
+
a("[nylas-pagination] Component will render");
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
a("[nylas-pagination] Component disconnected"), this.containerElement && this.containerElement.removeEventListener("scroll", this.handleContainerScroll);
|
|
37
|
+
}
|
|
38
|
+
handlePageScroll(t) {
|
|
39
|
+
this.isScrollAtPageBottom() && this.canScroll && this.scrollTarget === "page" && this.nextPage();
|
|
40
|
+
}
|
|
41
|
+
async nextPage() {
|
|
42
|
+
const t = this.host.children.length > 0;
|
|
43
|
+
this.next.emit({
|
|
44
|
+
hasChildren: t
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async previousPage() {
|
|
48
|
+
const t = this.host.children.length > 0;
|
|
49
|
+
this.previous.emit({
|
|
50
|
+
hasChildren: t
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
handleContainerScroll(t) {
|
|
54
|
+
this.isScrollAtContainerBottom() && this.canScroll && this.scrollTarget === "container" && this.nextPage();
|
|
55
|
+
}
|
|
56
|
+
isScrollAtContainerBottom() {
|
|
57
|
+
return this.containerElement ? this.containerElement && this.containerElement.scrollTop + this.containerElement.clientHeight >= this.containerElement.scrollHeight : !1;
|
|
58
|
+
}
|
|
59
|
+
isScrollAtPageBottom() {
|
|
60
|
+
return window.innerHeight + window.scrollY >= document.body.offsetHeight;
|
|
61
|
+
}
|
|
62
|
+
get canScroll() {
|
|
63
|
+
const t = this.host.children.length > 0;
|
|
64
|
+
return this.state === "ready" && t && (!this.mobileOnlyInfiniteScroll || window.innerWidth < this.mobileViewPortWidth);
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
return this.host.children.length > 0 ? e(p, null, e("div", { class: "container", ref: (n) => this.containerElement = n }, e("slot", null), this.canScroll && e("div", { class: "pagination" }, e("sp-theme", { scale: "medium", color: "dark" }, this.state === "ready" && this.hasNextPage && e("sp-button", { onClick: this.nextPage }, e("div", { slot: "icon" }, e("refresh-icon", { class: "refres-icon" })), " ", "Load more..."))))) : e(p, null, e("sp-theme", { scale: "medium", color: "dark" }, this.hasPreviousPage && e("sp-button", { class: "previous", parr: "previous", onClick: this.previousPage }, e("div", { slot: "icon" }, e("chevron-icon", { class: "previous-icon" })), " ", "Previous"), this.hasPreviousPage && this.hasNextPage && " ", this.hasNextPage && e("sp-button", { class: "next", parr: "next", onClick: this.nextPage }, e("div", { slot: "icon" }, e("chevron-icon", { class: "next-icon" })), " ", "Next")));
|
|
68
|
+
}
|
|
69
|
+
get host() {
|
|
70
|
+
return u(this);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
P([
|
|
74
|
+
v({
|
|
75
|
+
name: "nylas-pagination",
|
|
76
|
+
stateToProps: /* @__PURE__ */ new Map([
|
|
77
|
+
["mailbox.hasNextThreadPage", "hasNextPage"],
|
|
78
|
+
["mailbox.hasPreviousThreadPage", "hasPreviousPage"],
|
|
79
|
+
["mailbox.state", "state"]
|
|
80
|
+
]),
|
|
81
|
+
eventToProps: {
|
|
82
|
+
next: async (t, n) => {
|
|
83
|
+
a("[nylas-pagination] Next page event fired");
|
|
84
|
+
const { hasChildren: i } = t.detail;
|
|
85
|
+
await n.threads.nextThreadPage(i ? "append" : "overwrite", !i);
|
|
86
|
+
},
|
|
87
|
+
previous: async (t, n) => {
|
|
88
|
+
a("[nylas-pagination] Previous page event fired");
|
|
89
|
+
const { hasChildren: i } = t.detail;
|
|
90
|
+
await n.threads.previousThreadPage(i ? "append" : "overwrite", !i);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
fireRegisterEvent: !0
|
|
94
|
+
}),
|
|
95
|
+
h("design:type", Function),
|
|
96
|
+
h("design:paramtypes", []),
|
|
97
|
+
h("design:returntype", void 0)
|
|
98
|
+
], g.prototype, "render", null);
|
|
99
|
+
g.style = f;
|
|
100
|
+
export {
|
|
101
|
+
g as nylas_mailbox_pagination
|
|
102
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-29d0e781.cjs"),g=require("./register-component-55376f31-8d6ddee4.cjs"),a=require("./utils-5074a070-d5ba6add.cjs");require("react");require("react-dom");const p=":host{display:contents}.container{height:var(--container-height, 100dvh);overflow-y:var(--container-overflow-y, auto)}.pagination{display:flex;justify-content:center;align-items:center;margin:0 auto;padding:0;list-style:none;font-size:0.875rem;font-weight:600;color:var(--nylas-color-primary-600)}.pagination sp-button svg{animation:rotate 1s linear infinite}sp-button{border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-400);color:var(--nylas-color-primary-900);fill:var(--nylas-color-primary-900)}sp-button:hover{background-color:var(--nylas-color-primary-500)}sp-button:disabled{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);cursor:not-allowed}sp-button chevron-icon svg{width:15px;height:15px}.next chevron-icon{transform:rotate(180deg)}@keyframes rotate{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",u=p;var m=function(t,n,i,r){var s=arguments.length,o=s<3?n:r===null?r=Object.getOwnPropertyDescriptor(n,i):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,n,i,r);else for(var h=t.length-1;h>=0;h--)(l=t[h])&&(o=(s<3?l(o):s>3?l(n,i,o):l(n,i))||o);return s>3&&o&&Object.defineProperty(n,i,o),o},c=function(t,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,n)};const d=class{constructor(t){e.registerInstance(this,t),this.next=e.createEvent(this,"next",7),this.previous=e.createEvent(this,"previous",7),this.state="ready",this.hasNextPage=!1,this.hasPreviousPage=!1,this.scrollTarget="container",this.mobileOnlyInfiniteScroll=!0,this.mobileViewPortWidth=768,a.debug("[nylas-pagination] Constructed"),this.isScrollAtContainerBottom=this.isScrollAtContainerBottom.bind(this),this.isScrollAtPageBottom=this.isScrollAtPageBottom.bind(this),this.nextPage=this.nextPage.bind(this),this.previousPage=this.previousPage.bind(this),this.handlePageScroll=this.handlePageScroll.bind(this),this.handleContainerScroll=this.handleContainerScroll.bind(this)}connectedCallback(){a.debug("[nylas-pagination] Component connected")}async componentWillLoad(){a.debug("[nylas-pagination] Component will load")}async componentDidLoad(){a.debug("[nylas-pagination] Component did load"),this.containerElement&&this.containerElement.addEventListener("scroll",this.handleContainerScroll)}async componentWillRender(){a.debug("[nylas-pagination] Component will render")}disconnectedCallback(){a.debug("[nylas-pagination] Component disconnected"),this.containerElement&&this.containerElement.removeEventListener("scroll",this.handleContainerScroll)}handlePageScroll(t){this.isScrollAtPageBottom()&&this.canScroll&&this.scrollTarget==="page"&&this.nextPage()}async nextPage(){const t=this.host.children.length>0;this.next.emit({hasChildren:t})}async previousPage(){const t=this.host.children.length>0;this.previous.emit({hasChildren:t})}handleContainerScroll(t){this.isScrollAtContainerBottom()&&this.canScroll&&this.scrollTarget==="container"&&this.nextPage()}isScrollAtContainerBottom(){return this.containerElement?this.containerElement&&this.containerElement.scrollTop+this.containerElement.clientHeight>=this.containerElement.scrollHeight:!1}isScrollAtPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}get canScroll(){const t=this.host.children.length>0;return this.state==="ready"&&t&&(!this.mobileOnlyInfiniteScroll||window.innerWidth<this.mobileViewPortWidth)}render(){return this.host.children.length>0?e.h(e.Host,null,e.h("div",{class:"container",ref:n=>this.containerElement=n},e.h("slot",null),this.canScroll&&e.h("div",{class:"pagination"},e.h("sp-theme",{scale:"medium",color:"dark"},this.state==="ready"&&this.hasNextPage&&e.h("sp-button",{onClick:this.nextPage},e.h("div",{slot:"icon"},e.h("refresh-icon",{class:"refres-icon"}))," ","Load more..."))))):e.h(e.Host,null,e.h("sp-theme",{scale:"medium",color:"dark"},this.hasPreviousPage&&e.h("sp-button",{class:"previous",parr:"previous",onClick:this.previousPage},e.h("div",{slot:"icon"},e.h("chevron-icon",{class:"previous-icon"}))," ","Previous"),this.hasPreviousPage&&this.hasNextPage&&" ",this.hasNextPage&&e.h("sp-button",{class:"next",parr:"next",onClick:this.nextPage},e.h("div",{slot:"icon"},e.h("chevron-icon",{class:"next-icon"}))," ","Next")))}get host(){return e.getElement(this)}};m([g.RegisterComponent({name:"nylas-pagination",stateToProps:new Map([["mailbox.hasNextThreadPage","hasNextPage"],["mailbox.hasPreviousThreadPage","hasPreviousPage"],["mailbox.state","state"]]),eventToProps:{next:async(t,n)=>{a.debug("[nylas-pagination] Next page event fired");const{hasChildren:i}=t.detail;await n.threads.nextThreadPage(i?"append":"overwrite",!i)},previous:async(t,n)=>{a.debug("[nylas-pagination] Previous page event fired");const{hasChildren:i}=t.detail;await n.threads.previousThreadPage(i?"append":"overwrite",!i)}},fireRegisterEvent:!0}),c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],d.prototype,"render",null);d.style=u;exports.nylas_mailbox_pagination=d;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { r as y, h as l, H as b, g as m } from "./index-4f65b6f9.js";
|
|
2
|
+
import { R as u } from "./register-component-55376f31-5eaf8954.js";
|
|
3
|
+
import { d as c } from "./utils-5074a070-ce33ee6b.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "react-dom";
|
|
6
|
+
const p = ":host{display:block}sp-button{border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-400);color:var(--nylas-color-primary-900);fill:var(--nylas-color-primary-900)}sp-button:hover{background-color:var(--nylas-color-primary-500)}sp-button:disabled{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);cursor:not-allowed}", h = p;
|
|
7
|
+
var g = function(t, o, e, n) {
|
|
8
|
+
var r = arguments.length, a = r < 3 ? o : n === null ? n = Object.getOwnPropertyDescriptor(o, e) : n, i;
|
|
9
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
|
|
10
|
+
a = Reflect.decorate(t, o, e, n);
|
|
11
|
+
else
|
|
12
|
+
for (var s = t.length - 1; s >= 0; s--)
|
|
13
|
+
(i = t[s]) && (a = (r < 3 ? i(a) : r > 3 ? i(o, e, a) : i(o, e)) || a);
|
|
14
|
+
return r > 3 && a && Object.defineProperty(o, e, a), a;
|
|
15
|
+
}, d = function(t, o) {
|
|
16
|
+
if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
|
|
17
|
+
return Reflect.metadata(t, o);
|
|
18
|
+
};
|
|
19
|
+
const f = class {
|
|
20
|
+
constructor(t) {
|
|
21
|
+
y(this, t), this.onClick = async () => {
|
|
22
|
+
const o = this.method;
|
|
23
|
+
if (c("[nylas-mailbox-toolbar-button] onClick", { method: o, mailboxConnector: this.mailboxConnector }), this.mailboxConnector && o) {
|
|
24
|
+
const e = this.callMethod(this.mailboxConnector, o);
|
|
25
|
+
e && await e();
|
|
26
|
+
}
|
|
27
|
+
}, this.method = void 0, this.dataState = void 0, this.iconOnly = !1, this.mailboxConnector = void 0;
|
|
28
|
+
}
|
|
29
|
+
connectedCallback() {
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
}
|
|
33
|
+
async componentWillLoad() {
|
|
34
|
+
c("[nylas-if-state] Component will load");
|
|
35
|
+
}
|
|
36
|
+
async componentDidLoad() {
|
|
37
|
+
c("[nylas-if-state] Component did load");
|
|
38
|
+
}
|
|
39
|
+
callMethod(t, o) {
|
|
40
|
+
const e = o.split(".");
|
|
41
|
+
let n = t;
|
|
42
|
+
for (const i of e.slice(0, -1))
|
|
43
|
+
if (n = n[i], !n)
|
|
44
|
+
return;
|
|
45
|
+
const r = e[e.length - 1], a = n[r];
|
|
46
|
+
if (typeof a == "function")
|
|
47
|
+
return a.bind(n);
|
|
48
|
+
}
|
|
49
|
+
renderByState(t) {
|
|
50
|
+
return t ? l("slot", { name: "loading" }, "Loading...") : l("slot", null, "Click");
|
|
51
|
+
}
|
|
52
|
+
hasSlot(t) {
|
|
53
|
+
return !!this.host.querySelector(`[slot="${t}"]`);
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
var n;
|
|
57
|
+
let t = !1;
|
|
58
|
+
const o = (n = this.mailboxConnector) == null ? void 0 : n.nylasMailboxStore;
|
|
59
|
+
if (typeof o < "u") {
|
|
60
|
+
const r = String(this.dataState);
|
|
61
|
+
t = this.dataState ? o.get(r) === "loading" : !1;
|
|
62
|
+
}
|
|
63
|
+
const e = t ? "state-loading" : "state-ready";
|
|
64
|
+
return l(b, { key: "8885d53e61f2fb52afc9a8b795a71de850b2fbe7" }, l("sp-theme", { key: "7b7d856caa9e2389eaaff33381d374092572f922", scale: "medium", color: "dark" }, l("sp-button", { onClick: this.onClick, disabled: t, key: e, "icon-only": this.iconOnly, label: this.renderByState(t) }, this.hasSlot("icon") && l("div", { slot: "icon", class: "slot" }, l("slot", { name: "icon" })), !this.iconOnly && this.renderByState(t))));
|
|
65
|
+
}
|
|
66
|
+
get host() {
|
|
67
|
+
return m(this);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
g([
|
|
71
|
+
u({
|
|
72
|
+
name: "nylas-mailbox-toolbar-button",
|
|
73
|
+
connectorToProp: "mailboxConnector",
|
|
74
|
+
fireRegisterEvent: !0
|
|
75
|
+
}),
|
|
76
|
+
d("design:type", Function),
|
|
77
|
+
d("design:paramtypes", []),
|
|
78
|
+
d("design:returntype", void 0)
|
|
79
|
+
], f.prototype, "render", null);
|
|
80
|
+
f.style = h;
|
|
81
|
+
export {
|
|
82
|
+
f as nylas_mailbox_toolbar_button
|
|
83
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-29d0e781.cjs"),b=require("./register-component-55376f31-8d6ddee4.cjs"),c=require("./utils-5074a070-d5ba6add.cjs");require("react");require("react-dom");const y=":host{display:block}sp-button{border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-400);color:var(--nylas-color-primary-900);fill:var(--nylas-color-primary-900)}sp-button:hover{background-color:var(--nylas-color-primary-500)}sp-button:disabled{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);cursor:not-allowed}",f=y;var h=function(t,o,e,n){var l=arguments.length,a=l<3?o:n===null?n=Object.getOwnPropertyDescriptor(o,e):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,o,e,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(l<3?i(a):l>3?i(o,e,a):i(o,e))||a);return l>3&&a&&Object.defineProperty(o,e,a),a},d=function(t,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,o)};const u=class{constructor(t){r.registerInstance(this,t),this.onClick=async()=>{const o=this.method;if(c.debug("[nylas-mailbox-toolbar-button] onClick",{method:o,mailboxConnector:this.mailboxConnector}),this.mailboxConnector&&o){const e=this.callMethod(this.mailboxConnector,o);e&&await e()}},this.method=void 0,this.dataState=void 0,this.iconOnly=!1,this.mailboxConnector=void 0}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){c.debug("[nylas-if-state] Component will load")}async componentDidLoad(){c.debug("[nylas-if-state] Component did load")}callMethod(t,o){const e=o.split(".");let n=t;for(const i of e.slice(0,-1))if(n=n[i],!n)return;const l=e[e.length-1],a=n[l];if(typeof a=="function")return a.bind(n)}renderByState(t){return t?r.h("slot",{name:"loading"},"Loading..."):r.h("slot",null,"Click")}hasSlot(t){return!!this.host.querySelector(`[slot="${t}"]`)}render(){var n;let t=!1;const o=(n=this.mailboxConnector)==null?void 0:n.nylasMailboxStore;if(typeof o<"u"){const l=String(this.dataState);t=this.dataState?o.get(l)==="loading":!1}const e=t?"state-loading":"state-ready";return r.h(r.Host,{key:"8885d53e61f2fb52afc9a8b795a71de850b2fbe7"},r.h("sp-theme",{key:"7b7d856caa9e2389eaaff33381d374092572f922",scale:"medium",color:"dark"},r.h("sp-button",{onClick:this.onClick,disabled:t,key:e,"icon-only":this.iconOnly,label:this.renderByState(t)},this.hasSlot("icon")&&r.h("div",{slot:"icon",class:"slot"},r.h("slot",{name:"icon"})),!this.iconOnly&&this.renderByState(t))))}get host(){return r.getElement(this)}};h([b.RegisterComponent({name:"nylas-mailbox-toolbar-button",connectorToProp:"mailboxConnector",fireRegisterEvent:!0}),d("design:type",Function),d("design:paramtypes",[]),d("design:returntype",void 0)],u.prototype,"render",null);u.style=f;exports.nylas_mailbox_toolbar_button=u;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { r as y, c as D, h, H as M, g as H } from "./index-4f65b6f9.js";
|
|
2
|
+
import { d as p, g as b, c as w } from "./utils-5074a070-ce33ee6b.js";
|
|
3
|
+
import { t as f, d as c, a as T, b as m } from "./duration-bddc4a13-179ce826.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "react-dom";
|
|
6
|
+
const S = f((t) => {
|
|
7
|
+
t.setTime(t - t.getMilliseconds() - t.getSeconds() * T);
|
|
8
|
+
}, (t, e) => {
|
|
9
|
+
t.setTime(+t + e * c);
|
|
10
|
+
}, (t, e) => (e - t) / c, (t) => t.getMinutes()), k = S.range;
|
|
11
|
+
f((t) => {
|
|
12
|
+
t.setUTCSeconds(0, 0);
|
|
13
|
+
}, (t, e) => {
|
|
14
|
+
t.setTime(+t + e * c);
|
|
15
|
+
}, (t, e) => (e - t) / c, (t) => t.getUTCMinutes());
|
|
16
|
+
const x = f((t) => {
|
|
17
|
+
t.setTime(t - t.getMilliseconds() - t.getSeconds() * T - t.getMinutes() * c);
|
|
18
|
+
}, (t, e) => {
|
|
19
|
+
t.setTime(+t + e * m);
|
|
20
|
+
}, (t, e) => (e - t) / m, (t) => t.getHours()), v = x.range;
|
|
21
|
+
f((t) => {
|
|
22
|
+
t.setUTCMinutes(0, 0, 0);
|
|
23
|
+
}, (t, e) => {
|
|
24
|
+
t.setTime(+t + e * m);
|
|
25
|
+
}, (t, e) => (e - t) / m, (t) => t.getUTCHours());
|
|
26
|
+
const C = ':host{display:block;font-size:inherit;font-family:inherit;--nylas-grid-border-color:var(--nylas-base-100);--nylas-available-color:var(--nylas-base-500);--nylas-available-hover-color:var(--nylas-base-100);--nylas-unavailable-color:inherit}.legend{display:grid;grid-template-columns:1fr 1fr;gap:1rem;align-items:center;font-size:inherit;font-family:inherit;max-width:fit-content;margin:0 auto;margin-top:1rem}.legend .available{display:grid;grid-template-columns:auto 1fr;gap:0.5rem;align-items:center;font-size:inherit;font-family:inherit}.legend .available .box{width:2rem;height:2rem;background-color:var(--nylas-available-color);border:1px dashed var(--nylas-grid-border-color)}.legend .unavailable{display:grid;grid-template-columns:auto 1fr;gap:0.5rem;align-items:center;font-size:inherit;font-family:inherit}.legend .unavailable .box{width:2rem;height:2rem;background-color:var(--nylas-unavailable-color);border:1px dashed var(--nylas-grid-border-color)}.open-hours{display:grid;gap:1rem;grid-template:".... days days" "hours selected-hours selected-hours" 1fr/auto 1fr}.open-hours .days{grid-area:days;display:grid;grid-auto-flow:column;grid-template-columns:1fr 1fr 1fr 1fr 1fr 1fr 1fr;text-align:center;justify-items:center;font-size:inherit;font-family:inherit}.open-hours .hours{display:grid;grid-auto-flow:row;grid-area:hours;text-align:right;align-items:start;font-size:inherit;font-family:inherit}.open-hours .hours span{top:-0.6rem;display:block;position:relative}.open-hours .selected-hours{display:grid;grid-area:selected-hours;grid-template-columns:1fr 1fr 1fr 1fr 1fr 1fr 1fr}.open-hours .selected-hours .hour{display:grid;border:1px dashed var(--nylas-grid-border-color);height:40px;background-color:var(--nylas-unavailable-color)}.open-hours .selected-hours .hour.selected{background-color:var(--nylas-available-color)}.open-hours .selected-hours .hour.hovered{background-color:var(--nylas-available-hover-color)}.open-hours .selected-hours.inverse .hour{background-color:var(--nylas-available-color)}.open-hours .selected-hours.inverse .hour.selected{background-color:var(--nylas-unavailable-color)}.open-hours .selected-hours.inverse .hour.hovered{background-color:var(--nylas-available-hover-color)}', O = C, E = class {
|
|
27
|
+
constructor(t) {
|
|
28
|
+
y(this, t), this.openHoursChanged = D(this, "openHoursChanged", 7), this.dragStartTime = 0, this.onSelectedHoursWeel = (e) => {
|
|
29
|
+
e.preventDefault(), e.stopPropagation();
|
|
30
|
+
const { deltaY: s } = e, i = s > 0 ? -1 : 1;
|
|
31
|
+
if (this.intervalMinutes === this.stepMinutes && i === -1 || this.intervalMinutes === 60 && i === 1)
|
|
32
|
+
return;
|
|
33
|
+
this.intervalMinutes = this.intervalMinutes + i * this.stepMinutes;
|
|
34
|
+
const a = new Date(this.startTime);
|
|
35
|
+
a.setHours(this.endTime.getHours(), 0, 0, 0), this.intervalMinutes < 60 ? this.times = k(this.startTime, a, this.intervalMinutes) : this.times = v(this.startTime, a, this.intervalMinutes / 60);
|
|
36
|
+
}, this.onContextMenu = (e) => {
|
|
37
|
+
e.preventDefault(), e.stopPropagation(), this.inverse = !this.inverse;
|
|
38
|
+
}, this.onMouseDown = (e, s) => {
|
|
39
|
+
this.draggingStartDate = s, this.dragStartTime = (/* @__PURE__ */ new Date()).getTime(), e.preventDefault(), e.stopPropagation();
|
|
40
|
+
}, this.onMouseOver = (e, s) => {
|
|
41
|
+
this.isDragging() && (this.draggingEndDate = s);
|
|
42
|
+
}, this.onMouseUp = (e, s) => {
|
|
43
|
+
if (this.host.querySelectorAll(".hovered").forEach((a) => {
|
|
44
|
+
a.classList.remove("hovered");
|
|
45
|
+
}), this.isDragging() && this.draggingStartDate && this.draggingEndDate) {
|
|
46
|
+
const a = [];
|
|
47
|
+
let r = this.draggingStartDate, o = this.draggingEndDate;
|
|
48
|
+
o.setMinutes(o.getMinutes() + this.intervalMinutes);
|
|
49
|
+
const n = r.getDay(), u = o.getDay();
|
|
50
|
+
if (n === u)
|
|
51
|
+
a.push({ start: r, end: o });
|
|
52
|
+
else if (u > n)
|
|
53
|
+
for (let l = 0; l <= u - n; l++) {
|
|
54
|
+
const d = new Date(r), g = new Date(r);
|
|
55
|
+
d.setDate(r.getDate() + l), g.setDate(r.getDate() + l), g.setHours(o.getHours()), a.push({ start: d, end: g });
|
|
56
|
+
}
|
|
57
|
+
for (let l of a)
|
|
58
|
+
this.updateAvailableTimes(l.start, l.end);
|
|
59
|
+
}
|
|
60
|
+
this.draggingStartDate = null, this.draggingEndDate = null, e.preventDefault(), e.stopPropagation();
|
|
61
|
+
}, this.onTimeClick = (e) => {
|
|
62
|
+
if (this.isDragging()) {
|
|
63
|
+
p("dragging for more than threshold, skipping click event");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.draggingStartDate = null;
|
|
67
|
+
const s = new Date(e), i = new Date(e);
|
|
68
|
+
i.setMinutes(i.getMinutes() + this.intervalMinutes), this.updateAvailableTimes(s, i);
|
|
69
|
+
}, this.isDragging = () => {
|
|
70
|
+
const e = (/* @__PURE__ */ new Date()).getTime();
|
|
71
|
+
return this.draggingStartDate && e - this.dragStartTime > this.dragThreshold;
|
|
72
|
+
}, this.updateAvailableTimes = (e, s) => {
|
|
73
|
+
const { availableTimes: i } = this, a = i.findIndex((n) => e.getTime() >= n.start.getTime() && s.getTime() <= n.end.getTime());
|
|
74
|
+
if (a !== -1) {
|
|
75
|
+
i.splice(a, 1), this.availableTimes = [...i];
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const r = i.findIndex((n) => e.getTime() === n.end.getTime());
|
|
79
|
+
if (r !== -1) {
|
|
80
|
+
i[r].end = s, this.availableTimes = [...i];
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const o = i.findIndex((n) => s.getTime() === n.start.getTime());
|
|
84
|
+
if (o !== -1) {
|
|
85
|
+
i[o].start = e, this.availableTimes = [...i];
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.availableTimes = [...i, { start: e, end: s }];
|
|
89
|
+
}, this.isAvailableTime = (e) => this.availableTimes.some((s) => s.start.getTime() <= e.getTime() && s.end.getTime() > e.getTime()), this.getSelectedDate = (e) => {
|
|
90
|
+
const s = new Date(this.startTime);
|
|
91
|
+
s.setDate(e % 7 + 1);
|
|
92
|
+
const i = Math.floor(e / 7);
|
|
93
|
+
return s.setHours(this.times[i].getHours()), s.setMinutes(this.times[i].getMinutes()), s;
|
|
94
|
+
}, this.isHovering = (e) => !this.draggingStartDate || !this.draggingEndDate ? !1 : e.getDay() >= this.draggingStartDate.getDay() && e.getHours() >= this.draggingStartDate.getHours() && e.getHours() <= this.draggingEndDate.getHours() && e.getDay() <= this.draggingEndDate.getDay(), this.calculateAvailableTimes = (e) => {
|
|
95
|
+
const s = [];
|
|
96
|
+
for (const i of e)
|
|
97
|
+
for (const a of i.days) {
|
|
98
|
+
if (i.start === i.end)
|
|
99
|
+
continue;
|
|
100
|
+
const [r, o] = i.start.split(":").map((g) => parseInt(g, 10)), [n, u] = i.end.split(":").map((g) => parseInt(g, 10)), l = new Date(this.startTime);
|
|
101
|
+
l.setDate(l.getDate() + a), l.setHours(r), l.setMinutes(o);
|
|
102
|
+
const d = new Date(this.startTime);
|
|
103
|
+
d.setDate(d.getDate() + a), d.setHours(n), d.setMinutes(u), s.push({ start: l, end: d });
|
|
104
|
+
}
|
|
105
|
+
return s.sort((i, a) => i.start.getTime() - a.start.getTime()), p("availableTimes", s), s;
|
|
106
|
+
}, this.calculateOpenHours = () => {
|
|
107
|
+
const e = {}, s = [];
|
|
108
|
+
let i = [...this.availableTimes];
|
|
109
|
+
if (i.sort((a, r) => a.start.getTime() - r.start.getTime()), this.inverse) {
|
|
110
|
+
const a = [...i];
|
|
111
|
+
i = [];
|
|
112
|
+
let r = this.startTime;
|
|
113
|
+
for (const o of a) {
|
|
114
|
+
const n = o.start;
|
|
115
|
+
i.push({ start: r, end: n }), r = o.end;
|
|
116
|
+
}
|
|
117
|
+
i.push({ start: r, end: this.endTime });
|
|
118
|
+
}
|
|
119
|
+
i.sort((a, r) => a.start.getTime() - r.start.getTime());
|
|
120
|
+
for (const a of i) {
|
|
121
|
+
const r = a.start.getDay(), o = a.end.getDay(), n = new Date(a.start);
|
|
122
|
+
n.setDate(n.getDate() + 1), n.setHours(0, 0, 0, 0), (r > o || o > r) && (i.push({ start: n, end: a.end }), a.end = new Date(a.start), a.end.setHours(23, 0, 0, 0));
|
|
123
|
+
const u = b(a.start), l = b(a.end), d = `${u}-${l}`;
|
|
124
|
+
e[d] ? e[d].push(r) : e[d] = [r];
|
|
125
|
+
}
|
|
126
|
+
for (const a in e) {
|
|
127
|
+
const [r, o] = a.split("-"), u = {
|
|
128
|
+
days: e[a],
|
|
129
|
+
start: r,
|
|
130
|
+
end: o,
|
|
131
|
+
timezone: w()
|
|
132
|
+
};
|
|
133
|
+
s.push(u);
|
|
134
|
+
}
|
|
135
|
+
this.openHoursChanged.emit(s);
|
|
136
|
+
}, this.getNumberOfDatesBetween = (e, s) => {
|
|
137
|
+
const i = Math.abs(s.getTime() - e.getTime());
|
|
138
|
+
return Math.ceil(i / (1e3 * 60 * 60 * 24));
|
|
139
|
+
}, this.openHours = [], this.startTime = new Date(2024, 8, 1, 8, 0, 0, 0), this.endTime = new Date(2024, 8, 7, 18, 0, 0, 0), this.stepMinutes = 15, this.dragThreshold = 150, this.mobileViewPortWidth = 768, this.intervalMinutes = 60, this.times = [], this.availableTimes = [], this.draggingStartDate = null, this.draggingEndDate = null, this.inverse = !1, this.isMobile = !1;
|
|
140
|
+
}
|
|
141
|
+
componentWillLoad() {
|
|
142
|
+
this.onResize();
|
|
143
|
+
const t = new Date(this.startTime);
|
|
144
|
+
t.setHours(this.endTime.getHours(), 0, 0, 0), this.times = v(this.startTime, t, this.intervalMinutes / 60), this.availableTimes = this.calculateAvailableTimes(this.openHours);
|
|
145
|
+
}
|
|
146
|
+
whenOpenHoursChanged(t, e) {
|
|
147
|
+
JSON.stringify(t) !== JSON.stringify(e) && (this.availableTimes = this.calculateAvailableTimes(t));
|
|
148
|
+
}
|
|
149
|
+
availableTimesChanged() {
|
|
150
|
+
this.calculateOpenHours();
|
|
151
|
+
}
|
|
152
|
+
inverseChanged() {
|
|
153
|
+
this.calculateOpenHours();
|
|
154
|
+
}
|
|
155
|
+
onResize() {
|
|
156
|
+
const t = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
|
157
|
+
this.isMobile = t <= this.mobileViewPortWidth;
|
|
158
|
+
}
|
|
159
|
+
render() {
|
|
160
|
+
return h(M, { key: "7d7260510342c7d666f9596eddee704088451dbb" }, h("div", { key: "8ebc305e29157af40c432ec8ff0e182c206cfda0", class: "open-hours", part: "open-hours" }, h("div", { key: "df2e84e8387773ff864c56b78d5fbb3f8f7db606", class: "days", part: "days" }, Array.from({ length: this.getNumberOfDatesBetween(this.startTime, this.endTime) }).map((t, e) => {
|
|
161
|
+
const s = new Date(this.startTime);
|
|
162
|
+
return s.setDate(s.getDate() + e), h("span", null, s.toLocaleDateString(void 0, { weekday: this.isMobile ? "short" : "long" }));
|
|
163
|
+
})), h("div", { key: "88dff2631e52fed25458d0545dfaba0e0586b8ec", class: "hours", part: "hours" }, this.times.map((t) => h("span", null, t.toLocaleTimeString(void 0, { timeStyle: "short" })))), h("div", { key: "53f658bf52ea9367376fb297ce50d8849bf99841", class: {
|
|
164
|
+
"selected-hours": !0,
|
|
165
|
+
inverse: this.inverse
|
|
166
|
+
}, part: "selected-hours", onWheel: this.onSelectedHoursWeel, onContextMenu: this.onContextMenu }, Array.from({ length: this.getNumberOfDatesBetween(this.startTime, this.endTime) * this.times.length }).map((t, e) => h("div", { part: "hour", class: {
|
|
167
|
+
hour: !0,
|
|
168
|
+
selected: this.isAvailableTime(this.getSelectedDate(e)),
|
|
169
|
+
hovered: this.isHovering(this.getSelectedDate(e))
|
|
170
|
+
}, onMouseDown: (s) => this.onMouseDown(s, this.getSelectedDate(e)), onMouseUp: (s) => this.onMouseUp(s, this.getSelectedDate(e)), onMouseOver: (s) => this.onMouseOver(s, this.getSelectedDate(e)), onClick: () => this.onTimeClick(this.getSelectedDate(e)) }, " ")))), h("div", { key: "2f0459102a39a37ee38ff550b7fe7d303bfa9fef", class: "legend", part: "legend" }, h("div", { key: "b2ce6eb4496270ae2577164f2fecb9145e7120d5", class: "available", part: "available" }, h("span", { key: "0fe60c643e3d9cee77509109bbb99059f1900716", class: "box", part: "box" }), h("span", { key: "3f03d82fe8b20dab316910ced828682880057a4d", class: "label", part: "label" }, "Available")), h("div", { key: "188ea3df5640bcd2fe197bf00e2dfd4ede0189cf", class: "unavailable", part: "unavailable" }, h("span", { key: "9b313c8a36f2752a8327612efd665ea275175fb5", class: "box", part: "box" }), h("span", { key: "772d25822bd93b80d434f8bb501b4487b5d6a04a", class: "label", part: "label" }, "Unavailable"))));
|
|
171
|
+
}
|
|
172
|
+
get host() {
|
|
173
|
+
return H(this);
|
|
174
|
+
}
|
|
175
|
+
static get watchers() {
|
|
176
|
+
return {
|
|
177
|
+
openHours: ["whenOpenHoursChanged"],
|
|
178
|
+
availableTimes: ["availableTimesChanged"],
|
|
179
|
+
inverse: ["inverseChanged"]
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
E.style = O;
|
|
184
|
+
export {
|
|
185
|
+
E as nylas_open_hours_picker
|
|
186
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-29d0e781.cjs"),m=require("./utils-5074a070-d5ba6add.cjs"),u=require("./duration-bddc4a13-05d3e3e2.cjs");require("react");require("react-dom");const b=u.timeInterval(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*u.durationSecond)},(t,e)=>{t.setTime(+t+e*u.durationMinute)},(t,e)=>(e-t)/u.durationMinute,t=>t.getMinutes()),v=b.range;u.timeInterval(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*u.durationMinute)},(t,e)=>(e-t)/u.durationMinute,t=>t.getUTCMinutes());const T=u.timeInterval(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*u.durationSecond-t.getMinutes()*u.durationMinute)},(t,e)=>{t.setTime(+t+e*u.durationHour)},(t,e)=>(e-t)/u.durationHour,t=>t.getHours()),f=T.range;u.timeInterval(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*u.durationHour)},(t,e)=>(e-t)/u.durationHour,t=>t.getUTCHours());const y=':host{display:block;font-size:inherit;font-family:inherit;--nylas-grid-border-color:var(--nylas-base-100);--nylas-available-color:var(--nylas-base-500);--nylas-available-hover-color:var(--nylas-base-100);--nylas-unavailable-color:inherit}.legend{display:grid;grid-template-columns:1fr 1fr;gap:1rem;align-items:center;font-size:inherit;font-family:inherit;max-width:fit-content;margin:0 auto;margin-top:1rem}.legend .available{display:grid;grid-template-columns:auto 1fr;gap:0.5rem;align-items:center;font-size:inherit;font-family:inherit}.legend .available .box{width:2rem;height:2rem;background-color:var(--nylas-available-color);border:1px dashed var(--nylas-grid-border-color)}.legend .unavailable{display:grid;grid-template-columns:auto 1fr;gap:0.5rem;align-items:center;font-size:inherit;font-family:inherit}.legend .unavailable .box{width:2rem;height:2rem;background-color:var(--nylas-unavailable-color);border:1px dashed var(--nylas-grid-border-color)}.open-hours{display:grid;gap:1rem;grid-template:".... days days" "hours selected-hours selected-hours" 1fr/auto 1fr}.open-hours .days{grid-area:days;display:grid;grid-auto-flow:column;grid-template-columns:1fr 1fr 1fr 1fr 1fr 1fr 1fr;text-align:center;justify-items:center;font-size:inherit;font-family:inherit}.open-hours .hours{display:grid;grid-auto-flow:row;grid-area:hours;text-align:right;align-items:start;font-size:inherit;font-family:inherit}.open-hours .hours span{top:-0.6rem;display:block;position:relative}.open-hours .selected-hours{display:grid;grid-area:selected-hours;grid-template-columns:1fr 1fr 1fr 1fr 1fr 1fr 1fr}.open-hours .selected-hours .hour{display:grid;border:1px dashed var(--nylas-grid-border-color);height:40px;background-color:var(--nylas-unavailable-color)}.open-hours .selected-hours .hour.selected{background-color:var(--nylas-available-color)}.open-hours .selected-hours .hour.hovered{background-color:var(--nylas-available-hover-color)}.open-hours .selected-hours.inverse .hour{background-color:var(--nylas-available-color)}.open-hours .selected-hours.inverse .hour.selected{background-color:var(--nylas-unavailable-color)}.open-hours .selected-hours.inverse .hour.hovered{background-color:var(--nylas-available-hover-color)}',D=y,p=class{constructor(t){o.registerInstance(this,t),this.openHoursChanged=o.createEvent(this,"openHoursChanged",7),this.dragStartTime=0,this.onSelectedHoursWeel=e=>{e.preventDefault(),e.stopPropagation();const{deltaY:s}=e,i=s>0?-1:1;if(this.intervalMinutes===this.stepMinutes&&i===-1||this.intervalMinutes===60&&i===1)return;this.intervalMinutes=this.intervalMinutes+i*this.stepMinutes;const a=new Date(this.startTime);a.setHours(this.endTime.getHours(),0,0,0),this.intervalMinutes<60?this.times=v(this.startTime,a,this.intervalMinutes):this.times=f(this.startTime,a,this.intervalMinutes/60)},this.onContextMenu=e=>{e.preventDefault(),e.stopPropagation(),this.inverse=!this.inverse},this.onMouseDown=(e,s)=>{this.draggingStartDate=s,this.dragStartTime=new Date().getTime(),e.preventDefault(),e.stopPropagation()},this.onMouseOver=(e,s)=>{this.isDragging()&&(this.draggingEndDate=s)},this.onMouseUp=(e,s)=>{if(this.host.querySelectorAll(".hovered").forEach(a=>{a.classList.remove("hovered")}),this.isDragging()&&this.draggingStartDate&&this.draggingEndDate){const a=[];let r=this.draggingStartDate,l=this.draggingEndDate;l.setMinutes(l.getMinutes()+this.intervalMinutes);const n=r.getDay(),g=l.getDay();if(n===g)a.push({start:r,end:l});else if(g>n)for(let h=0;h<=g-n;h++){const d=new Date(r),c=new Date(r);d.setDate(r.getDate()+h),c.setDate(r.getDate()+h),c.setHours(l.getHours()),a.push({start:d,end:c})}for(let h of a)this.updateAvailableTimes(h.start,h.end)}this.draggingStartDate=null,this.draggingEndDate=null,e.preventDefault(),e.stopPropagation()},this.onTimeClick=e=>{if(this.isDragging()){m.debug("dragging for more than threshold, skipping click event");return}this.draggingStartDate=null;const s=new Date(e),i=new Date(e);i.setMinutes(i.getMinutes()+this.intervalMinutes),this.updateAvailableTimes(s,i)},this.isDragging=()=>{const e=new Date().getTime();return this.draggingStartDate&&e-this.dragStartTime>this.dragThreshold},this.updateAvailableTimes=(e,s)=>{const{availableTimes:i}=this,a=i.findIndex(n=>e.getTime()>=n.start.getTime()&&s.getTime()<=n.end.getTime());if(a!==-1){i.splice(a,1),this.availableTimes=[...i];return}const r=i.findIndex(n=>e.getTime()===n.end.getTime());if(r!==-1){i[r].end=s,this.availableTimes=[...i];return}const l=i.findIndex(n=>s.getTime()===n.start.getTime());if(l!==-1){i[l].start=e,this.availableTimes=[...i];return}this.availableTimes=[...i,{start:e,end:s}]},this.isAvailableTime=e=>this.availableTimes.some(s=>s.start.getTime()<=e.getTime()&&s.end.getTime()>e.getTime()),this.getSelectedDate=e=>{const s=new Date(this.startTime);s.setDate(e%7+1);const i=Math.floor(e/7);return s.setHours(this.times[i].getHours()),s.setMinutes(this.times[i].getMinutes()),s},this.isHovering=e=>!this.draggingStartDate||!this.draggingEndDate?!1:e.getDay()>=this.draggingStartDate.getDay()&&e.getHours()>=this.draggingStartDate.getHours()&&e.getHours()<=this.draggingEndDate.getHours()&&e.getDay()<=this.draggingEndDate.getDay(),this.calculateAvailableTimes=e=>{const s=[];for(const i of e)for(const a of i.days){if(i.start===i.end)continue;const[r,l]=i.start.split(":").map(c=>parseInt(c,10)),[n,g]=i.end.split(":").map(c=>parseInt(c,10)),h=new Date(this.startTime);h.setDate(h.getDate()+a),h.setHours(r),h.setMinutes(l);const d=new Date(this.startTime);d.setDate(d.getDate()+a),d.setHours(n),d.setMinutes(g),s.push({start:h,end:d})}return s.sort((i,a)=>i.start.getTime()-a.start.getTime()),m.debug("availableTimes",s),s},this.calculateOpenHours=()=>{const e={},s=[];let i=[...this.availableTimes];if(i.sort((a,r)=>a.start.getTime()-r.start.getTime()),this.inverse){const a=[...i];i=[];let r=this.startTime;for(const l of a){const n=l.start;i.push({start:r,end:n}),r=l.end}i.push({start:r,end:this.endTime})}i.sort((a,r)=>a.start.getTime()-r.start.getTime());for(const a of i){const r=a.start.getDay(),l=a.end.getDay(),n=new Date(a.start);n.setDate(n.getDate()+1),n.setHours(0,0,0,0),(r>l||l>r)&&(i.push({start:n,end:a.end}),a.end=new Date(a.start),a.end.setHours(23,0,0,0));const g=m.get24HourTime(a.start),h=m.get24HourTime(a.end),d=`${g}-${h}`;e[d]?e[d].push(r):e[d]=[r]}for(const a in e){const[r,l]=a.split("-"),g={days:e[a],start:r,end:l,timezone:m.getUserTimezone()};s.push(g)}this.openHoursChanged.emit(s)},this.getNumberOfDatesBetween=(e,s)=>{const i=Math.abs(s.getTime()-e.getTime());return Math.ceil(i/(1e3*60*60*24))},this.openHours=[],this.startTime=new Date(2024,8,1,8,0,0,0),this.endTime=new Date(2024,8,7,18,0,0,0),this.stepMinutes=15,this.dragThreshold=150,this.mobileViewPortWidth=768,this.intervalMinutes=60,this.times=[],this.availableTimes=[],this.draggingStartDate=null,this.draggingEndDate=null,this.inverse=!1,this.isMobile=!1}componentWillLoad(){this.onResize();const t=new Date(this.startTime);t.setHours(this.endTime.getHours(),0,0,0),this.times=f(this.startTime,t,this.intervalMinutes/60),this.availableTimes=this.calculateAvailableTimes(this.openHours)}whenOpenHoursChanged(t,e){JSON.stringify(t)!==JSON.stringify(e)&&(this.availableTimes=this.calculateAvailableTimes(t))}availableTimesChanged(){this.calculateOpenHours()}inverseChanged(){this.calculateOpenHours()}onResize(){const t=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0);this.isMobile=t<=this.mobileViewPortWidth}render(){return o.h(o.Host,{key:"7d7260510342c7d666f9596eddee704088451dbb"},o.h("div",{key:"8ebc305e29157af40c432ec8ff0e182c206cfda0",class:"open-hours",part:"open-hours"},o.h("div",{key:"df2e84e8387773ff864c56b78d5fbb3f8f7db606",class:"days",part:"days"},Array.from({length:this.getNumberOfDatesBetween(this.startTime,this.endTime)}).map((t,e)=>{const s=new Date(this.startTime);return s.setDate(s.getDate()+e),o.h("span",null,s.toLocaleDateString(void 0,{weekday:this.isMobile?"short":"long"}))})),o.h("div",{key:"88dff2631e52fed25458d0545dfaba0e0586b8ec",class:"hours",part:"hours"},this.times.map(t=>o.h("span",null,t.toLocaleTimeString(void 0,{timeStyle:"short"})))),o.h("div",{key:"53f658bf52ea9367376fb297ce50d8849bf99841",class:{"selected-hours":!0,inverse:this.inverse},part:"selected-hours",onWheel:this.onSelectedHoursWeel,onContextMenu:this.onContextMenu},Array.from({length:this.getNumberOfDatesBetween(this.startTime,this.endTime)*this.times.length}).map((t,e)=>o.h("div",{part:"hour",class:{hour:!0,selected:this.isAvailableTime(this.getSelectedDate(e)),hovered:this.isHovering(this.getSelectedDate(e))},onMouseDown:s=>this.onMouseDown(s,this.getSelectedDate(e)),onMouseUp:s=>this.onMouseUp(s,this.getSelectedDate(e)),onMouseOver:s=>this.onMouseOver(s,this.getSelectedDate(e)),onClick:()=>this.onTimeClick(this.getSelectedDate(e))}," ")))),o.h("div",{key:"2f0459102a39a37ee38ff550b7fe7d303bfa9fef",class:"legend",part:"legend"},o.h("div",{key:"b2ce6eb4496270ae2577164f2fecb9145e7120d5",class:"available",part:"available"},o.h("span",{key:"0fe60c643e3d9cee77509109bbb99059f1900716",class:"box",part:"box"}),o.h("span",{key:"3f03d82fe8b20dab316910ced828682880057a4d",class:"label",part:"label"},"Available")),o.h("div",{key:"188ea3df5640bcd2fe197bf00e2dfd4ede0189cf",class:"unavailable",part:"unavailable"},o.h("span",{key:"9b313c8a36f2752a8327612efd665ea275175fb5",class:"box",part:"box"}),o.h("span",{key:"772d25822bd93b80d434f8bb501b4487b5d6a04a",class:"label",part:"label"},"Unavailable"))))}get host(){return o.getElement(this)}static get watchers(){return{openHours:["whenOpenHoursChanged"],availableTimes:["availableTimesChanged"],inverse:["inverseChanged"]}}};p.style=D;exports.nylas_open_hours_picker=p;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { r as y, c as i, h as d, H as g, g as C } from "./index-4f65b6f9.js";
|
|
2
|
+
import { N as m, e as S } from "./index-2b85580a-f9211f23.js";
|
|
3
|
+
import { d as a } from "./utils-5074a070-ce33ee6b.js";
|
|
4
|
+
import { C as A, a as b, H as f, N as p, b as v, c as P, d as _ } from "./mailbox-store-0019772c-06d31a90.js";
|
|
5
|
+
import { C as N, N as w } from "./scheduler-store-5a39585a-117668e3.js";
|
|
6
|
+
import "react";
|
|
7
|
+
import "react-dom";
|
|
8
|
+
class x {
|
|
9
|
+
constructor(e, s, r, h, o, n = "https://scheduler.nylas.com") {
|
|
10
|
+
this.router = e, this.schedulerAPIURL = n, this.nylasAuth = s, this.nylasAuthStore = r, this.nylasMailboxStore = h, this.nylasSchedulerStore = o;
|
|
11
|
+
}
|
|
12
|
+
init() {
|
|
13
|
+
a("NylasConnector init");
|
|
14
|
+
}
|
|
15
|
+
get authStore() {
|
|
16
|
+
return this.nylasAuthStore;
|
|
17
|
+
}
|
|
18
|
+
get mailboxStore() {
|
|
19
|
+
return this.nylasMailboxStore;
|
|
20
|
+
}
|
|
21
|
+
get schedulerStore() {
|
|
22
|
+
return this.nylasSchedulerStore;
|
|
23
|
+
}
|
|
24
|
+
get auth() {
|
|
25
|
+
return this._authConnector ? this._authConnector : (this._authConnector = new p(this.nylasAuth, this.nylasAuthStore), this._authConnector);
|
|
26
|
+
}
|
|
27
|
+
get threads() {
|
|
28
|
+
return this._threadConnector ? this._threadConnector : (this._threadConnector = new v(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore, this.router), this._threadConnector);
|
|
29
|
+
}
|
|
30
|
+
get messages() {
|
|
31
|
+
return this._messageConnector ? this._messageConnector : (this._messageConnector = new P(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._messageConnector);
|
|
32
|
+
}
|
|
33
|
+
get folders() {
|
|
34
|
+
return this._foldersConnector ? this._foldersConnector : (this._foldersConnector = new _(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._foldersConnector);
|
|
35
|
+
}
|
|
36
|
+
get scheduler() {
|
|
37
|
+
return this._schedulerAPIConnector ? this._schedulerAPIConnector : (this._schedulerAPIConnector = new w({
|
|
38
|
+
schedulerAPIURL: this.schedulerAPIURL,
|
|
39
|
+
schedulerStore: this.schedulerStore
|
|
40
|
+
}), this._schedulerAPIConnector);
|
|
41
|
+
}
|
|
42
|
+
getAuth() {
|
|
43
|
+
return this.nylasAuth;
|
|
44
|
+
}
|
|
45
|
+
resetStores() {
|
|
46
|
+
this.nylasAuthStore.reset(), this.nylasMailboxStore.reset();
|
|
47
|
+
}
|
|
48
|
+
async logout() {
|
|
49
|
+
await this.nylasAuth.logout(), this.resetStores();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const I = ":host{display:contents}", M = I, L = class {
|
|
53
|
+
constructor(t) {
|
|
54
|
+
y(this, t), this.init = i(this, "init", 7), this.loggedIn = i(this, "loggedIn", 7), this.loggedOut = i(this, "loggedOut", 7), this.handleAuthChange = async (e) => {
|
|
55
|
+
e ? this.loggedIn.emit(this.host) : this.loggedOut.emit(this.host);
|
|
56
|
+
}, this.authConfig = void 0, this.eventOverrides = {}, this.automaticComponentRegistration = !0;
|
|
57
|
+
}
|
|
58
|
+
connectedCallback() {
|
|
59
|
+
a("[nylas-provider] connectedCallback");
|
|
60
|
+
}
|
|
61
|
+
async componentWillLoad() {
|
|
62
|
+
var o, n, l, c, u;
|
|
63
|
+
a("[nylas-provider] componentWillLoad"), this.stores = {
|
|
64
|
+
auth: A(),
|
|
65
|
+
mailbox: b(),
|
|
66
|
+
scheduler: N()
|
|
67
|
+
}, this.baseProvider = new m(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides);
|
|
68
|
+
const t = new f();
|
|
69
|
+
this.nylasAuth = S({
|
|
70
|
+
apiUri: "https://api.us.nylas.com",
|
|
71
|
+
elementsApiUri: "https://elements.us.nylas.com",
|
|
72
|
+
storageType: "indexeddb",
|
|
73
|
+
clientId: "YOUR_CLIENT_ID",
|
|
74
|
+
defaultScopes: [],
|
|
75
|
+
redirectURI: "/",
|
|
76
|
+
...this.authConfig
|
|
77
|
+
});
|
|
78
|
+
const e = (o = this.baseProvider) == null ? void 0 : o.getStore("mailbox");
|
|
79
|
+
if (!e)
|
|
80
|
+
throw new Error("The mailbox store is not set");
|
|
81
|
+
const s = (n = this.baseProvider) == null ? void 0 : n.getStore("auth");
|
|
82
|
+
if (!s)
|
|
83
|
+
throw new Error("The auth store is not set");
|
|
84
|
+
const r = (l = this.baseProvider) == null ? void 0 : l.getStore("scheduler");
|
|
85
|
+
if (!r)
|
|
86
|
+
throw new Error("The scheduler store is not set");
|
|
87
|
+
this.nylasConnector = new x(t, this.nylasAuth, s, e, r), this.init.emit(this.host).defaultPrevented || await ((c = this.nylasConnector) == null ? void 0 : c.auth.validateSession()), this.handleAuthChange(s.state.isAuthenticated), (u = this.baseProvider) == null || u.componentWillLoad(this.nylasConnector);
|
|
88
|
+
}
|
|
89
|
+
componentDidLoad() {
|
|
90
|
+
var e, s;
|
|
91
|
+
const t = (e = this.baseProvider) == null ? void 0 : e.getStore("auth");
|
|
92
|
+
t == null || t.onChange("isAuthenticated", this.handleAuthChange), (s = this.baseProvider) == null || s.componentDidLoad();
|
|
93
|
+
}
|
|
94
|
+
componentDisconnected() {
|
|
95
|
+
var t;
|
|
96
|
+
(t = this.baseProvider) == null || t.componentDisconnected();
|
|
97
|
+
}
|
|
98
|
+
async registerComponentHandler(t) {
|
|
99
|
+
var e;
|
|
100
|
+
(e = this.baseProvider) == null || e.registerComponent(t.detail);
|
|
101
|
+
}
|
|
102
|
+
async unregisterComponentHandler(t) {
|
|
103
|
+
var e;
|
|
104
|
+
(e = this.baseProvider) == null || e.unregisterComponent(t.detail);
|
|
105
|
+
}
|
|
106
|
+
async getNylasAuth() {
|
|
107
|
+
return this.nylasAuth;
|
|
108
|
+
}
|
|
109
|
+
async getNylasConnector() {
|
|
110
|
+
return this.nylasConnector;
|
|
111
|
+
}
|
|
112
|
+
async getMailboxStore() {
|
|
113
|
+
var t;
|
|
114
|
+
return (t = this.baseProvider) == null ? void 0 : t.getStore("mailbox");
|
|
115
|
+
}
|
|
116
|
+
async getAuthStore() {
|
|
117
|
+
var t;
|
|
118
|
+
return (t = this.baseProvider) == null ? void 0 : t.getStore("auth");
|
|
119
|
+
}
|
|
120
|
+
async getNylasSchedulerStore() {
|
|
121
|
+
var t;
|
|
122
|
+
return (t = this.baseProvider) == null ? void 0 : t.getStore("scheduler");
|
|
123
|
+
}
|
|
124
|
+
render() {
|
|
125
|
+
return d(g, { key: "ff2cfa488faf8587aae9b577b59f536921dc125a" }, d("slot", { key: "a5faaff431a3140912330969ea744fbc1519c121" }));
|
|
126
|
+
}
|
|
127
|
+
get host() {
|
|
128
|
+
return C(this);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
L.style = M;
|
|
132
|
+
export {
|
|
133
|
+
L as nylas_provider
|
|
134
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-29d0e781.cjs"),y=require("./index-2b85580a-bfc3ceac.cjs"),a=require("./utils-5074a070-d5ba6add.cjs"),o=require("./mailbox-store-0019772c-d1254c5c.cjs"),g=require("./scheduler-store-5a39585a-2c848bec.cjs");require("react");require("react-dom");class S{constructor(t,s,n,l,i,h="https://scheduler.nylas.com"){this.router=t,this.schedulerAPIURL=h,this.nylasAuth=s,this.nylasAuthStore=n,this.nylasMailboxStore=l,this.nylasSchedulerStore=i}init(){a.debug("NylasConnector init")}get authStore(){return this.nylasAuthStore}get mailboxStore(){return this.nylasMailboxStore}get schedulerStore(){return this.nylasSchedulerStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new o.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new o.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new o.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new o.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}get scheduler(){return this._schedulerAPIConnector?this._schedulerAPIConnector:(this._schedulerAPIConnector=new g.NylaSchedulerAPIConnector({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore}),this._schedulerAPIConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasAuthStore.reset(),this.nylasMailboxStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const b=":host{display:contents}",m=b,C=class{constructor(e){r.registerInstance(this,e),this.init=r.createEvent(this,"init",7),this.loggedIn=r.createEvent(this,"loggedIn",7),this.loggedOut=r.createEvent(this,"loggedOut",7),this.handleAuthChange=async t=>{t?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host)},this.authConfig=void 0,this.eventOverrides={},this.automaticComponentRegistration=!0}connectedCallback(){a.debug("[nylas-provider] connectedCallback")}async componentWillLoad(){var i,h,c,u,d;a.debug("[nylas-provider] componentWillLoad"),this.stores={auth:o.CreateNylasAuthStore(),mailbox:o.CreateNylasMailboxStore(),scheduler:g.CreateNylasSchedulerStore()},this.baseProvider=new y.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const e=new o.HashRouter;this.nylasAuth=y.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const t=(i=this.baseProvider)==null?void 0:i.getStore("mailbox");if(!t)throw new Error("The mailbox store is not set");const s=(h=this.baseProvider)==null?void 0:h.getStore("auth");if(!s)throw new Error("The auth store is not set");const n=(c=this.baseProvider)==null?void 0:c.getStore("scheduler");if(!n)throw new Error("The scheduler store is not set");this.nylasConnector=new S(e,this.nylasAuth,s,t,n),this.init.emit(this.host).defaultPrevented||await((u=this.nylasConnector)==null?void 0:u.auth.validateSession()),this.handleAuthChange(s.state.isAuthenticated),(d=this.baseProvider)==null||d.componentWillLoad(this.nylasConnector)}componentDidLoad(){var t,s;const e=(t=this.baseProvider)==null?void 0:t.getStore("auth");e==null||e.onChange("isAuthenticated",this.handleAuthChange),(s=this.baseProvider)==null||s.componentDidLoad()}componentDisconnected(){var e;(e=this.baseProvider)==null||e.componentDisconnected()}async registerComponentHandler(e){var t;(t=this.baseProvider)==null||t.registerComponent(e.detail)}async unregisterComponentHandler(e){var t;(t=this.baseProvider)==null||t.unregisterComponent(e.detail)}async getNylasAuth(){return this.nylasAuth}async getNylasConnector(){return this.nylasConnector}async getMailboxStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("mailbox")}async getAuthStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("auth")}async getNylasSchedulerStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("scheduler")}render(){return r.h(r.Host,{key:"ff2cfa488faf8587aae9b577b59f536921dc125a"},r.h("slot",{key:"a5faaff431a3140912330969ea744fbc1519c121"}))}get host(){return r.getElement(this)}};C.style=m;exports.nylas_provider=C;
|