@nylas/react 1.0.0-prealpha1 → 1.0.2-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/dist/add-circle-icon.entry-2ccb238b.cjs +1 -0
- package/dist/add-circle-icon.entry-35d6aa07.js +15 -0
- package/dist/{archive-icon_7.entry-8c90815a.cjs → archive-icon_7.entry-84d70dbf.cjs} +1 -1
- package/dist/{archive-icon_7.entry-53aede1b.js → archive-icon_7.entry-91aaa1aa.js} +16 -16
- package/dist/{arrow-icon.entry-a2f53919.cjs → arrow-icon.entry-400a08fa.cjs} +1 -1
- package/dist/{arrow-icon.entry-2867f4fb.js → arrow-icon.entry-8b2e96a6.js} +4 -4
- package/dist/{bold-icon_3.entry-ad806730.js → bold-icon_3.entry-4b2798a8.js} +6 -6
- package/dist/{bold-icon_3.entry-e0bc6774.cjs → bold-icon_3.entry-9ad35153.cjs} +1 -1
- package/dist/{calendar-cancel-icon.entry-74051835.js → calendar-cancel-icon.entry-83ba884a.js} +5 -5
- package/dist/{calendar-cancel-icon.entry-546b7bd4.cjs → calendar-cancel-icon.entry-fcb66929.cjs} +1 -1
- package/dist/{calendar-check-icon_3.entry-42bab0b4.js → calendar-check-icon_3.entry-903e2d82.js} +4 -4
- package/dist/{calendar-check-icon_3.entry-f5846fee.cjs → calendar-check-icon_3.entry-a16ce05e.cjs} +1 -1
- package/dist/{calendar-icon.entry-25474b1e.cjs → calendar-icon.entry-7bae38d7.cjs} +1 -1
- package/dist/{calendar-icon.entry-c751873f.js → calendar-icon.entry-8f38af4a.js} +5 -5
- package/dist/chevron-icon.entry-58366662.cjs +1 -0
- package/dist/chevron-icon.entry-5e11cef5.js +15 -0
- package/dist/close-icon_2.entry-011d9cf4.js +25 -0
- package/dist/{close-icon_2.entry-aa015993.cjs → close-icon_2.entry-83088b9a.cjs} +1 -1
- package/dist/{document-refresh-icon.entry-ca2ef29e.cjs → document-refresh-icon.entry-071ffd66.cjs} +1 -1
- package/dist/{document-refresh-icon.entry-b27207eb.js → document-refresh-icon.entry-9083a2e9.js} +5 -5
- package/dist/elements/index.d.ts +4 -0
- package/dist/{elements-60ebdb01-24595598.cjs → elements-dc5b338e-81a0319c.cjs} +577 -555
- package/dist/{elements-60ebdb01-5d144002.js → elements-dc5b338e-fb5dbfb5.js} +3339 -2763
- package/dist/{forward-icon_6.entry-725d1be4.cjs → forward-icon_6.entry-3345af84.cjs} +3 -3
- package/dist/{forward-icon_6.entry-dc8f7235.js → forward-icon_6.entry-b60fcb35.js} +127 -127
- package/dist/{globe-icon.entry-918cfd35.cjs → globe-icon.entry-8325e73e.cjs} +1 -1
- package/dist/{globe-icon.entry-796d3f48.js → globe-icon.entry-e3fd373f.js} +4 -4
- package/dist/index-3b6f5cd5.cjs +30 -0
- package/dist/{index-4f65b6f9.js → index-630f4e87.js} +410 -401
- package/dist/{index-2b85580a-f9211f23.js → index-b30d446a-a90f84b2.js} +4 -9
- package/dist/{index-2b85580a-bfc3ceac.cjs → index-b30d446a-cbbef925.cjs} +1 -1
- package/dist/{loading-icon.entry-8e49fab0.js → loading-icon.entry-27410cf8.js} +4 -4
- package/dist/loading-icon.entry-b2096d2b.cjs +1 -0
- package/dist/{mailbox-store-0019772c-d1254c5c.cjs → mailbox-store-19f0c6c9-a0cbfa97.cjs} +1 -1
- package/dist/{mailbox-store-0019772c-06d31a90.js → mailbox-store-19f0c6c9-e3e8b4e5.js} +1 -1
- package/dist/{nylas-booked-event-card_9.entry-d995d7cb.js → nylas-booked-event-card_10.entry-7e66a648.js} +1818 -1927
- package/dist/{nylas-booked-event-card_9.entry-ea02f083.cjs → nylas-booked-event-card_10.entry-ed515326.cjs} +6 -139
- package/dist/{nylas-if-state_3.entry-e8c831b7.cjs → nylas-if-state_3.entry-504be976.cjs} +1 -1
- package/dist/{nylas-if-state_3.entry-ce816adb.js → nylas-if-state_3.entry-e96d01f1.js} +6 -6
- package/dist/{nylas-list-folders.entry-de8cca60.cjs → nylas-list-folders.entry-866361cc.cjs} +1 -1
- package/dist/{nylas-list-folders.entry-8134344b.js → nylas-list-folders.entry-a5437201.js} +3 -3
- package/dist/{nylas-list-threads.entry-93b70a1a.cjs → nylas-list-threads.entry-04989295.cjs} +1 -1
- package/dist/{nylas-list-threads.entry-1367fe30.js → nylas-list-threads.entry-fd6cda61.js} +3 -3
- package/dist/{nylas-mailbox-pagination.entry-568ac217.js → nylas-mailbox-pagination.entry-988214bc.js} +2 -2
- package/dist/{nylas-mailbox-pagination.entry-6bb0ee37.cjs → nylas-mailbox-pagination.entry-e0bd4aef.cjs} +1 -1
- package/dist/{nylas-mailbox-toolbar-button.entry-d4ad5c15.cjs → nylas-mailbox-toolbar-button.entry-3d772b26.cjs} +1 -1
- package/dist/{nylas-mailbox-toolbar-button.entry-9214b283.js → nylas-mailbox-toolbar-button.entry-c720e22a.js} +8 -8
- package/dist/{nylas-open-hours-picker.entry-109f13f5.js → nylas-open-hours-picker.entry-6bdc7c73.js} +58 -58
- package/dist/{nylas-open-hours-picker.entry-2c19643f.cjs → nylas-open-hours-picker.entry-881b6db7.cjs} +1 -1
- package/dist/{nylas-provider.entry-2cfe5f0e.js → nylas-provider.entry-70721009.js} +7 -7
- package/dist/{nylas-provider.entry-87fa9276.cjs → nylas-provider.entry-8d9a844b.cjs} +1 -1
- package/dist/nylas-scheduler.entry-7321e18f.js +230 -0
- package/dist/nylas-scheduler.entry-e82977fb.cjs +1 -0
- package/dist/{nylas-threads-refresh.entry-6d61a689.cjs → nylas-threads-refresh.entry-477e68e4.cjs} +1 -1
- package/dist/{nylas-threads-refresh.entry-9111a403.js → nylas-threads-refresh.entry-b7f9e93f.js} +4 -4
- package/dist/{nylas-threads-search.entry-2124f663.js → nylas-threads-search.entry-95afea9c.js} +12 -12
- package/dist/nylas-threads-search.entry-c5854641.cjs +1 -0
- package/dist/{nylas-view-thread.entry-fe51c1f6.js → nylas-view-thread.entry-165173b1.js} +3 -3
- package/dist/{nylas-view-thread.entry-4ecbcd78.cjs → nylas-view-thread.entry-8b72cbdb.cjs} +1 -1
- package/dist/play-icon_2.entry-ed5877e3.js +25 -0
- package/dist/play-icon_2.entry-f23ed6c1.cjs +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.js +57 -53
- package/dist/{refresh-icon.entry-9f24e833.cjs → refresh-icon.entry-601cac89.cjs} +1 -1
- package/dist/{refresh-icon.entry-4ddd53b0.js → refresh-icon.entry-e48a338f.js} +4 -4
- package/dist/{register-component-55376f31-8d6ddee4.cjs → register-component-152c6ad2-0df7215b.cjs} +1 -1
- package/dist/{register-component-55376f31-5eaf8954.js → register-component-152c6ad2-a06f58c2.js} +1 -1
- package/dist/scheduler-store-7d48e682-0c0c3991.js +289 -0
- package/dist/scheduler-store-7d48e682-674705ef.cjs +1 -0
- package/dist/search-icon_3.entry-292138c3.js +101 -0
- package/dist/search-icon_3.entry-8e555357.cjs +1 -0
- package/package.json +1 -1
- package/dist/chevron-icon.entry-60842fb6.js +0 -15
- package/dist/chevron-icon.entry-97e4621e.cjs +0 -1
- package/dist/close-icon_2.entry-ef03bd27.js +0 -25
- package/dist/index-29d0e781.cjs +0 -30
- package/dist/loading-icon.entry-b2534e3e.cjs +0 -1
- package/dist/nylas-scheduler.entry-6ec8e574.js +0 -195
- package/dist/nylas-scheduler.entry-b41cbf99.cjs +0 -1
- package/dist/nylas-threads-search.entry-03073490.cjs +0 -1
- package/dist/play-icon_2.entry-8e156535.js +0 -25
- package/dist/play-icon_2.entry-cf1cbc8d.cjs +0 -1
- package/dist/property-0065dde7-83dc9cc4.cjs +0 -23
- package/dist/property-0065dde7-c57b8fa3.js +0 -589
- package/dist/scheduler-store-5a39585a-117668e3.js +0 -173
- package/dist/scheduler-store-5a39585a-2c848bec.cjs +0 -1
- package/dist/translate-icon.entry-0cd24de4.cjs +0 -1
- package/dist/translate-icon.entry-db2cdf1d.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-29d0e781.cjs"),M=require("./register-component-55376f31-8d6ddee4.cjs"),h=require("./utils-5074a070-d5ba6add.cjs"),A=require("./index-2b85580a-bfc3ceac.cjs"),c=require("./mailbox-store-0019772c-d1254c5c.cjs");require("react");require("react-dom");const P=":host{display:block}div{height:inherit}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.fade-in{animation:fadeIn 1.5s}.fade-out{animation:fadeOut 1.5s}@keyframes slideIn{0%{transform:translateY(100%)}100%{transform:translateY(0)}}@keyframes slideOut{0%{transform:translateY(0)}100%{transform:translateY(100%)}}.slide-in{animation:slideIn 1.5s}.slide-out{animation:slideOut 1.5s}@keyframes swipeIn{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes swipeOut{0%{transform:translateX(0)}100%{transform:translateX(100%)}}.swipe-in{animation:swipeIn 1.5s}.swipe-out{animation:swipeOut 1.5s}",N=P;var L=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},y=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const p=class{constructor(e){o.registerInstance(this,e),this.state=void 0,this.isStateSet=void 0,this.isBoolean=void 0,this.getStore=void 0,this.transition="none",this.show=!1,this.classes={},this.initTransition=this.initTransition.bind(this)}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){h.debug("[nylas-if-state] Component will load"),this.watchStore(!0)}async componentDidLoad(){h.debug("[nylas-if-state] Component did load")}shouldRender(){const[e,t]=this.state?this.state.split("."):["",""],n=this.getStore;if(typeof n>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{getStore:n}),!1;const s=n(e);if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{store:s}),!1;const i=s.state[t];return typeof this.isStateSet=="boolean"?this.isStateSet===!1&&(typeof i>"u"||i===null||i.length===0)||this.isStateSet===!0&&typeof i<"u"&&i!==null:typeof this.isBoolean=="boolean"?this.isBoolean===!0&&typeof i<"u"&&i===!0||this.isBoolean===!1&&typeof i<"u"&&i===!1:!1}onGetStoreChange(){this.watchStore(!0)}watchStore(e=!1){const[t,n]=this.state?this.state.split("."):["",""],s=this.getStore;if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{getStore:s}),null;const i=s(t);if(typeof i>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{store:i}),null;e===!0&&this.initTransition(),i.onChange(n,this.initTransition)}initTransition(){const e=this.shouldRender();switch(this.transition){case"fade":case"slide":case"swipe":this.classes={[`${this.transition}-in`]:e,[`${this.transition}-out`]:!e},setTimeout(()=>{this.show=e},150);break;default:this.show=this.shouldRender();break}}render(){return o.h(o.Host,{key:"91d17bc89a09742106ef3bd9365c5ce48cf14e86"},o.h("div",{key:"9d0070be4bf5d9a5f405fc4a0733e6d832fa669a",class:this.classes},this.show&&o.h("slot",null)))}static get watchers(){return{getStore:["onGetStoreChange"]}}};L([M.RegisterComponent({name:"nylas-if-state",getStoresToProp:"getStore",fireRegisterEvent:!0}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],p.prototype,"render",null);p.style=N;const T=":host{font-family:'Arial', sans-serif;background:var(--nylas-color-primary-50);color:var(--nylas-color-primary-800);margin:0;display:contents}input{box-sizing:border-box}.login-container{display:flex;justify-content:center;align-items:center;height:100%}.login-box{width:300px;padding:20px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border-radius:var(--nylas-border-radius-2x);background:var(--nylas-color-primary-50);text-align:center}.login-box h1{margin-top:0;margin-bottom:0.5em}.login-box p{margin-bottom:1em}.login-methods button{display:block;width:100%;padding:10px 10px 10px 50px;margin-bottom:10px;border:none;border-radius:var(--nylas-border-radius);border:1px solid var(--nylas-color-primary-300);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-600);cursor:pointer;transition:background 0.3s ease;position:relative;text-align:left}.login-methods button svg{position:absolute;left:16px;top:50%;transform:translateY(-50%)}.login-methods button:hover{background:var(--nylas-color-primary-200);}.login-form label{display:block;margin-bottom:5px;text-align:left}.login-form input{width:100%;padding:10px;margin-bottom:10px;border:1px solid var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-800);}.login-form button{width:100%;padding:10px;border:none;border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-500);color:var(--nylas-color-primary-50);cursor:pointer;transition:background 0.3s ease}.login-form button:hover{background:var(--nylas-color-primary-600);}",I=T;var O=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},m=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const b=class{constructor(e){o.registerInstance(this,e),this.buttonClick=o.createEvent(this,"buttonClick",7),this._handleLoginRedirect=async()=>{var s;const t=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes));this.buttonClick.emit({url:t}).defaultPrevented||t&&(window.location.href=t)},this._onGoogleButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"google"));n&&(window.location.href=n)},this._onMicrosoftButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"microsoft"));n&&(window.location.href=n)},this._onFormSubmit=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,this.email));n&&(window.location.href=n)},this.isAuthenticated=!1,this.nylasConnector=void 0,this.scopes=void 0,this.loginMethod="redirect",this.companyName="Nylas",this.logoUrl="https://www.nylas.com/wp-content/uploads/main-logo.svg",this.logoWidth="min-content",this.providers="google,microsoft",this.buttonText="Login",this.email=""}connectedCallback(){}disconnectedCallback(){}componentWillLoad(){}async componentDidLoad(){var t;await((t=this.nylasConnector)==null?void 0:t.auth.manageHostedAuthCodeExchange(window.location.href))&&window.history.replaceState({},document.title,window.location.pathname)}render(){var t;const e=((t=this.providers)==null?void 0:t.split(","))||[];return o.h(o.Host,{key:"734ebbbe5cf2ba3c08943a665a4724f59705da5b"},this.loginMethod==="redirect"&&o.h("div",{class:"redirect-container"},!this.isAuthenticated&&o.h("sp-button",{part:"button",onClick:this._handleLoginRedirect},this.buttonText)),this.loginMethod==="emebded"&&o.h("main",{class:"login-container"},o.h("section",{class:"login-box"},o.h("header",null,o.h("img",{src:this.logoUrl,alt:`${this.companyName} logo`,width:"100%",style:{minWidth:this.logoWidth}}),o.h("h1",null,"Welcome")),o.h("p",null,"Log in to your account to continue to ",this.companyName),o.h("div",{class:"login-methods"},e.includes("google")&&o.h("button",{class:"login-google",onClick:this._onGoogleButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 256 262"},o.h("path",{fill:"#4285F4",d:"M255.6 131.6c0-8.2-.8-16.2-2.2-23.9H130v45.3h70.3c-3 16.1-12.4 29.7-26.3 38.9v32.4h42.6c25-23 39.4-56.7 39.4-97.7z"}),o.h("path",{fill:"#34A853",d:"M130 262c35.3 0 64.9-11.7 86.5-31.7l-42.6-32.4c-11.7 7.9-26.7 12.6-43.9 12.6-33.7 0-62.3-22.7-72.5-53.4H14.5v33.3A130.3 130.3 0 00130 262z"}),o.h("path",{fill:"#FBBC05",d:"M57.5 158.1a72.7 72.7 0 010-54.2V70.6H14.5a130.4 130.4 0 000 120.8l43-33.3z"}),o.h("path",{fill:"#EA4335",d:"M130 51.6c19 0 36 6.5 49.4 19.2l37-36C195 13.1 165.2 0 130 0A130.3 130.3 0 0014.5 70.6l43 33.3c10.2-30.7 38.8-53.3 72.5-53.3z"})),"Continue with Google"),e.includes("microsoft")&&o.h("button",{class:"login-microsoft",onClick:this._onMicrosoftButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 448 512"},o.h("path",{fill:"#F3F3F3",d:"M0 32v192h192V32H0zm256 0v192h192V32H256zm192 256v192h-192V288h192zM0 224v192h192V224H0z"})),"Continue with Microsoft")),o.h("form",{class:"login-form",method:"POST",onSubmit:this._onFormSubmit},o.h("label",{htmlFor:"email"},"Email"),o.h("input",{type:"email",id:"email",name:"email",required:!0,value:this.email}),o.h("button",{type:"submit"},"Next")))))}};O([M.RegisterComponent({name:"nylas-login",connectorToProp:"nylasConnector",stateToProps:new Map([["auth.isAuthenticated","isAuthenticated"]]),fireRegisterEvent:!0}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",void 0)],b.prototype,"render",null);b.style=I;class E{constructor(t,n,s,i){this.router=t,this.nylasAuth=n,this.nylasAuthStore=s,this.nylasMailboxStore=i}init(){h.debug("NylasMailboxConnector init")}get mailboxStore(){return this.nylasMailboxStore}get authStore(){return this.nylasAuthStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new c.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new c.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new c.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new c.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasMailboxStore.reset(),this.nylasAuthStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const H=":host{display:contents}",B=H,_=class{constructor(e){o.registerInstance(this,e),this.init=o.createEvent(this,"init",7),this.loggedIn=o.createEvent(this,"loggedIn",7),this.loggedOut=o.createEvent(this,"loggedOut",7),this.handleAuthChange=async t=>{var n;t?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host).defaultPrevented||await((n=this.nylasMailboxConnector)==null?void 0:n.logout())},this.automaticComponentRegistration=!0,this.eventOverrides={},this.authConfig=void 0,this.defaultAuthStoreState=void 0,this.defaultMailboxStoreState=void 0}connectedCallback(){h.debug("[nylas-mailbox] connectedCallback")}async componentWillLoad(){var s,i,a,r,l,v,C;this.stores={auth:c.CreateNylasAuthStore(this.defaultAuthStoreState),mailbox:c.CreateNylasMailboxStore(this.defaultMailboxStoreState)},this.baseProvider=new A.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.router=new c.HashRouter,this.nylasAuth=A.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const e=(s=this.baseProvider)==null?void 0:s.getStore("auth");if(!e)throw new Error("Auth store is not defined");const t=(i=this.baseProvider)==null?void 0:i.getStore("mailbox");if(!t)throw new Error("Mailbox store is not defined");this.nylasMailboxConnector=new E(this.router,this.nylasAuth,e,t),this.init.emit(this.host).defaultPrevented||await((a=this.nylasMailboxConnector)==null?void 0:a.auth.validateSession()),(r=this.router)==null||r.addRouteChangeListener("/thread/:threadId",async(R,k,w)=>{var u,f;const g=w.threadId,d=await((u=this.nylasMailboxConnector)==null?void 0:u.threads.getThread(g));d&&((f=this.nylasMailboxConnector)==null||f.mailboxStore.set("selectedThread",d))}),(l=this.router)==null||l.addRouteChangeListener("/",async(R,k,w)=>{var d,u,f,S;if(!e.state.isAuthenticated)return;(d=this.nylasMailboxConnector)==null||d.threads.unSelectThread(),(u=this.nylasMailboxConnector)==null||u.folders.getFolders();const g=window.location.hash.split("?")[1];if(g){const x=new URLSearchParams(g).get("query");x&&await((f=this.nylasMailboxConnector)==null?void 0:f.threads.getThreads({search_query_native:x,page_token:void 0}))}else(S=this.nylasMailboxConnector)==null||S.threads.getThreads()}),(v=this.router)==null||v.init(),this.handleAuthChange(e.state.isAuthenticated),(C=this.baseProvider)==null||C.componentWillLoad(this.nylasMailboxConnector)}async componentDidLoad(){var t,n;const e=(t=this.baseProvider)==null?void 0:t.getStore("auth");if(!e)throw new Error("Auth store is not defined");e.onChange("isAuthenticated",this.handleAuthChange),(n=this.baseProvider)==null||n.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 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 getNylasAuth(){return this.nylasAuth}async getNylasMailboxConnector(){return this.nylasMailboxConnector}render(){return o.h(o.Host,{key:"08e87a3218f672e8944102d626b690aefb3bab3f"},o.h("slot",{key:"05ab1ca1539a00ea199bb9cb25c8b96af8d6ab66"}))}get host(){return o.getElement(this)}};_.style=B;exports.nylas_if_state=p;exports.nylas_login=b;exports.nylas_mailbox=_;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-3b6f5cd5.cjs"),M=require("./register-component-152c6ad2-0df7215b.cjs"),h=require("./utils-5074a070-d5ba6add.cjs"),A=require("./index-b30d446a-cbbef925.cjs"),c=require("./mailbox-store-19f0c6c9-a0cbfa97.cjs");require("react");require("react-dom");const P=":host{display:block}div{height:inherit}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.fade-in{animation:fadeIn 1.5s}.fade-out{animation:fadeOut 1.5s}@keyframes slideIn{0%{transform:translateY(100%)}100%{transform:translateY(0)}}@keyframes slideOut{0%{transform:translateY(0)}100%{transform:translateY(100%)}}.slide-in{animation:slideIn 1.5s}.slide-out{animation:slideOut 1.5s}@keyframes swipeIn{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes swipeOut{0%{transform:translateX(0)}100%{transform:translateX(100%)}}.swipe-in{animation:swipeIn 1.5s}.swipe-out{animation:swipeOut 1.5s}",N=P;var L=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},y=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const p=class{constructor(e){o.registerInstance(this,e),this.state=void 0,this.isStateSet=void 0,this.isBoolean=void 0,this.getStore=void 0,this.transition="none",this.show=!1,this.classes={},this.initTransition=this.initTransition.bind(this)}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){h.debug("[nylas-if-state] Component will load"),this.watchStore(!0)}async componentDidLoad(){h.debug("[nylas-if-state] Component did load")}shouldRender(){const[e,t]=this.state?this.state.split("."):["",""],n=this.getStore;if(typeof n>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{getStore:n}),!1;const s=n(e);if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{store:s}),!1;const i=s.state[t];return typeof this.isStateSet=="boolean"?this.isStateSet===!1&&(typeof i>"u"||i===null||i.length===0)||this.isStateSet===!0&&typeof i<"u"&&i!==null:typeof this.isBoolean=="boolean"?this.isBoolean===!0&&typeof i<"u"&&i===!0||this.isBoolean===!1&&typeof i<"u"&&i===!1:!1}onGetStoreChange(){this.watchStore(!0)}watchStore(e=!1){const[t,n]=this.state?this.state.split("."):["",""],s=this.getStore;if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{getStore:s}),null;const i=s(t);if(typeof i>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{store:i}),null;e===!0&&this.initTransition(),i.onChange(n,this.initTransition)}initTransition(){const e=this.shouldRender();switch(this.transition){case"fade":case"slide":case"swipe":this.classes={[`${this.transition}-in`]:e,[`${this.transition}-out`]:!e},setTimeout(()=>{this.show=e},150);break;default:this.show=this.shouldRender();break}}render(){return o.h(o.Host,{key:"91d17bc89a09742106ef3bd9365c5ce48cf14e86"},o.h("div",{key:"9d0070be4bf5d9a5f405fc4a0733e6d832fa669a",class:this.classes},this.show&&o.h("slot",null)))}static get watchers(){return{getStore:["onGetStoreChange"]}}};L([M.RegisterComponent({name:"nylas-if-state",getStoresToProp:"getStore",fireRegisterEvent:!0}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],p.prototype,"render",null);p.style=N;const T=":host{font-family:'Arial', sans-serif;background:var(--nylas-color-primary-50);color:var(--nylas-color-primary-800);margin:0;display:contents}input{box-sizing:border-box}.login-container{display:flex;justify-content:center;align-items:center;height:100%}.login-box{width:300px;padding:20px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border-radius:var(--nylas-border-radius-2x);background:var(--nylas-color-primary-50);text-align:center}.login-box h1{margin-top:0;margin-bottom:0.5em}.login-box p{margin-bottom:1em}.login-methods button{display:block;width:100%;padding:10px 10px 10px 50px;margin-bottom:10px;border:none;border-radius:var(--nylas-border-radius);border:1px solid var(--nylas-color-primary-300);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-600);cursor:pointer;transition:background 0.3s ease;position:relative;text-align:left}.login-methods button svg{position:absolute;left:16px;top:50%;transform:translateY(-50%)}.login-methods button:hover{background:var(--nylas-color-primary-200);}.login-form label{display:block;margin-bottom:5px;text-align:left}.login-form input{width:100%;padding:10px;margin-bottom:10px;border:1px solid var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-800);}.login-form button{width:100%;padding:10px;border:none;border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-500);color:var(--nylas-color-primary-50);cursor:pointer;transition:background 0.3s ease}.login-form button:hover{background:var(--nylas-color-primary-600);}",I=T;var O=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},m=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const b=class{constructor(e){o.registerInstance(this,e),this.buttonClick=o.createEvent(this,"buttonClick",7),this._handleLoginRedirect=async()=>{var s;const t=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes));this.buttonClick.emit({url:t}).defaultPrevented||t&&(window.location.href=t)},this._onGoogleButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"google"));n&&(window.location.href=n)},this._onMicrosoftButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"microsoft"));n&&(window.location.href=n)},this._onFormSubmit=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,this.email));n&&(window.location.href=n)},this.isAuthenticated=!1,this.nylasConnector=void 0,this.scopes=void 0,this.loginMethod="redirect",this.companyName="Nylas",this.logoUrl="https://www.nylas.com/wp-content/uploads/main-logo.svg",this.logoWidth="min-content",this.providers="google,microsoft",this.buttonText="Login",this.email=""}connectedCallback(){}disconnectedCallback(){}componentWillLoad(){}async componentDidLoad(){var t;await((t=this.nylasConnector)==null?void 0:t.auth.manageHostedAuthCodeExchange(window.location.href))&&window.history.replaceState({},document.title,window.location.pathname)}render(){var t;const e=((t=this.providers)==null?void 0:t.split(","))||[];return o.h(o.Host,{key:"a0b36443906ea5244070e6d0eece3794b1d1d3d5"},this.loginMethod==="redirect"&&o.h("div",{class:"redirect-container"},!this.isAuthenticated&&o.h("sp-button",{part:"button",onClick:this._handleLoginRedirect},this.buttonText)),this.loginMethod==="emebded"&&o.h("main",{class:"login-container"},o.h("section",{class:"login-box"},o.h("header",null,o.h("img",{src:this.logoUrl,alt:`${this.companyName} logo`,width:"100%",style:{minWidth:this.logoWidth}}),o.h("h1",null,"Welcome")),o.h("p",null,"Log in to your account to continue to ",this.companyName),o.h("div",{class:"login-methods"},e.includes("google")&&o.h("button",{class:"login-google",onClick:this._onGoogleButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 256 262"},o.h("path",{fill:"#4285F4",d:"M255.6 131.6c0-8.2-.8-16.2-2.2-23.9H130v45.3h70.3c-3 16.1-12.4 29.7-26.3 38.9v32.4h42.6c25-23 39.4-56.7 39.4-97.7z"}),o.h("path",{fill:"#34A853",d:"M130 262c35.3 0 64.9-11.7 86.5-31.7l-42.6-32.4c-11.7 7.9-26.7 12.6-43.9 12.6-33.7 0-62.3-22.7-72.5-53.4H14.5v33.3A130.3 130.3 0 00130 262z"}),o.h("path",{fill:"#FBBC05",d:"M57.5 158.1a72.7 72.7 0 010-54.2V70.6H14.5a130.4 130.4 0 000 120.8l43-33.3z"}),o.h("path",{fill:"#EA4335",d:"M130 51.6c19 0 36 6.5 49.4 19.2l37-36C195 13.1 165.2 0 130 0A130.3 130.3 0 0014.5 70.6l43 33.3c10.2-30.7 38.8-53.3 72.5-53.3z"})),"Continue with Google"),e.includes("microsoft")&&o.h("button",{class:"login-microsoft",onClick:this._onMicrosoftButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 448 512"},o.h("path",{fill:"#F3F3F3",d:"M0 32v192h192V32H0zm256 0v192h192V32H256zm192 256v192h-192V288h192zM0 224v192h192V224H0z"})),"Continue with Microsoft")),o.h("form",{class:"login-form",method:"POST",onSubmit:this._onFormSubmit},o.h("label",{htmlFor:"email"},"Email"),o.h("input",{type:"email",id:"email",name:"email",required:!0,value:this.email}),o.h("button",{type:"submit"},"Next")))))}};O([M.RegisterComponent({name:"nylas-login",connectorToProp:"nylasConnector",stateToProps:new Map([["auth.isAuthenticated","isAuthenticated"]]),fireRegisterEvent:!0}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",void 0)],b.prototype,"render",null);b.style=I;class E{constructor(t,n,s,i){this.router=t,this.nylasAuth=n,this.nylasAuthStore=s,this.nylasMailboxStore=i}init(){h.debug("NylasMailboxConnector init")}get mailboxStore(){return this.nylasMailboxStore}get authStore(){return this.nylasAuthStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new c.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new c.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new c.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new c.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasMailboxStore.reset(),this.nylasAuthStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const H=":host{display:contents}",B=H,_=class{constructor(e){o.registerInstance(this,e),this.init=o.createEvent(this,"init",7),this.loggedIn=o.createEvent(this,"loggedIn",7),this.loggedOut=o.createEvent(this,"loggedOut",7),this.handleAuthChange=async t=>{var n;t?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host).defaultPrevented||await((n=this.nylasMailboxConnector)==null?void 0:n.logout())},this.automaticComponentRegistration=!0,this.eventOverrides={},this.authConfig=void 0,this.defaultAuthStoreState=void 0,this.defaultMailboxStoreState=void 0}connectedCallback(){h.debug("[nylas-mailbox] connectedCallback")}async componentWillLoad(){var s,i,a,r,l,v,C;this.stores={auth:c.CreateNylasAuthStore(this.defaultAuthStoreState),mailbox:c.CreateNylasMailboxStore(this.defaultMailboxStoreState)},this.baseProvider=new A.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.router=new c.HashRouter,this.nylasAuth=A.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const e=(s=this.baseProvider)==null?void 0:s.getStore("auth");if(!e)throw new Error("Auth store is not defined");const t=(i=this.baseProvider)==null?void 0:i.getStore("mailbox");if(!t)throw new Error("Mailbox store is not defined");this.nylasMailboxConnector=new E(this.router,this.nylasAuth,e,t),this.init.emit(this.host).defaultPrevented||await((a=this.nylasMailboxConnector)==null?void 0:a.auth.validateSession()),(r=this.router)==null||r.addRouteChangeListener("/thread/:threadId",async(R,k,w)=>{var u,f;const g=w.threadId,d=await((u=this.nylasMailboxConnector)==null?void 0:u.threads.getThread(g));d&&((f=this.nylasMailboxConnector)==null||f.mailboxStore.set("selectedThread",d))}),(l=this.router)==null||l.addRouteChangeListener("/",async(R,k,w)=>{var d,u,f,S;if(!e.state.isAuthenticated)return;(d=this.nylasMailboxConnector)==null||d.threads.unSelectThread(),(u=this.nylasMailboxConnector)==null||u.folders.getFolders();const g=window.location.hash.split("?")[1];if(g){const x=new URLSearchParams(g).get("query");x&&await((f=this.nylasMailboxConnector)==null?void 0:f.threads.getThreads({search_query_native:x,page_token:void 0}))}else(S=this.nylasMailboxConnector)==null||S.threads.getThreads()}),(v=this.router)==null||v.init(),this.handleAuthChange(e.state.isAuthenticated),(C=this.baseProvider)==null||C.componentWillLoad(this.nylasMailboxConnector)}async componentDidLoad(){var t,n;const e=(t=this.baseProvider)==null?void 0:t.getStore("auth");if(!e)throw new Error("Auth store is not defined");e.onChange("isAuthenticated",this.handleAuthChange),(n=this.baseProvider)==null||n.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 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 getNylasAuth(){return this.nylasAuth}async getNylasMailboxConnector(){return this.nylasMailboxConnector}render(){return o.h(o.Host,{key:"a3c855c441914ccb60f6ad72cf166fe888508a6c"},o.h("slot",{key:"09bb1cbaf72e4beb90dcb723b1dc398b63072dd7"}))}get host(){return o.getElement(this)}};_.style=B;exports.nylas_if_state=p;exports.nylas_login=b;exports.nylas_mailbox=_;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as p, h as i, H as b, c as m, g as N } from "./index-
|
|
2
|
-
import { R as A } from "./register-component-
|
|
1
|
+
import { r as p, h as i, H as b, c as m, g as N } from "./index-630f4e87.js";
|
|
2
|
+
import { R as A } from "./register-component-152c6ad2-a06f58c2.js";
|
|
3
3
|
import { d as h } from "./utils-5074a070-ce33ee6b.js";
|
|
4
|
-
import { N as P, e as L } from "./index-
|
|
5
|
-
import { C as T, a as O, H as I, N as H, b as E, c as B, d as $ } from "./mailbox-store-
|
|
4
|
+
import { N as P, e as L } from "./index-b30d446a-a90f84b2.js";
|
|
5
|
+
import { C as T, a as O, H as I, N as H, b as E, c as B, d as $ } from "./mailbox-store-19f0c6c9-e3e8b4e5.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import "react-dom";
|
|
8
8
|
const D = ":host{display:block}div{height:inherit}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.fade-in{animation:fadeIn 1.5s}.fade-out{animation:fadeOut 1.5s}@keyframes slideIn{0%{transform:translateY(100%)}100%{transform:translateY(0)}}@keyframes slideOut{0%{transform:translateY(0)}100%{transform:translateY(100%)}}.slide-in{animation:slideIn 1.5s}.slide-out{animation:slideOut 1.5s}@keyframes swipeIn{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes swipeOut{0%{transform:translateX(0)}100%{transform:translateX(100%)}}.swipe-in{animation:swipeIn 1.5s}.swipe-out{animation:swipeOut 1.5s}", F = D;
|
|
@@ -141,7 +141,7 @@ const _ = class {
|
|
|
141
141
|
render() {
|
|
142
142
|
var t;
|
|
143
143
|
const e = ((t = this.providers) == null ? void 0 : t.split(",")) || [];
|
|
144
|
-
return i(b, { key: "
|
|
144
|
+
return i(b, { key: "a0b36443906ea5244070e6d0eece3794b1d1d3d5" }, this.loginMethod === "redirect" && i("div", { class: "redirect-container" }, !this.isAuthenticated && i("sp-button", { part: "button", onClick: this._handleLoginRedirect }, this.buttonText)), this.loginMethod === "emebded" && i("main", { class: "login-container" }, i("section", { class: "login-box" }, i("header", null, i("img", { src: this.logoUrl, alt: `${this.companyName} logo`, width: "100%", style: {
|
|
145
145
|
minWidth: this.logoWidth
|
|
146
146
|
} }), i("h1", null, "Welcome")), i("p", null, "Log in to your account to continue to ", this.companyName), i("div", { class: "login-methods" }, e.includes("google") && i("button", { class: "login-google", onClick: this._onGoogleButtonClick }, i("svg", { xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", role: "img", width: "18", height: "18", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 256 262" }, i("path", { fill: "#4285F4", d: "M255.6 131.6c0-8.2-.8-16.2-2.2-23.9H130v45.3h70.3c-3 16.1-12.4 29.7-26.3 38.9v32.4h42.6c25-23 39.4-56.7 39.4-97.7z" }), i("path", { fill: "#34A853", d: "M130 262c35.3 0 64.9-11.7 86.5-31.7l-42.6-32.4c-11.7 7.9-26.7 12.6-43.9 12.6-33.7 0-62.3-22.7-72.5-53.4H14.5v33.3A130.3 130.3 0 00130 262z" }), i("path", { fill: "#FBBC05", d: "M57.5 158.1a72.7 72.7 0 010-54.2V70.6H14.5a130.4 130.4 0 000 120.8l43-33.3z" }), i("path", { fill: "#EA4335", d: "M130 51.6c19 0 36 6.5 49.4 19.2l37-36C195 13.1 165.2 0 130 0A130.3 130.3 0 0014.5 70.6l43 33.3c10.2-30.7 38.8-53.3 72.5-53.3z" })), "Continue with Google"), e.includes("microsoft") && i("button", { class: "login-microsoft", onClick: this._onMicrosoftButtonClick }, i("svg", { xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", role: "img", width: "18", height: "18", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 448 512" }, i("path", { fill: "#F3F3F3", d: "M0 32v192h192V32H0zm256 0v192h192V32H256zm192 256v192h-192V288h192zM0 224v192h192V224H0z" })), "Continue with Microsoft")), i("form", { class: "login-form", method: "POST", onSubmit: this._onFormSubmit }, i("label", { htmlFor: "email" }, "Email"), i("input", { type: "email", id: "email", name: "email", required: !0, value: this.email }), i("button", { type: "submit" }, "Next")))));
|
|
147
147
|
}
|
|
@@ -277,7 +277,7 @@ const G = ":host{display:contents}", V = G, q = class {
|
|
|
277
277
|
return this.nylasMailboxConnector;
|
|
278
278
|
}
|
|
279
279
|
render() {
|
|
280
|
-
return i(b, { key: "
|
|
280
|
+
return i(b, { key: "a3c855c441914ccb60f6ad72cf166fe888508a6c" }, i("slot", { key: "09bb1cbaf72e4beb90dcb723b1dc398b63072dd7" }));
|
|
281
281
|
}
|
|
282
282
|
get host() {
|
|
283
283
|
return N(this);
|
package/dist/{nylas-list-folders.entry-de8cca60.cjs → nylas-list-folders.entry-866361cc.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-3b6f5cd5.cjs"),u=require("./register-component-152c6ad2-0df7215b.cjs"),a=require("./utils-5074a070-d5ba6add.cjs");require("react");require("react-dom");const h=":host{display:block}.folders{display:flex;flex-direction:column;align-items:self-start}.folders .folder{border:1px solid var(--nylas-color-primary-100);padding:0.5rem 0.75rem;margin-bottom:0.5rem;justify-content:left;width:100%;min-width:200px;border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-50)}.folders .folder:last-child{margin-bottom:0}.folders .folder.selected{background-color:var(--nylas-color-primary-100)}.folders .folder .icon{margin-right:0.5rem;stroke:var(--nylas-color-primary-900);fill:none}hr{width:100%;margin:1rem 0;border:0;border-top:1px solid var(--nylas-color-primary-100)}",m=h;var p=function(t,r,e,o){var s=arguments.length,n=s<3?r:o===null?o=Object.getOwnPropertyDescriptor(r,e):o,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,r,e,o);else for(var i=t.length-1;i>=0;i--)(d=t[i])&&(n=(s<3?d(n):s>3?d(r,e,n):d(r,e))||n);return s>3&&n&&Object.defineProperty(r,e,n),n},c=function(t,r){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,r)};const f=class{constructor(t){l.registerInstance(this,t),this.folderSelected=l.createEvent(this,"folderSelected",7),this.folderSelectedHandler=r=>{var e;(e=this.folderSelected)==null||e.emit(r)},this.folders=void 0,this.selectedFolder=void 0,this.defaultFolders=void 0,this.otherFolders=void 0}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){a.debug("[nylas-list-folders] Component will load")}async componentDidLoad(){a.debug("[nylas-list-folders] Component did load")}watchFolders(t){a.debug("[nylas-list-folders] watchFolders",{newFolders:t});const r=["inbox","drafts","sent","starred","spam","archive","trash"];this.defaultFolders=r.filter(e=>t.find(o=>{var s;return((s=o.name)==null?void 0:s.toLowerCase())===e.toLowerCase()})).map(e=>t.find(o=>{var s;return((s=o.name)==null?void 0:s.toLowerCase())===e.toLowerCase()})).filter(e=>typeof e<"u").sort((e,o)=>r.indexOf((e==null?void 0:e.name)??"")-r.indexOf((o==null?void 0:o.name)??"")),this.otherFolders=t.filter(e=>!r.find(o=>{var s;return((s=e.name)==null?void 0:s.toLowerCase())===o.toLowerCase()})).sort((e,o)=>(e.name??"").localeCompare(o.name??""))}formatFolderName(t){var r;return a.toTitleCase(((r=t.name)==null?void 0:r.replace("CATEGORY_",""))??"Unknown")}getFolderIcon(t){var r;switch((r=t.name)==null?void 0:r.toLowerCase()){case"inbox":return l.h("inbox-icon",null);case"drafts":return l.h("drafts-icon",null);case"sent":return l.h("sent-icon",null);case"starred":return l.h("star-icon",null);case"spam":return l.h("spam-icon",null);case"archive":return l.h("archive-icon",null);case"trash":return l.h("trash-icon",null);default:return l.h("folder-icon",null)}}render(){var t,r;return l.h(l.Host,{key:"7cccf397860653266b6f2635762fa76a2910c6b3"},l.h("div",{key:"390e0d26d5c5568487a937ff49f2931da00f26b1",class:"folders"},(t=this.defaultFolders)==null?void 0:t.map(e=>{var o;return l.h("sp-button",{onClick:()=>this.folderSelectedHandler(e),class:{folder:!0,selected:a.formatFolderName(e.name??"inbox").toLowerCase()===((o=this.selectedFolder)==null?void 0:o.toLowerCase())}},l.h("div",{slot:"icon",class:"icon"},this.getFolderIcon(e)),this.formatFolderName(e))})),this.otherFolders&&l.h(l.Fragment,null,l.h("hr",null),l.h("div",{class:"folders"},(r=this.otherFolders)==null?void 0:r.map(e=>{var o;return l.h("sp-button",{onClick:()=>this.folderSelectedHandler(e),class:{folder:!0,selected:a.formatFolderName(e.name??"inbox").toLowerCase()===((o=this.selectedFolder)==null?void 0:o.toLowerCase())}},l.h("div",{slot:"icon",class:"icon"},this.getFolderIcon(e)),this.formatFolderName(e))}))))}static get watchers(){return{folders:["watchFolders"]}}};p([u.RegisterComponent({name:"nylas-pagination",stateToProps:new Map([["mailbox.folders","folders"],["mailbox.selectedFolder","selectedFolder"]]),eventToProps:{folderSelected:async(t,r)=>{a.debug("[nylas-list-folders] folderSelected event",{_event:t}),await r.threads.getThreads({page_token:void 0,in:a.formatFolderName(t.detail.id??"inbox")})}},fireRegisterEvent:!0}),c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],f.prototype,"render",null);f.style=m;exports.nylas_list_folders=f;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as u, c as p, h as s, F as h, H as y } from "./index-
|
|
2
|
-
import { R as b } from "./register-component-
|
|
1
|
+
import { r as u, c as p, h as s, F as h, H as y } from "./index-630f4e87.js";
|
|
2
|
+
import { R as b } from "./register-component-152c6ad2-a06f58c2.js";
|
|
3
3
|
import { d, t as F, f } from "./utils-5074a070-ce33ee6b.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react-dom";
|
|
@@ -74,7 +74,7 @@ const m = class {
|
|
|
74
74
|
}
|
|
75
75
|
render() {
|
|
76
76
|
var r, t;
|
|
77
|
-
return s(y, { key: "
|
|
77
|
+
return s(y, { key: "7cccf397860653266b6f2635762fa76a2910c6b3" }, s("div", { key: "390e0d26d5c5568487a937ff49f2931da00f26b1", class: "folders" }, (r = this.defaultFolders) == null ? void 0 : r.map((e) => {
|
|
78
78
|
var o;
|
|
79
79
|
return s("sp-button", { onClick: () => this.folderSelectedHandler(e), class: {
|
|
80
80
|
folder: !0,
|
package/dist/{nylas-list-threads.entry-93b70a1a.cjs → nylas-list-threads.entry-04989295.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-3b6f5cd5.cjs"),u=require("./register-component-152c6ad2-0df7215b.cjs"),i=require("./utils-5074a070-d5ba6add.cjs");require("react");require("react-dom");const h=':host{display:block;font-size:var(--nylas-font-size, inherit);font-family:var(--nylas-font-family, inherit)}.list-thread{display:grid;grid-auto-flow:row;color:var(--nylas-color-primary-800);width:100%}.thread{position:relative;width:100%;display:grid;padding:0.5rem 1rem;column-gap:0.25rem;grid-template-areas:"........ from count ....... date actions" "checkbox subject subject subject subject actions" "........ snippet snippet snippet snippet actions";grid-template-columns:auto auto auto auto auto auto;margin-bottom:0.75rem;border-radius:var(--nylas-border-radius-2x);color:var(--nylas-color-primary-00);background-color:var(--nylas-color-primary-50);border:0;box-sizing:border-box;text-align:left;cursor:pointer;box-shadow:1px 1px 3px 0px rgba(0, 0, 0, 0.3);font-size:inherit;font-family:inherit}.thread.loading{animation:pulsate 1.5s infinite ease-in-out;width:100%;height:90px}.thread:last-of-type{margin-bottom:0}.thread.selected{box-shadow:0 2px 0 0 var(--nylas-color-primary-200);background-color:var(--nylas-color-primary-100)}.thread:hover{box-shadow:0 2px 0 0 var(--nylas-color-primary-200);background-color:var(--nylas-color-primary-100)}.thread>div{align-self:center;pointer-events:all !important}.thread .actions{grid-area:actions}.thread .actions sp-action-menu{pointer-events:initial !important}.thread .actions sp-action-button{pointer-events:initial !important}.thread .actions sp-menu-item{pointer-events:initial !important}.thread .checkbox{grid-area:checkbox;margin-right:0.5rem;pointer-events:initial !important}.thread .checkbox sp-checkbox{pointer-events:initial !important}.thread .star{grid-area:star;justify-self:end}.thread .from{grid-area:from;color:var(--nylas-color-primary-600)}.thread .count{grid-area:count;color:var(--nylas-color-primary-600)}.thread .subject{grid-area:subject;color:var(--nylas-color-primary-600)}.thread .snippet{grid-area:snippet;color:var(--nylas-color-primary-500)}.thread .date{grid-area:date;align-self:center;color:var(--nylas-color-primary-500)}.thread.unread .from,.thread.unread .count,.thread.unread .subject,.thread.unread .date{font-weight:600;color:var(--nylas-color-primary-800)}.thread.unread .snippet{color:var(--nylas-color-primary-700)}.thread .from{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.thread .snippet{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.thread .subject{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media only screen and (min-width: 768px){.thread{column-gap:1rem;grid-template-areas:"checkbox from count subject snippet date actions";grid-template-columns:auto minmax(auto, 200px) auto auto 1fr auto auto;margin-bottom:0.5rem;border:1px solid var(--nylas-color-primary-100)}.thread.no-checkbox{grid-template-areas:"from count subject snippet date actions";grid-template-columns:minmax(auto, 200px) auto auto 1fr auto auto}.thread .checkbox{margin-right:0}}@keyframes pulsate{0%{background-color:var(--nylas-color-primary-50)}50%{background-color:var(--nylas-color-primary-100)}100%{background-color:var(--nylas-color-primary-50)}}',m=h;var y=function(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var c=e.length-1;c>=0;c--)(l=e[c])&&(o=(n<3?l(o):n>3?l(t,r,o):l(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o},d=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const p=class{constructor(e){a.registerInstance(this,e),this.threadSelected=a.createEvent(this,"threadSelected",7),this.handleThreadSelected=async t=>{i.debug("[nylas-list-threads] Thread selected",{thread:t}),this.threadSelected.emit(t).defaultPrevented||i.debug("[nylas-list-threads] Default event not prevented, selecting thread")},this.handleCheckboxClick=async t=>{i.debug("[nylas-list-threads] Checkbox clicked",{event:t}),t.stopPropagation()},this.threads=[],this.isAuthenticated=!1,this.tokenInfo=void 0,this.state="ready",this.showCheckbox=!1}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){i.debug("[nylas-list-threads] Component will load")}async componentDidLoad(){i.debug("[nylas-list-threads] Component did load",{isAuthenticated:this.isAuthenticated})}render(){return a.h(a.Host,{key:"162954a4241d7ddb5a7957686dc63b805972645c"},a.h("div",{key:"4912c92ca812790c2fede6220494da1c8ce7959e",class:"list-thread",part:"list-thread"},this.state==="loading"&&new Array(10).fill(0).map((e,t)=>a.h("div",{class:"thread loading",style:{animationDelay:`${t*20}ms`}})),this.state==="ready"&&this.threads.map(e=>{var t,r,s,n;return a.h("button",{key:e==null?void 0:e.id,class:{thread:!0,unread:(e==null?void 0:e.unread)===!0,"no-checkbox":this.showCheckbox===!1},part:"thread","aria-label":`Thread with subject ${e==null?void 0:e.subject}`,onClick:()=>this.handleThreadSelected(e)},this.showCheckbox&&a.h("div",{class:"checkbox",part:"checkbox"},a.h("sp-checkbox",{size:"s",value:e==null?void 0:e.id,onClick:this.handleCheckboxClick})),a.h("div",{class:"from",part:"from"},i.formatParticipants(e.participants??[],(t=this.tokenInfo)==null?void 0:t.email,((r=e==null?void 0:e.message_ids)==null?void 0:r.length)||1,1)),a.h("div",{class:"subject",part:"subject"},e==null?void 0:e.subject),a.h("div",{class:"count",part:"count"},((s=e==null?void 0:e.message_ids)==null?void 0:s.length)||1),a.h("div",{class:"snippet",part:"snippet"},(n=e==null?void 0:e.snippet)==null?void 0:n.trim()),e.latest_message_received_date&&a.h("div",{class:"date","aria-label":`${Intl.DateTimeFormat(void 0,{dateStyle:"full"}).format(new Date(e.latest_message_received_date*1e3))}`,part:"date"},i.formatDateTime(e.latest_message_received_date)))})))}};y([u.RegisterComponent({name:"nylas-list-threads",stateToProps:new Map([["auth.isAuthenticated","isAuthenticated"],["auth.tokenInfo","tokenInfo"],["mailbox.threads","threads"],["mailbox.state","state"]]),eventToProps:{threadSelected:async(e,t)=>{i.debug("[nylas-list-threads] Thread selected",{event:e}),await t.threads.selectThread(e.detail)}},fireRegisterEvent:!0}),d("design:type",Function),d("design:paramtypes",[]),d("design:returntype",void 0)],p.prototype,"render",null);p.style=m;exports.nylas_list_threads=p;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as m, c as u, h as a, H as h } from "./index-
|
|
2
|
-
import { R as y } from "./register-component-
|
|
1
|
+
import { r as m, c as u, h as a, H as h } from "./index-630f4e87.js";
|
|
2
|
+
import { R as y } from "./register-component-152c6ad2-a06f58c2.js";
|
|
3
3
|
import { d as n, a as f, b } from "./utils-5074a070-ce33ee6b.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react-dom";
|
|
@@ -35,7 +35,7 @@ const p = class {
|
|
|
35
35
|
n("[nylas-list-threads] Component did load", { isAuthenticated: this.isAuthenticated });
|
|
36
36
|
}
|
|
37
37
|
render() {
|
|
38
|
-
return a(h, { key: "
|
|
38
|
+
return a(h, { key: "162954a4241d7ddb5a7957686dc63b805972645c" }, a("div", { key: "4912c92ca812790c2fede6220494da1c8ce7959e", class: "list-thread", part: "list-thread" }, this.state === "loading" && new Array(10).fill(0).map((e, t) => a("div", { class: "thread loading", style: { animationDelay: `${t * 20}ms` } })), this.state === "ready" && this.threads.map((e) => {
|
|
39
39
|
var t, r, i, s;
|
|
40
40
|
return a("button", { key: e == null ? void 0 : e.id, class: {
|
|
41
41
|
thread: !0,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as m, c as d, h as e, H as p, g as u } from "./index-
|
|
2
|
-
import { R as v } from "./register-component-
|
|
1
|
+
import { r as m, c as d, h as e, H as p, g as u } from "./index-630f4e87.js";
|
|
2
|
+
import { R as v } from "./register-component-152c6ad2-a06f58c2.js";
|
|
3
3
|
import { d as a } from "./utils-5074a070-ce33ee6b.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react-dom";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-3b6f5cd5.cjs"),g=require("./register-component-152c6ad2-0df7215b.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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-3b6f5cd5.cjs"),b=require("./register-component-152c6ad2-0df7215b.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:"a54c99a0881643686516cecb59f8f945ba8e3ef1"},r.h("sp-theme",{key:"075773f3a5e9c354bae00d01c70d3b458cc40961",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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
import { R as u } from "./register-component-
|
|
1
|
+
import { r as f, h as l, H as b, g as m } from "./index-630f4e87.js";
|
|
2
|
+
import { R as u } from "./register-component-152c6ad2-a06f58c2.js";
|
|
3
3
|
import { d as c } from "./utils-5074a070-ce33ee6b.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react-dom";
|
|
@@ -16,9 +16,9 @@ var g = function(t, o, e, n) {
|
|
|
16
16
|
if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
|
|
17
17
|
return Reflect.metadata(t, o);
|
|
18
18
|
};
|
|
19
|
-
const
|
|
19
|
+
const y = class {
|
|
20
20
|
constructor(t) {
|
|
21
|
-
|
|
21
|
+
f(this, t), this.onClick = async () => {
|
|
22
22
|
const o = this.method;
|
|
23
23
|
if (c("[nylas-mailbox-toolbar-button] onClick", { method: o, mailboxConnector: this.mailboxConnector }), this.mailboxConnector && o) {
|
|
24
24
|
const e = this.callMethod(this.mailboxConnector, o);
|
|
@@ -61,7 +61,7 @@ const f = class {
|
|
|
61
61
|
t = this.dataState ? o.get(r) === "loading" : !1;
|
|
62
62
|
}
|
|
63
63
|
const e = t ? "state-loading" : "state-ready";
|
|
64
|
-
return l(b, { key: "
|
|
64
|
+
return l(b, { key: "a54c99a0881643686516cecb59f8f945ba8e3ef1" }, l("sp-theme", { key: "075773f3a5e9c354bae00d01c70d3b458cc40961", 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
65
|
}
|
|
66
66
|
get host() {
|
|
67
67
|
return m(this);
|
|
@@ -76,8 +76,8 @@ g([
|
|
|
76
76
|
d("design:type", Function),
|
|
77
77
|
d("design:paramtypes", []),
|
|
78
78
|
d("design:returntype", void 0)
|
|
79
|
-
],
|
|
80
|
-
|
|
79
|
+
], y.prototype, "render", null);
|
|
80
|
+
y.style = h;
|
|
81
81
|
export {
|
|
82
|
-
|
|
82
|
+
y as nylas_mailbox_toolbar_button
|
|
83
83
|
};
|
package/dist/{nylas-open-hours-picker.entry-109f13f5.js → nylas-open-hours-picker.entry-6bdc7c73.js}
RENAMED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { r as y, c as D, h, H as M, g as H } from "./index-
|
|
2
|
-
import { d as
|
|
3
|
-
import { t as
|
|
1
|
+
import { r as y, c as D, h, H as M, g as H } from "./index-630f4e87.js";
|
|
2
|
+
import { d as f, g as b, c as w } from "./utils-5074a070-ce33ee6b.js";
|
|
3
|
+
import { t as p, d as c, a as T, b as m } from "./duration-bddc4a13-179ce826.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react-dom";
|
|
6
|
-
const S =
|
|
6
|
+
const S = p((t) => {
|
|
7
7
|
t.setTime(t - t.getMilliseconds() - t.getSeconds() * T);
|
|
8
8
|
}, (t, e) => {
|
|
9
9
|
t.setTime(+t + e * c);
|
|
10
10
|
}, (t, e) => (e - t) / c, (t) => t.getMinutes()), k = S.range;
|
|
11
|
-
|
|
11
|
+
p((t) => {
|
|
12
12
|
t.setUTCSeconds(0, 0);
|
|
13
13
|
}, (t, e) => {
|
|
14
14
|
t.setTime(+t + e * c);
|
|
15
15
|
}, (t, e) => (e - t) / c, (t) => t.getUTCMinutes());
|
|
16
|
-
const x =
|
|
16
|
+
const x = p((t) => {
|
|
17
17
|
t.setTime(t - t.getMilliseconds() - t.getSeconds() * T - t.getMinutes() * c);
|
|
18
18
|
}, (t, e) => {
|
|
19
19
|
t.setTime(+t + e * m);
|
|
20
20
|
}, (t, e) => (e - t) / m, (t) => t.getHours()), v = x.range;
|
|
21
|
-
|
|
21
|
+
p((t) => {
|
|
22
22
|
t.setUTCMinutes(0, 0, 0);
|
|
23
23
|
}, (t, e) => {
|
|
24
24
|
t.setTime(+t + e * m);
|
|
@@ -27,12 +27,12 @@ const C = ':host{display:block;font-size:inherit;font-family:inherit;--nylas-gri
|
|
|
27
27
|
constructor(t) {
|
|
28
28
|
y(this, t), this.openHoursChanged = D(this, "openHoursChanged", 7), this.dragStartTime = 0, this.onSelectedHoursWeel = (e) => {
|
|
29
29
|
e.preventDefault(), e.stopPropagation();
|
|
30
|
-
const { deltaY: s } = e,
|
|
31
|
-
if (this.intervalMinutes === this.stepMinutes &&
|
|
30
|
+
const { deltaY: s } = e, a = s > 0 ? -1 : 1;
|
|
31
|
+
if (this.intervalMinutes === this.stepMinutes && a === -1 || this.intervalMinutes === 60 && a === 1)
|
|
32
32
|
return;
|
|
33
|
-
this.intervalMinutes = this.intervalMinutes +
|
|
34
|
-
const
|
|
35
|
-
|
|
33
|
+
this.intervalMinutes = this.intervalMinutes + a * this.stepMinutes;
|
|
34
|
+
const i = new Date(this.startTime);
|
|
35
|
+
i.setHours(this.endTime.getHours(), 0, 0, 0), this.intervalMinutes < 60 ? this.times = k(this.startTime, i, this.intervalMinutes) : this.times = v(this.startTime, i, this.intervalMinutes / 60);
|
|
36
36
|
}, this.onContextMenu = (e) => {
|
|
37
37
|
e.preventDefault(), e.stopPropagation(), this.inverse = !this.inverse;
|
|
38
38
|
}, this.onMouseDown = (e, s) => {
|
|
@@ -40,92 +40,92 @@ const C = ':host{display:block;font-size:inherit;font-family:inherit;--nylas-gri
|
|
|
40
40
|
}, this.onMouseOver = (e, s) => {
|
|
41
41
|
this.isDragging() && (this.draggingEndDate = s);
|
|
42
42
|
}, this.onMouseUp = (e, s) => {
|
|
43
|
-
if (this.host.querySelectorAll(".hovered").forEach((
|
|
44
|
-
|
|
43
|
+
if (this.host.querySelectorAll(".hovered").forEach((i) => {
|
|
44
|
+
i.classList.remove("hovered");
|
|
45
45
|
}), this.isDragging() && this.draggingStartDate && this.draggingEndDate) {
|
|
46
|
-
const
|
|
46
|
+
const i = [];
|
|
47
47
|
let r = this.draggingStartDate, o = this.draggingEndDate;
|
|
48
48
|
o.setMinutes(o.getMinutes() + this.intervalMinutes);
|
|
49
49
|
const n = r.getDay(), u = o.getDay();
|
|
50
50
|
if (n === u)
|
|
51
|
-
|
|
51
|
+
i.push({ start: r, end: o });
|
|
52
52
|
else if (u > n)
|
|
53
53
|
for (let l = 0; l <= u - n; l++) {
|
|
54
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()),
|
|
55
|
+
d.setDate(r.getDate() + l), g.setDate(r.getDate() + l), g.setHours(o.getHours()), i.push({ start: d, end: g });
|
|
56
56
|
}
|
|
57
|
-
for (let l of
|
|
57
|
+
for (let l of i)
|
|
58
58
|
this.updateAvailableTimes(l.start, l.end);
|
|
59
59
|
}
|
|
60
60
|
this.draggingStartDate = null, this.draggingEndDate = null, e.preventDefault(), e.stopPropagation();
|
|
61
61
|
}, this.onTimeClick = (e) => {
|
|
62
62
|
if (this.isDragging()) {
|
|
63
|
-
|
|
63
|
+
f("dragging for more than threshold, skipping click event");
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
this.draggingStartDate = null;
|
|
67
|
-
const s = new Date(e),
|
|
68
|
-
|
|
67
|
+
const s = new Date(e), a = new Date(e);
|
|
68
|
+
a.setMinutes(a.getMinutes() + this.intervalMinutes), this.updateAvailableTimes(s, a);
|
|
69
69
|
}, this.isDragging = () => {
|
|
70
70
|
const e = (/* @__PURE__ */ new Date()).getTime();
|
|
71
71
|
return this.draggingStartDate && e - this.dragStartTime > this.dragThreshold;
|
|
72
72
|
}, this.updateAvailableTimes = (e, s) => {
|
|
73
|
-
const { availableTimes:
|
|
74
|
-
if (
|
|
75
|
-
|
|
73
|
+
const { availableTimes: a } = this, i = a.findIndex((n) => e.getTime() >= n.start.getTime() && s.getTime() <= n.end.getTime());
|
|
74
|
+
if (i !== -1) {
|
|
75
|
+
a.splice(i, 1), this.availableTimes = [...a];
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
const r =
|
|
78
|
+
const r = a.findIndex((n) => e.getTime() === n.end.getTime());
|
|
79
79
|
if (r !== -1) {
|
|
80
|
-
|
|
80
|
+
a[r].end = s, this.availableTimes = [...a];
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
const o =
|
|
83
|
+
const o = a.findIndex((n) => s.getTime() === n.start.getTime());
|
|
84
84
|
if (o !== -1) {
|
|
85
|
-
|
|
85
|
+
a[o].start = e, this.availableTimes = [...a];
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
this.availableTimes = [...
|
|
88
|
+
this.availableTimes = [...a, { start: e, end: s }];
|
|
89
89
|
}, this.isAvailableTime = (e) => this.availableTimes.some((s) => s.start.getTime() <= e.getTime() && s.end.getTime() > e.getTime()), this.getSelectedDate = (e) => {
|
|
90
90
|
const s = new Date(this.startTime);
|
|
91
91
|
s.setDate(e % 7 + 1);
|
|
92
|
-
const
|
|
93
|
-
return s.setHours(this.times[
|
|
92
|
+
const a = Math.floor(e / 7);
|
|
93
|
+
return s.setHours(this.times[a].getHours()), s.setMinutes(this.times[a].getMinutes()), s;
|
|
94
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
95
|
const s = [];
|
|
96
|
-
for (const
|
|
97
|
-
for (const
|
|
98
|
-
if (
|
|
96
|
+
for (const a of e)
|
|
97
|
+
for (const i of a.days) {
|
|
98
|
+
if (a.start === a.end)
|
|
99
99
|
continue;
|
|
100
|
-
const [r, o] =
|
|
101
|
-
l.setDate(l.getDate() +
|
|
100
|
+
const [r, o] = a.start.split(":").map((g) => parseInt(g, 10)), [n, u] = a.end.split(":").map((g) => parseInt(g, 10)), l = new Date(this.startTime);
|
|
101
|
+
l.setDate(l.getDate() + i), l.setHours(r), l.setMinutes(o);
|
|
102
102
|
const d = new Date(this.startTime);
|
|
103
|
-
d.setDate(d.getDate() +
|
|
103
|
+
d.setDate(d.getDate() + i), d.setHours(n), d.setMinutes(u), s.push({ start: l, end: d });
|
|
104
104
|
}
|
|
105
|
-
return s.sort((
|
|
105
|
+
return s.sort((a, i) => a.start.getTime() - i.start.getTime()), f("availableTimes", s), s;
|
|
106
106
|
}, this.calculateOpenHours = () => {
|
|
107
107
|
const e = {}, s = [];
|
|
108
|
-
let
|
|
109
|
-
if (
|
|
110
|
-
const
|
|
111
|
-
|
|
108
|
+
let a = [...this.availableTimes];
|
|
109
|
+
if (a.sort((i, r) => i.start.getTime() - r.start.getTime()), this.inverse) {
|
|
110
|
+
const i = [...a];
|
|
111
|
+
a = [];
|
|
112
112
|
let r = this.startTime;
|
|
113
|
-
for (const o of
|
|
113
|
+
for (const o of i) {
|
|
114
114
|
const n = o.start;
|
|
115
|
-
|
|
115
|
+
a.push({ start: r, end: n }), r = o.end;
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
a.push({ start: r, end: this.endTime });
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
for (const
|
|
121
|
-
const r =
|
|
122
|
-
n.setDate(n.getDate() + 1), n.setHours(0, 0, 0, 0), (r > o || o > r) && (
|
|
123
|
-
const u = b(
|
|
119
|
+
a.sort((i, r) => i.start.getTime() - r.start.getTime());
|
|
120
|
+
for (const i of a) {
|
|
121
|
+
const r = i.start.getDay(), o = i.end.getDay(), n = new Date(i.start);
|
|
122
|
+
n.setDate(n.getDate() + 1), n.setHours(0, 0, 0, 0), (r > o || o > r) && (a.push({ start: n, end: i.end }), i.end = new Date(i.start), i.end.setHours(23, 0, 0, 0));
|
|
123
|
+
const u = b(i.start), l = b(i.end), d = `${u}-${l}`;
|
|
124
124
|
e[d] ? e[d].push(r) : e[d] = [r];
|
|
125
125
|
}
|
|
126
|
-
for (const
|
|
127
|
-
const [r, o] =
|
|
128
|
-
days: e[
|
|
126
|
+
for (const i in e) {
|
|
127
|
+
const [r, o] = i.split("-"), u = {
|
|
128
|
+
days: e[i],
|
|
129
129
|
start: r,
|
|
130
130
|
end: o,
|
|
131
131
|
timezone: w()
|
|
@@ -134,8 +134,8 @@ const C = ':host{display:block;font-size:inherit;font-family:inherit;--nylas-gri
|
|
|
134
134
|
}
|
|
135
135
|
this.openHoursChanged.emit(s);
|
|
136
136
|
}, this.getNumberOfDatesBetween = (e, s) => {
|
|
137
|
-
const
|
|
138
|
-
return Math.ceil(
|
|
137
|
+
const a = Math.abs(s.getTime() - e.getTime());
|
|
138
|
+
return Math.ceil(a / (1e3 * 60 * 60 * 24));
|
|
139
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
140
|
}
|
|
141
141
|
componentWillLoad() {
|
|
@@ -157,17 +157,17 @@ const C = ':host{display:block;font-size:inherit;font-family:inherit;--nylas-gri
|
|
|
157
157
|
this.isMobile = t <= this.mobileViewPortWidth;
|
|
158
158
|
}
|
|
159
159
|
render() {
|
|
160
|
-
return h(M, { key: "
|
|
160
|
+
return h(M, { key: "d5bbd9de6ab37f3f65d15b3dc5707b01a851956d" }, h("div", { key: "5ff3bdae2037ba3899332c0aca490c2b4cc80196", class: "open-hours", part: "open-hours" }, h("div", { key: "c8de6bcc08a63326182fad04ea4e1808c628c609", class: "days", part: "days" }, Array.from({ length: this.getNumberOfDatesBetween(this.startTime, this.endTime) }).map((t, e) => {
|
|
161
161
|
const s = new Date(this.startTime);
|
|
162
162
|
return s.setDate(s.getDate() + e), h("span", null, s.toLocaleDateString(void 0, { weekday: this.isMobile ? "short" : "long" }));
|
|
163
|
-
})), h("div", { key: "
|
|
163
|
+
})), h("div", { key: "3592ca8e4b4de1302cca7fdca24cfb6ed09c7d41", class: "hours", part: "hours" }, this.times.map((t) => h("span", null, t.toLocaleTimeString(void 0, { timeStyle: "short" })))), h("div", { key: "48ead6932850e177cfbd43a6227720c8c86145ea", class: {
|
|
164
164
|
"selected-hours": !0,
|
|
165
165
|
inverse: this.inverse
|
|
166
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
167
|
hour: !0,
|
|
168
168
|
selected: this.isAvailableTime(this.getSelectedDate(e)),
|
|
169
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: "
|
|
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: "ca2aa5bef7a0e31b29b4a1a759fcefcabc6f0785", class: "legend", part: "legend" }, h("div", { key: "a7b3b3a0a02c8dfbac69f8cad10c392e3a2e3e84", class: "available", part: "available" }, h("span", { key: "dcfcd5d5fd2934672fb0069825ab98e50c886682", class: "box", part: "box" }), h("span", { key: "37cc29e78d063c1087d46a1cc5de6dbe46677031", class: "label", part: "label" }, "Available")), h("div", { key: "9db85b0c8c208aa764f2ea0c6e3371dcea0594e0", class: "unavailable", part: "unavailable" }, h("span", { key: "c0a3ef91cc2a8f418329d2c6d91feb7d90e4658f", class: "box", part: "box" }), h("span", { key: "0f21587a4222836b2273e19094b8c0c35b88de20", class: "label", part: "label" }, "Unavailable"))));
|
|
171
171
|
}
|
|
172
172
|
get host() {
|
|
173
173
|
return H(this);
|
|
@@ -1 +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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-3b6f5cd5.cjs"),m=require("./utils-5074a070-d5ba6add.cjs"),u=require("./duration-bddc4a13-05d3e3e2.cjs");require("react");require("react-dom");const f=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=f.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()),p=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,b=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=p(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(),c=l.getDay();if(n===c)a.push({start:r,end:l});else if(c>n)for(let h=0;h<=c-n;h++){const d=new Date(r),g=new Date(r);d.setDate(r.getDate()+h),g.setDate(r.getDate()+h),g.setHours(l.getHours()),a.push({start:d,end:g})}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(g=>parseInt(g,10)),[n,c]=i.end.split(":").map(g=>parseInt(g,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(c),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 c=m.get24HourTime(a.start),h=m.get24HourTime(a.end),d=`${c}-${h}`;e[d]?e[d].push(r):e[d]=[r]}for(const a in e){const[r,l]=a.split("-"),c={days:e[a],start:r,end:l,timezone:m.getUserTimezone()};s.push(c)}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=p(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:"d5bbd9de6ab37f3f65d15b3dc5707b01a851956d"},o.h("div",{key:"5ff3bdae2037ba3899332c0aca490c2b4cc80196",class:"open-hours",part:"open-hours"},o.h("div",{key:"c8de6bcc08a63326182fad04ea4e1808c628c609",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:"3592ca8e4b4de1302cca7fdca24cfb6ed09c7d41",class:"hours",part:"hours"},this.times.map(t=>o.h("span",null,t.toLocaleTimeString(void 0,{timeStyle:"short"})))),o.h("div",{key:"48ead6932850e177cfbd43a6227720c8c86145ea",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:"ca2aa5bef7a0e31b29b4a1a759fcefcabc6f0785",class:"legend",part:"legend"},o.h("div",{key:"a7b3b3a0a02c8dfbac69f8cad10c392e3a2e3e84",class:"available",part:"available"},o.h("span",{key:"dcfcd5d5fd2934672fb0069825ab98e50c886682",class:"box",part:"box"}),o.h("span",{key:"37cc29e78d063c1087d46a1cc5de6dbe46677031",class:"label",part:"label"},"Available")),o.h("div",{key:"9db85b0c8c208aa764f2ea0c6e3371dcea0594e0",class:"unavailable",part:"unavailable"},o.h("span",{key:"c0a3ef91cc2a8f418329d2c6d91feb7d90e4658f",class:"box",part:"box"}),o.h("span",{key:"0f21587a4222836b2273e19094b8c0c35b88de20",class:"label",part:"label"},"Unavailable"))))}get host(){return o.getElement(this)}static get watchers(){return{openHours:["whenOpenHoursChanged"],availableTimes:["availableTimesChanged"],inverse:["inverseChanged"]}}};b.style=D;exports.nylas_open_hours_picker=b;
|