@nylas/web-elements 1.4.1 → 1.4.3
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/nylas-web-elements/{index-95193d9b.js → index-212258bf.js} +2 -2
- package/dist/nylas-web-elements/{index.es-69f2eefb.js → index.es-82b6efae.js} +2 -2
- package/dist/nylas-web-elements/index.esm.js +1 -1
- package/dist/nylas-web-elements/input-component.entry.js +1 -1
- package/dist/nylas-web-elements/input-component.entry.js.map +1 -1
- package/dist/nylas-web-elements/input-image-url.entry.js +1 -1
- package/dist/nylas-web-elements/multi-select-dropdown.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-additional-participants.entry.js +1 -1
- package/dist/nylas-web-elements/{nylas-api-request-d8eb4c91.js → nylas-api-request-51129e10.js} +2 -2
- package/dist/nylas-web-elements/nylas-availability-picker.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-booked-event-card.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-booking-calendar-picker.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-booking-confirmation-redirect.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-booking-confirmation-type.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-booking-form-config.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-booking-form.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-buffer-time.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-calendar-picker.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-cancel-booking-form.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-cancellation-policy.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-cancelled-event-card.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-confirmation-email.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-confirmed-event-card.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-connected-calendars.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-custom-booking-flow.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-custom-event-slug.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-customize-booking-settings.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-date-component.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-date-picker.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-date-picker.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-disable-emails.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-editor-tabs-group.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-editor-tabs.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-calendar.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-calendar.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-event-capacity.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-capacity.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-event-description.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-duration.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-info.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-limits.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-location.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-timeslot.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-timeslot.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-event-title.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-event-title.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-feedback-form.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-form-card.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-if-state.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-limit-future-bookings.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-list-configurations.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-locale-switch.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-login.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-min-booking-notice.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-min-cancellation-notice.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-notification.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-organizer-confirmation-card.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-page-name.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-page-styling.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-participant-booking-calendars.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-participants-custom-availability.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-provider.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-reminder-emails.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-reminder-time.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-scheduler-editor.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-scheduling-method.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-scheduling.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-select-event-type.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-selected-event-card.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-time-window-picker.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-timeslot-interval.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-timeslot-picker.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-timeslot-picker.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
- package/dist/nylas-web-elements/nylas-web-elements.esm.js.map +1 -1
- package/dist/nylas-web-elements/{register-component-3d439a88.js → register-component-8b5587d5.js} +2 -2
- package/dist/nylas-web-elements/{scheduler-store-0acc5e0f.js → scheduler-store-36b93b74.js} +2 -2
- package/dist/nylas-web-elements/textarea-component.entry.js +1 -1
- package/dist/nylas-web-elements/time-period-selector.entry.js +1 -1
- package/dist/nylas-web-elements/{utils-3fdf2c83.js → utils-ac8fef1e.js} +2 -2
- package/dist/types/components/scheduler/nylas-date-picker/nylas-date-picker.d.ts +4 -0
- package/dist/types/components/scheduler-editor/nylas-event-capacity/nylas-event-capacity.d.ts +1 -0
- package/package.json +2 -3
- package/CHANGELOG.md +0 -872
- /package/dist/nylas-web-elements/{index-95193d9b.js.map → index-212258bf.js.map} +0 -0
- /package/dist/nylas-web-elements/{index.es-69f2eefb.js.map → index.es-82b6efae.js.map} +0 -0
- /package/dist/nylas-web-elements/{nylas-api-request-d8eb4c91.js.map → nylas-api-request-51129e10.js.map} +0 -0
- /package/dist/nylas-web-elements/{register-component-3d439a88.js.map → register-component-8b5587d5.js.map} +0 -0
- /package/dist/nylas-web-elements/{scheduler-store-0acc5e0f.js.map → scheduler-store-36b93b74.js.map} +0 -0
- /package/dist/nylas-web-elements/{utils-3fdf2c83.js.map → utils-ac8fef1e.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["patchBrowser","BUILD","isDev","isTesting","consoleDevInfo","cloneNodeFix","patchCloneNodeFix","H","prototype","scriptElm","scriptDataOpts","Array","from","doc","querySelectorAll","find","s","RegExp","NAMESPACE","test","src","getAttribute","importMeta","url","opts","resourcesUrl","URL","href","promiseResolve","HTMLElementPrototype","nativeCloneNodeFn","cloneNode","deep","this","nodeName","call","clonedNode","srcChildNodes","childNodes","i","length","nodeType","appendChild","then","options","globalScripts","bootstrapLazy","JSON","parse"],"sources":["../../node_modules/.pnpm/@stencil+core@4.12.0/node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v4.12.0 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, doc, promiseResolve, H } from '@stencil/core';\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n const scriptElm = BUILD.scriptDataOpts\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})['data-opts'] || {} : {};\n if (importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n }\n return promiseResolve(opts);\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"mappings":"+KAKA,MAAMA,EAAe,KAEjB,GAAIC,EAAMC,QAAUD,EAAME,UAAW,CACjCC,EAAe,+BACvB,CACI,GAAIH,EAAMI,aAAc,CAEpBC,EAAkBC,EAAEC,UAC5B,CACI,MAAMC,EAAYR,EAAMS,eAClBC,MAAMC,KAAKC,EAAIC,iBAAiB,WAAWC,MAAMC,GAAM,IAAIC,OAAO,IAAKC,4BAAoCC,KAAKH,EAAEI,MAChHJ,EAAEK,aAAa,4BAA8BH,IAC/C,KACN,MAAMI,cAAyBC,IAC/B,MAAMC,EAAOvB,EAAMS,gBAAkBD,GAAa,IAAI,cAAgB,GAAK,GAC3E,GAAIa,IAAe,GAAI,CACnBE,EAAKC,aAAe,IAAIC,IAAI,IAAKJ,GAAYK,IACrD,CACI,OAAOC,EAAeJ,EAAK,EAE/B,MAAMlB,EAAqBuB,IACvB,MAAMC,EAAoBD,EAAqBE,UAC/CF,EAAqBE,UAAY,SAAUC,GACvC,GAAIC,KAAKC,WAAa,WAAY,CAC9B,OAAOJ,EAAkBK,KAAKF,KAAMD,EAChD,CACQ,MAAMI,EAAaN,EAAkBK,KAAKF,KAAM,OAChD,MAAMI,EAAgBJ,KAAKK,WAC3B,GAAIN,EAAM,CACN,IAAK,IAAIO,EAAI,EAAGA,EAAIF,EAAcG,OAAQD,IAAK,CAE3C,GAAIF,EAAcE,GAAGE,WAAa,EAAG,CACjCL,EAAWM,YAAYL,EAAcE,GAAGR,UAAU,MACtE,CACA,CACA,CACQ,OAAOK,CACf,CAAK,ECtCLpC,IAAe2C,MAAKC,IAClBC,IACA,OAAOC,EAAcC,KAAAC,MAAA,
|
|
1
|
+
{"version":3,"names":["patchBrowser","BUILD","isDev","isTesting","consoleDevInfo","cloneNodeFix","patchCloneNodeFix","H","prototype","scriptElm","scriptDataOpts","Array","from","doc","querySelectorAll","find","s","RegExp","NAMESPACE","test","src","getAttribute","importMeta","url","opts","resourcesUrl","URL","href","promiseResolve","HTMLElementPrototype","nativeCloneNodeFn","cloneNode","deep","this","nodeName","call","clonedNode","srcChildNodes","childNodes","i","length","nodeType","appendChild","then","options","globalScripts","bootstrapLazy","JSON","parse"],"sources":["../../node_modules/.pnpm/@stencil+core@4.12.0/node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v4.12.0 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, doc, promiseResolve, H } from '@stencil/core';\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n const scriptElm = BUILD.scriptDataOpts\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})['data-opts'] || {} : {};\n if (importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n }\n return promiseResolve(opts);\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"mappings":"+KAKA,MAAMA,EAAe,KAEjB,GAAIC,EAAMC,QAAUD,EAAME,UAAW,CACjCC,EAAe,+BACvB,CACI,GAAIH,EAAMI,aAAc,CAEpBC,EAAkBC,EAAEC,UAC5B,CACI,MAAMC,EAAYR,EAAMS,eAClBC,MAAMC,KAAKC,EAAIC,iBAAiB,WAAWC,MAAMC,GAAM,IAAIC,OAAO,IAAKC,4BAAoCC,KAAKH,EAAEI,MAChHJ,EAAEK,aAAa,4BAA8BH,IAC/C,KACN,MAAMI,cAAyBC,IAC/B,MAAMC,EAAOvB,EAAMS,gBAAkBD,GAAa,IAAI,cAAgB,GAAK,GAC3E,GAAIa,IAAe,GAAI,CACnBE,EAAKC,aAAe,IAAIC,IAAI,IAAKJ,GAAYK,IACrD,CACI,OAAOC,EAAeJ,EAAK,EAE/B,MAAMlB,EAAqBuB,IACvB,MAAMC,EAAoBD,EAAqBE,UAC/CF,EAAqBE,UAAY,SAAUC,GACvC,GAAIC,KAAKC,WAAa,WAAY,CAC9B,OAAOJ,EAAkBK,KAAKF,KAAMD,EAChD,CACQ,MAAMI,EAAaN,EAAkBK,KAAKF,KAAM,OAChD,MAAMI,EAAgBJ,KAAKK,WAC3B,GAAIN,EAAM,CACN,IAAK,IAAIO,EAAI,EAAGA,EAAIF,EAAcG,OAAQD,IAAK,CAE3C,GAAIF,EAAcE,GAAGE,WAAa,EAAG,CACjCL,EAAWM,YAAYL,EAAcE,GAAGR,UAAU,MACtE,CACA,CACA,CACQ,OAAOK,CACf,CAAK,ECtCLpC,IAAe2C,MAAKC,IAClBC,IACA,OAAOC,EAAcC,KAAAC,MAAA,2jxCAAuCJ,EAAA"}
|
package/dist/nylas-web-elements/{register-component-3d439a88.js → register-component-8b5587d5.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,e as t}from"./utils-
|
|
2
|
-
//# sourceMappingURL=register-component-
|
|
1
|
+
import{a as e,e as t}from"./utils-ac8fef1e.js";import{e as n}from"./index-3e0d6890.js";function r(e,t,n="registerComponent"){return new CustomEvent(n,{bubbles:true,composed:true,detail:t})}function o(e,t,n="unregisterComponent"){return new CustomEvent(n,{bubbles:true,composed:true,detail:t})}function s(s){return(c,i)=>{const u=s.name;e(`[${u}] Registering component ${u} being called on ${i}`);const l=c.componentWillLoad;if(!l){t(`[${u}] componentWillLoad lifecycle method in ${u} missing. Required for RegisterComponent decorator.`);return}const a=c.connectedCallback;if(!a){t(`[${u}] connectedCallback lifecycle method in ${u} missing. Required for RegisterComponent decorator.`);return}const m=c.disconnectedCallback;if(!m){t(`[${u}] disconnectedCallback lifecycle method in ${u} missing. Required for RegisterComponent decorator.`);return}if(s.storeToProps&&s.stateToProps){const e=Array.from(s.storeToProps.values());const n=Array.from(s.stateToProps.values());const r=e.filter((e=>n.includes(e)));if(r.length>0){t(`[${u}] Overlapping prop keys detected in ${u} for storeToProps and stateToProps. Make sure to only define them once. Overlapping keys: ${r.join(", ")}`);return}}const p=new Map;if(s.eventToProps){Object.keys(s.eventToProps).forEach((e=>{p.set(e,s.eventToProps?.[e])}))}c.connectedCallback=function(){e(`[~${u}] connectedCallback called`);const t=a?.call(this);const r=n(this);if(r.dataset.nylasId){return t}Object.defineProperty(r,"registerNylasComponent",{get(){return true},enumerable:true});Object.defineProperty(r,"stateToProps",{get(){return s.stateToProps},enumerable:true});Object.defineProperty(r,"getStoresToProp",{get(){return s.getStoresToProp},enumerable:true});Object.defineProperty(r,"storeToProps",{get(){return s.storeToProps},enumerable:true});Object.defineProperty(r,"eventToProps",{get(){return p},enumerable:true});Object.defineProperty(r,"authToProp",{get(){return s.authToProp},enumerable:true});Object.defineProperty(r,"connectorToProp",{get(){return s.connectorToProp},enumerable:true});Object.defineProperty(r,"localPropsToProp",{get(){return s.localPropsToProp},enumerable:true});return t};if(s.fireRegisterEvent){c.componentWillLoad=function(){const t=l?.call(this);const o=n(this);const i={element:o,...s,eventToProps:p};const a=r(c,i,s.registrationEventName);if(o.dispatchEvent(a)){e(`[${u}] Component ${u} successfully fired registration event`)}return t};c.disconnectedCallback=function(){const t=m?.call(this);const r=n(this);const i={element:r,...s,eventToProps:p};const l=o(c,i,s.unregistrationEventName);if(r.dispatchEvent(l)){e(`[${u}] Component ${u} successfully fired unregistration event`)}return t}}}}export{s as R};
|
|
2
|
+
//# sourceMappingURL=register-component-8b5587d5.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as t,b as e,a as i}from"./utils-3fdf2c83.js";import{c as n}from"./index-89ee2ce0.js";var s;(function(t){t["Error"]="error";t["Warning"]="warning";t["Info"]="info";t["Success"]="success"})(s||(s={}));var o;(function(t){t["Component"]="component";t["Api"]="api";t["Auth"]="auth"})(o||(o={}));var r;(function(t){t["endtime_not_in_future"]="endtime_not_in_future";t["no_booking_info"]="no_booking_info";t["no_timeslot_selected"]="no_timeslot_selected";t["no_timezone_selected"]="no_timezone_selected";t["no_booking_id"]="no_booking_id";t["no_salt"]="no_salt";t["invalid_start_time"]="invalid_start_time";t["invalid_end_time"]="invalid_end_time";t["invalid_timezone"]="invalid_timezone";t["no_config_id"]="no_config_id"})(r||(r={}));class a{constructor(){this.component=t=>{const e=o.Component;const i=`${t} Error`;return{endtime_not_in_future:(t='"endtime" can not be in the future')=>({title:i,message:t,category:e}),no_booking_info:(t="No booking info provided")=>({title:i,message:t,category:e}),no_timeslot_selected:(t="No timeslot selected")=>({title:i,message:t,category:e}),no_timezone_selected:(t="No timezone selected")=>({title:i,message:t,category:e}),no_booking_id:(t="No booking id provided")=>({title:i,message:t,category:e}),no_salt:(t="No salt provided")=>({title:i,message:t,category:e}),invalid_start_time:(t="Invalid start time")=>({title:i,message:t,category:e}),invalid_end_time:(t="Invalid end time")=>({title:i,message:t,category:e}),invalid_timezone:(t="Invalid timezone")=>({title:i,message:t,category:e}),no_config_id:(t="No configuration id provided")=>({title:i,message:t,category:e})}};this.api=t=>{const e=o.Api;const i=`${t} Error`;return{invalid_session:t=>({title:i,message:t,category:e}),general_error:t=>({title:i,message:t,category:e}),internal_error:t=>({title:i,message:t,category:e}),invalid_request_error:t=>({title:i,message:t,category:e}),timeslot_not_available:t=>({title:i,message:t,category:e}),provider_error:t=>({title:i,message:t,category:e}),not_found_error:t=>({title:i,message:t,category:e})}}}}class c{constructor({schedulerAPIURL:t,schedulerStore:e,sessionId:i,configId:n,slug:s,clientId:o}){this.errors=new a;this.schedulerStore=e;this.schedulerAPIURL=t;this.sessionId=i;this.configId=n;this.slug=s;this.clientId=o}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(t,e,i,n={}){try{const s=new URL(this.schedulerAPIURL);const o="1.4.1"||"latest";s.pathname=t;const r=await fetch(decodeURIComponent(s.toString()),{method:e,headers:{"Content-Type":"application/json",Origin:window.location.origin,"X-Source":"nylas-scheduling","X-Nylas-Web-Elements-Version":o,...n},body:i});const a=await r.json();return a}catch(t){return{error:{message:t.message,title:"API request failed",type:"api"}}}}getErrorMessage(t){let e=t?.message||t?.title||"Something went wrong";if(t?.type==="provider_error"){e=t?.provider_error?.error?.message||t?.provider_error?.error?.title||"Something went wrong"}return e}setConfigId(t){this.configId=t}selectDate(t){this.schedulerStore.set("selectedDate",t);this.schedulerStore.set("selectedTimeslot",null)}selectTime(t){this.schedulerStore.set("selectedTimeslot",t)}selectTimezone(t){this.schedulerStore.set("selectedTimezone",t)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e);t.changeLanguage(e)}async toggleAdditionalData(t){if(!t){await this.refetchAvailability()}this.schedulerStore.set("showBookingForm",t)}setParticipantName(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,name:t}})}setParticipantEmail(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,email:t}})}async refetchAvailability(){const t=new Date;const e=new Date(t.getFullYear(),t.getMonth(),1).getTime()/1e3;const i=e<t.getTime()/1e3?Math.floor(t.getTime()/1e3):e;const n=new Date(t.getFullYear(),t.getMonth()+1,1).getTime()/1e3;const s=await this.getAvailability(i,n);return s}async resetStoreStateAndFetchAvailability(){const t=new Date;const e=await this.refetchAvailability();const i=this.schedulerStore.get("availability").find((t=>new Date(t.start_time)>new Date));let n=t;if(i){n=i.start_time}this.schedulerStore.set("selectedDate",n);this.schedulerStore.set("eventInfo",null);this.schedulerStore.set("showBookingForm",false);this.schedulerStore.set("selectedTimeslot",null);return e}async setReschedule(t){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.state.eventInfo;if(e){this.schedulerStore.set("reschedulingEventInfo",e)}this.schedulerStore.set("rescheduleBookingId",t);await this.getUISettings();const i=await this.resetStoreStateAndFetchAvailability().finally((()=>{this.schedulerStore.set("isLoading",false)}));return i}async setCancel(t){this.schedulerStore.set("cancelBookingId",t)}async setReject(t){this.schedulerStore.set("rejectBookingId",t)}async resetCancel(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("cancelBookingId","");this.schedulerStore.set("rejectBookingId","");this.schedulerStore.set("cancelledEventInfo",null);return t}async goBack(){this.schedulerStore.set("cancelBookingId","");return}async resetConfirm(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("confirmedEventInfo",undefined);return t}async bookTimeslot(e){this.schedulerStore.set("isLoading",true);const{selectedTimeslot:i,selectedTimezone:n,bookingInfo:s,selectedLanguage:o}=this.schedulerStore.state;if(!e&&!s){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_booking_info()}}const r=e?.timeslot||i;if(!r){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timeslot_selected()}}const a=e&&e?.timezone?e?.timezone:n;const c=o||"en-US";if(!a){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timezone_selected()}}const l=[...this.schedulerStore.get("availabilityOrderEmails")];let d="";const h=r?.emails||[];const g={};Object.entries(s?.additionalFields||{}).forEach((([t,e])=>{g[t]=e.value}));const u=e?e?.primaryParticipant:s?.primaryParticipant;const f=e?e?.guests||[]:s?.guests||[];const m=e?e?.additionalFields:g;const _=this.getHeaders();const v=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const y=`/v3/scheduling/bookings${v}`;if(l.length===0){const t=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,event_id:r?.event_id||undefined,master_id:r?.master_id||undefined,calendar_id:r?.calendar_id||undefined,email_language:this.getTwoLetterLanguageCode(c)}),_);this.schedulerStore.set("isLoading",false);if("data"in t){this.schedulerStore.set("eventInfo",t.data);return t}return{error:t.error}}while(l.length>0){d=l.shift();if(!h.includes(d)){continue}const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({participants:d?[{email:d}]:undefined,additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,email_language:this.getTwoLetterLanguageCode(c)}),_);if("data"in e){this.schedulerStore.set("isLoading",false);this.schedulerStore.set("eventInfo",e?.data);return e}else if(e.error?.message?.startsWith("The selected timeslot is unavailable")){continue}else{this.schedulerStore.set("isLoading",false);const i=e.error?.type;let n=e.error;if(i&&i in this.errors.api(t.t("createBookingErrorTitle"))){const e=this.getErrorMessage(n);n=this.errors.api(t.t("createBookingErrorTitle"))[i](e)}return{error:n}}}this.schedulerStore.set("isLoading",false);return{error:this.errors.api(t.t("createBookingErrorTitle")).timeslot_not_available("The selected timeslot is unavailable")}}async getUISettings(){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.get("rescheduleBookingId");const i=this.getHeaders();let n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";if(e&&!!n){n+=`&booking_id=${e}`}else if(e){n+=`?booking_id=${e}`}const s=`/v3/scheduling/ui-settings${n}`;const o=await this.makeAPIRequest(s,"GET",undefined,i);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("getUISettingErrorTitle"))){i=this.errors.api(t.t("getUISettingErrorTitle"))[e](i?.message||i?.title||"Something went wrong")}return{error:i}}if("data"in o){this.schedulerStore.set("configSettings",o.data)}this.schedulerStore.set("isLoading",false);return o}getTwoLetterLanguageCode(t){return t.split("-")[0]}getStartTimeWithMinBookingNotice(t){const e=this.schedulerStore.get("configSettings")?.scheduler;const i=e?.min_booking_notice;if(!i){return t}const n=(new Date).getTime();if(t<(n+i*60*1e3)/1e3){return Math.floor((n+i*60*1e3)/1e3)}else{return t}}getEndTimeForAvailableDaysInFuture(t){const i=new Date;const n=this.schedulerStore.get("configSettings")?.scheduler?.available_days_in_future;const s=Math.floor(e(i,n).getTime()/1e3);const o=Math.min(s,t);return o}async getAvailability(e=0,i=0){this.schedulerStore.set("isLoading",true);const n=new URLSearchParams;const s=new Date;const o=s.getTime();if(i&&i<o/1e3){this.schedulerStore.set("isLoading",false);const e=this.errors.component(t.t("getAvailabilityErrorTitle")).endtime_not_in_future();return{error:e}}if(!e){const t=new Date(s.getFullYear(),s.getMonth(),1);e=Math.floor(t.getTime()/1e3)}if(!i){const t=new Date(s.getFullYear(),s.getMonth()+1,0);i=Math.floor(t.getTime()/1e3)}i=this.getEndTimeForAvailableDaysInFuture(i);const r=this.getStartTimeWithMinBookingNotice(e);e=r;i=r>i?r+1:i;n.append("start_time",encodeURIComponent(e.toString()));n.append("end_time",encodeURIComponent(i.toString()));if(this.configId&&!this.sessionId){n.append("configuration_id",encodeURIComponent(this.configId))}else if(this.slug&&this.clientId&&!this.sessionId){n.append("slug",encodeURIComponent(this.slug));n.append("client_id",encodeURIComponent(this.clientId))}const a=this.schedulerStore.get("rescheduleBookingId");if(a){n.append("booking_id",encodeURIComponent(a))}const c=n.toString();const l=`/v3/scheduling/availability${c?`?${c}`:""}`;const d=this.getHeaders();const h=await this.makeAPIRequest(decodeURIComponent(l),"GET",undefined,d);if("error"in h){this.schedulerStore.set("availability",[]);this.schedulerStore.set("isLoading",false);const e=h.error?.type;let i=h.error;if(e&&e in this.errors.api(t.t("getAvailabilityErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("getAvailabilityErrorTitle"))[e](n)}return{error:i}}if("data"in h){const t=h.data?.time_slots?.map((t=>({...t,start_time:new Date(t.start_time*1e3),end_time:new Date(t.end_time*1e3)})))||[];const e=t.filter((t=>t.start_time.getTime()>o));const i=e.sort(((t,e)=>t.start_time.getTime()-e.start_time.getTime()));this.schedulerStore.set("availability",i);const n=h.data?.order||[];this.schedulerStore.set("availabilityOrderEmails",n)}this.schedulerStore.set("isLoading",false);return h}async cancelBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("cancelBookingErrorTitle")).no_booking_id()}}const n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const s=`/v3/scheduling/bookings/${e}${n}`;const o=this.getHeaders();const r=await this.makeAPIRequest(decodeURIComponent(s),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:i}),o);if("error"in r){this.schedulerStore.set("isLoading",false);const e=r.error?.type;let i=r.error;if(e&&e in this.errors.api(t.t("cancelBookingErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("cancelBookingErrorTitle"))[e](n)}return{error:i}}this.schedulerStore.set("cancelledEventInfo",{booking_id:e});this.schedulerStore.set("rescheduleBookingId","");this.schedulerStore.set("isLoading",false);return r}async rescheduleBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("rescheduleBookingErrorTitle")).no_booking_id()}}const n=this.errors.api(t.t("rescheduleBookingErrorTitle"));const s=this.errors.component(t.t("rescheduleBookingErrorTitle"));const{bookingInfo:o,selectedTimeslot:r,selectedTimezone:a,selectedLanguage:c}=this.schedulerStore.state;const{startTime:l,endTime:d,timezone:h}=i;const g=l||r?.start_time;if(!g){return{error:s.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const u=d||r?.end_time;if(!u){return{error:s.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const f=this.schedulerStore.get("availabilityOrderEmails");let m="";if(f.length>0){const t=r?.emails||[];for(let e=0;e<f.length;e++){if(t.includes(f[e])){m=f[e];break}}}const _=h||a;if(!_){return{error:s.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')}}const v={};Object.entries(o?.additionalFields||{}).forEach((([t,e])=>{v[t]=e.value}));const y=i?i?.primaryParticipant:o?.primaryParticipant;const I=i?i?.guests||[]:o?.guests||[];const T=i?i?.additionalFields:v;const k=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const b=`/v3/scheduling/bookings/${e}${k}`;const w=this.getHeaders();const E=await this.makeAPIRequest(decodeURIComponent(b),"PATCH",JSON.stringify({start_time:g.getTime()/1e3,end_time:u.getTime()/1e3,timezone:_,additional_fields:T,guest:{...y},additional_guests:I,participants:m?[{email:m}]:undefined,email_language:this.getTwoLetterLanguageCode(c)}),w);if("error"in E){this.schedulerStore.set("isLoading",false);const t=E.error?.type;let e=E.error;if(t&&t in n){const i=this.getErrorMessage(e);e=n[t](i)}return{error:e}}const p=this.schedulerStore.get("reschedulingEventInfo");if("data"in E){this.schedulerStore.set("eventInfo",E?.data)}else if(p){this.schedulerStore.set("eventInfo",p)}else{const t={booking_id:e};this.schedulerStore.set("eventInfo",t)}this.schedulerStore.set("isLoading",false);return E}async updateBooking(e){this.schedulerStore.set("isLoading",true);const{bookingId:i,status:n,reason:s}=e;const o=this.schedulerStore.get("organizerConfirmationSalt");const r=n==="confirmed"?t.t("confirmBookingErrorTitle"):t.t("rejectBookingErrorTitle");if(!i){return{error:this.errors.component(r).no_booking_id()}}if(!o){return{error:this.errors.component(r).no_salt()}}const a=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const c=`/v3/scheduling/bookings/${i}${a}`;const l=this.getHeaders();const d=await this.makeAPIRequest(decodeURIComponent(c),"PUT",JSON.stringify({status:n,cancellation_reason:s,salt:o}),l);if("error"in d){this.schedulerStore.set("isLoading",false);const t=d.error?.type;let e=d.error;if(t&&t in this.errors.api(r)){const i=this.getErrorMessage(e);e=this.errors.api(r)[t](i)}return{error:e}}if("data"in d&&n==="confirmed"){this.schedulerStore.set("confirmedEventInfo",d?.data)}else if("request_id"in d&&n==="cancelled"){this.schedulerStore.set("cancelledEventInfo",{booking_id:i})}this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("isLoading",false);return d}async validateGroupEventTimeslot(e){this.schedulerStore.set("isLoading",true);const i=this.schedulerStore.get("configSettings")?.configuration_id;if(!i){return{error:this.errors.component(t.t("validateTimeslotErrorTitle")).no_config_id()}}const n=this.getHeaders();const s=`/v3/scheduling/configurations/${i}/group-events/validate-timeslot`;const o=await this.makeAPIRequest(decodeURIComponent(s),"POST",JSON.stringify({...e,start_time:e.start_time.getTime()/1e3,end_time:e.end_time.getTime()/1e3}),n);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("validateTimeslotErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("validateTimeslotErrorTitle"))[e](n)}this.refetchAvailability();return{error:i}}this.schedulerStore.set("selectedTimeslot",e);this.schedulerStore.set("showBookingForm",true);this.schedulerStore.set("isLoading",false);return o}}function l(t={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:false,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:false,nylasBranding:true,...t};i(`[defaultNylasStoreState]: `,e);const s=n(e);s.onChange("availability",(t=>{i(`[availability]: `,t);const e=t.map((t=>t.start_time));i(`[selectableDates]: `,e);s.set("selectableDates",e);const n=t[0];if(!n)return;const o=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);i(`[durationMinutes]: `,o);s.set("eventDuration",o)}));s.reset=()=>{for(const t in e){const i=e[t];s.set(t,i)}};return s}export{l as C,o as E,c as N};
|
|
2
|
-
//# sourceMappingURL=scheduler-store-
|
|
1
|
+
import{i as t,b as e,a as i}from"./utils-ac8fef1e.js";import{c as n}from"./index-89ee2ce0.js";var s;(function(t){t["Error"]="error";t["Warning"]="warning";t["Info"]="info";t["Success"]="success"})(s||(s={}));var o;(function(t){t["Component"]="component";t["Api"]="api";t["Auth"]="auth"})(o||(o={}));var r;(function(t){t["endtime_not_in_future"]="endtime_not_in_future";t["no_booking_info"]="no_booking_info";t["no_timeslot_selected"]="no_timeslot_selected";t["no_timezone_selected"]="no_timezone_selected";t["no_booking_id"]="no_booking_id";t["no_salt"]="no_salt";t["invalid_start_time"]="invalid_start_time";t["invalid_end_time"]="invalid_end_time";t["invalid_timezone"]="invalid_timezone";t["no_config_id"]="no_config_id"})(r||(r={}));class a{constructor(){this.component=t=>{const e=o.Component;const i=`${t} Error`;return{endtime_not_in_future:(t='"endtime" can not be in the future')=>({title:i,message:t,category:e}),no_booking_info:(t="No booking info provided")=>({title:i,message:t,category:e}),no_timeslot_selected:(t="No timeslot selected")=>({title:i,message:t,category:e}),no_timezone_selected:(t="No timezone selected")=>({title:i,message:t,category:e}),no_booking_id:(t="No booking id provided")=>({title:i,message:t,category:e}),no_salt:(t="No salt provided")=>({title:i,message:t,category:e}),invalid_start_time:(t="Invalid start time")=>({title:i,message:t,category:e}),invalid_end_time:(t="Invalid end time")=>({title:i,message:t,category:e}),invalid_timezone:(t="Invalid timezone")=>({title:i,message:t,category:e}),no_config_id:(t="No configuration id provided")=>({title:i,message:t,category:e})}};this.api=t=>{const e=o.Api;const i=`${t} Error`;return{invalid_session:t=>({title:i,message:t,category:e}),general_error:t=>({title:i,message:t,category:e}),internal_error:t=>({title:i,message:t,category:e}),invalid_request_error:t=>({title:i,message:t,category:e}),timeslot_not_available:t=>({title:i,message:t,category:e}),provider_error:t=>({title:i,message:t,category:e}),not_found_error:t=>({title:i,message:t,category:e})}}}}class c{constructor({schedulerAPIURL:t,schedulerStore:e,sessionId:i,configId:n,slug:s,clientId:o}){this.errors=new a;this.schedulerStore=e;this.schedulerAPIURL=t;this.sessionId=i;this.configId=n;this.slug=s;this.clientId=o}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(t,e,i,n={}){try{const s=new URL(this.schedulerAPIURL);const o="1.4.3"||"latest";s.pathname=t;const r=await fetch(decodeURIComponent(s.toString()),{method:e,headers:{"Content-Type":"application/json",Origin:window.location.origin,"X-Source":"nylas-scheduling","X-Nylas-Web-Elements-Version":o,...n},body:i});const a=await r.json();return a}catch(t){return{error:{message:t.message,title:"API request failed",type:"api"}}}}getErrorMessage(t){let e=t?.message||t?.title||"Something went wrong";if(t?.type==="provider_error"){e=t?.provider_error?.error?.message||t?.provider_error?.error?.title||"Something went wrong"}return e}setConfigId(t){this.configId=t}selectDate(t){this.schedulerStore.set("selectedDate",t);this.schedulerStore.set("selectedTimeslot",null)}selectTime(t){this.schedulerStore.set("selectedTimeslot",t)}selectTimezone(t){this.schedulerStore.set("selectedTimezone",t)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e);t.changeLanguage(e)}async toggleAdditionalData(t){if(!t){await this.refetchAvailability()}this.schedulerStore.set("showBookingForm",t)}setParticipantName(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,name:t}})}setParticipantEmail(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e?.primaryParticipant,email:t}})}async refetchAvailability(){const t=new Date;const e=new Date(t.getFullYear(),t.getMonth(),1).getTime()/1e3;const i=e<t.getTime()/1e3?Math.floor(t.getTime()/1e3):e;const n=new Date(t.getFullYear(),t.getMonth()+1,1).getTime()/1e3;const s=await this.getAvailability(i,n);return s}async resetStoreStateAndFetchAvailability(){const t=new Date;const e=await this.refetchAvailability();const i=this.schedulerStore.get("availability").find((t=>new Date(t.start_time)>new Date));let n=t;if(i){n=i.start_time}this.schedulerStore.set("selectedDate",n);this.schedulerStore.set("eventInfo",null);this.schedulerStore.set("showBookingForm",false);this.schedulerStore.set("selectedTimeslot",null);return e}async setReschedule(t){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.state.eventInfo;if(e){this.schedulerStore.set("reschedulingEventInfo",e)}this.schedulerStore.set("rescheduleBookingId",t);await this.getUISettings();const i=await this.resetStoreStateAndFetchAvailability().finally((()=>{this.schedulerStore.set("isLoading",false)}));return i}async setCancel(t){this.schedulerStore.set("cancelBookingId",t)}async setReject(t){this.schedulerStore.set("rejectBookingId",t)}async resetCancel(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("cancelBookingId","");this.schedulerStore.set("rejectBookingId","");this.schedulerStore.set("cancelledEventInfo",null);return t}async goBack(){this.schedulerStore.set("cancelBookingId","");return}async resetConfirm(){const t=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("confirmedEventInfo",undefined);return t}async bookTimeslot(e){this.schedulerStore.set("isLoading",true);const{selectedTimeslot:i,selectedTimezone:n,bookingInfo:s,selectedLanguage:o}=this.schedulerStore.state;if(!e&&!s){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_booking_info()}}const r=e?.timeslot||i;if(!r){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timeslot_selected()}}const a=e&&e?.timezone?e?.timezone:n;const c=o||"en-US";if(!a){return{error:this.errors.component(t.t("createBookingErrorTitle")).no_timezone_selected()}}const l=[...this.schedulerStore.get("availabilityOrderEmails")];let d="";const h=r?.emails||[];const g={};Object.entries(s?.additionalFields||{}).forEach((([t,e])=>{g[t]=e.value}));const u=e?e?.primaryParticipant:s?.primaryParticipant;const f=e?e?.guests||[]:s?.guests||[];const m=e?e?.additionalFields:g;const _=this.getHeaders();const v=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const y=`/v3/scheduling/bookings${v}`;if(l.length===0){const t=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,event_id:r?.event_id||undefined,master_id:r?.master_id||undefined,calendar_id:r?.calendar_id||undefined,email_language:this.getTwoLetterLanguageCode(c)}),_);this.schedulerStore.set("isLoading",false);if("data"in t){this.schedulerStore.set("eventInfo",t.data);return t}return{error:t.error}}while(l.length>0){d=l.shift();if(!h.includes(d)){continue}const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({participants:d?[{email:d}]:undefined,additional_fields:m,additional_guests:f,guest:{...u},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:a,email_language:this.getTwoLetterLanguageCode(c)}),_);if("data"in e){this.schedulerStore.set("isLoading",false);this.schedulerStore.set("eventInfo",e?.data);return e}else if(e.error?.message?.startsWith("The selected timeslot is unavailable")){continue}else{this.schedulerStore.set("isLoading",false);const i=e.error?.type;let n=e.error;if(i&&i in this.errors.api(t.t("createBookingErrorTitle"))){const e=this.getErrorMessage(n);n=this.errors.api(t.t("createBookingErrorTitle"))[i](e)}return{error:n}}}this.schedulerStore.set("isLoading",false);return{error:this.errors.api(t.t("createBookingErrorTitle")).timeslot_not_available("The selected timeslot is unavailable")}}async getUISettings(){this.schedulerStore.set("isLoading",true);const e=this.schedulerStore.get("rescheduleBookingId");const i=this.getHeaders();let n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";if(e&&!!n){n+=`&booking_id=${e}`}else if(e){n+=`?booking_id=${e}`}const s=`/v3/scheduling/ui-settings${n}`;const o=await this.makeAPIRequest(s,"GET",undefined,i);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("getUISettingErrorTitle"))){i=this.errors.api(t.t("getUISettingErrorTitle"))[e](i?.message||i?.title||"Something went wrong")}return{error:i}}if("data"in o){this.schedulerStore.set("configSettings",o.data)}this.schedulerStore.set("isLoading",false);return o}getTwoLetterLanguageCode(t){return t.split("-")[0]}getStartTimeWithMinBookingNotice(t){const e=this.schedulerStore.get("configSettings")?.scheduler;const i=e?.min_booking_notice;if(!i){return t}const n=(new Date).getTime();if(t<(n+i*60*1e3)/1e3){return Math.floor((n+i*60*1e3)/1e3)}else{return t}}getEndTimeForAvailableDaysInFuture(t){const i=new Date;const n=this.schedulerStore.get("configSettings")?.scheduler?.available_days_in_future;const s=Math.floor(e(i,n).getTime()/1e3);const o=Math.min(s,t);return o}async getAvailability(e=0,i=0){this.schedulerStore.set("isLoading",true);const n=new URLSearchParams;const s=new Date;const o=s.getTime();if(i&&i<o/1e3){this.schedulerStore.set("isLoading",false);const e=this.errors.component(t.t("getAvailabilityErrorTitle")).endtime_not_in_future();return{error:e}}if(!e){const t=new Date(s.getFullYear(),s.getMonth(),1);e=Math.floor(t.getTime()/1e3)}if(!i){const t=new Date(s.getFullYear(),s.getMonth()+1,0);i=Math.floor(t.getTime()/1e3)}i=this.getEndTimeForAvailableDaysInFuture(i);const r=this.getStartTimeWithMinBookingNotice(e);e=r;i=r>i?r+1:i;n.append("start_time",encodeURIComponent(e.toString()));n.append("end_time",encodeURIComponent(i.toString()));if(this.configId&&!this.sessionId){n.append("configuration_id",encodeURIComponent(this.configId))}else if(this.slug&&this.clientId&&!this.sessionId){n.append("slug",encodeURIComponent(this.slug));n.append("client_id",encodeURIComponent(this.clientId))}const a=this.schedulerStore.get("rescheduleBookingId");if(a){n.append("booking_id",encodeURIComponent(a))}const c=n.toString();const l=`/v3/scheduling/availability${c?`?${c}`:""}`;const d=this.getHeaders();const h=await this.makeAPIRequest(decodeURIComponent(l),"GET",undefined,d);if("error"in h){this.schedulerStore.set("availability",[]);this.schedulerStore.set("isLoading",false);const e=h.error?.type;let i=h.error;if(e&&e in this.errors.api(t.t("getAvailabilityErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("getAvailabilityErrorTitle"))[e](n)}return{error:i}}if("data"in h){const t=h.data?.time_slots?.map((t=>({...t,start_time:new Date(t.start_time*1e3),end_time:new Date(t.end_time*1e3)})))||[];const e=t.filter((t=>t.start_time.getTime()>o));const i=e.sort(((t,e)=>t.start_time.getTime()-e.start_time.getTime()));this.schedulerStore.set("availability",i);const n=h.data?.order||[];this.schedulerStore.set("availabilityOrderEmails",n)}this.schedulerStore.set("isLoading",false);return h}async cancelBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("cancelBookingErrorTitle")).no_booking_id()}}const n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const s=`/v3/scheduling/bookings/${e}${n}`;const o=this.getHeaders();const r=await this.makeAPIRequest(decodeURIComponent(s),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:i}),o);if("error"in r){this.schedulerStore.set("isLoading",false);const e=r.error?.type;let i=r.error;if(e&&e in this.errors.api(t.t("cancelBookingErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("cancelBookingErrorTitle"))[e](n)}return{error:i}}this.schedulerStore.set("cancelledEventInfo",{booking_id:e});this.schedulerStore.set("rescheduleBookingId","");this.schedulerStore.set("isLoading",false);return r}async rescheduleBooking(e,i){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(t.t("rescheduleBookingErrorTitle")).no_booking_id()}}const n=this.errors.api(t.t("rescheduleBookingErrorTitle"));const s=this.errors.component(t.t("rescheduleBookingErrorTitle"));const{bookingInfo:o,selectedTimeslot:r,selectedTimezone:a,selectedLanguage:c}=this.schedulerStore.state;const{startTime:l,endTime:d,timezone:h}=i;const g=l||r?.start_time;if(!g){return{error:s.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const u=d||r?.end_time;if(!u){return{error:s.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const f=this.schedulerStore.get("availabilityOrderEmails");let m="";if(f.length>0){const t=r?.emails||[];for(let e=0;e<f.length;e++){if(t.includes(f[e])){m=f[e];break}}}const _=h||a;if(!_){return{error:s.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')}}const v={};Object.entries(o?.additionalFields||{}).forEach((([t,e])=>{v[t]=e.value}));const y=i?i?.primaryParticipant:o?.primaryParticipant;const I=i?i?.guests||[]:o?.guests||[];const T=i?i?.additionalFields:v;const k=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const b=`/v3/scheduling/bookings/${e}${k}`;const w=this.getHeaders();const E=await this.makeAPIRequest(decodeURIComponent(b),"PATCH",JSON.stringify({start_time:g.getTime()/1e3,end_time:u.getTime()/1e3,timezone:_,additional_fields:T,guest:{...y},additional_guests:I,participants:m?[{email:m}]:undefined,email_language:this.getTwoLetterLanguageCode(c)}),w);if("error"in E){this.schedulerStore.set("isLoading",false);const t=E.error?.type;let e=E.error;if(t&&t in n){const i=this.getErrorMessage(e);e=n[t](i)}return{error:e}}const p=this.schedulerStore.get("reschedulingEventInfo");if("data"in E){this.schedulerStore.set("eventInfo",E?.data)}else if(p){this.schedulerStore.set("eventInfo",p)}else{const t={booking_id:e};this.schedulerStore.set("eventInfo",t)}this.schedulerStore.set("isLoading",false);return E}async updateBooking(e){this.schedulerStore.set("isLoading",true);const{bookingId:i,status:n,reason:s}=e;const o=this.schedulerStore.get("organizerConfirmationSalt");const r=n==="confirmed"?t.t("confirmBookingErrorTitle"):t.t("rejectBookingErrorTitle");if(!i){return{error:this.errors.component(r).no_booking_id()}}if(!o){return{error:this.errors.component(r).no_salt()}}const a=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const c=`/v3/scheduling/bookings/${i}${a}`;const l=this.getHeaders();const d=await this.makeAPIRequest(decodeURIComponent(c),"PUT",JSON.stringify({status:n,cancellation_reason:s,salt:o}),l);if("error"in d){this.schedulerStore.set("isLoading",false);const t=d.error?.type;let e=d.error;if(t&&t in this.errors.api(r)){const i=this.getErrorMessage(e);e=this.errors.api(r)[t](i)}return{error:e}}if("data"in d&&n==="confirmed"){this.schedulerStore.set("confirmedEventInfo",d?.data)}else if("request_id"in d&&n==="cancelled"){this.schedulerStore.set("cancelledEventInfo",{booking_id:i})}this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("isLoading",false);return d}async validateGroupEventTimeslot(e){this.schedulerStore.set("isLoading",true);const i=this.schedulerStore.get("configSettings")?.configuration_id;if(!i){return{error:this.errors.component(t.t("validateTimeslotErrorTitle")).no_config_id()}}const n=this.getHeaders();const s=`/v3/scheduling/configurations/${i}/group-events/validate-timeslot`;const o=await this.makeAPIRequest(decodeURIComponent(s),"POST",JSON.stringify({...e,start_time:e.start_time.getTime()/1e3,end_time:e.end_time.getTime()/1e3}),n);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let i=o.error;if(e&&e in this.errors.api(t.t("validateTimeslotErrorTitle"))){const n=this.getErrorMessage(i);i=this.errors.api(t.t("validateTimeslotErrorTitle"))[e](n)}this.refetchAvailability();return{error:i}}this.schedulerStore.set("selectedTimeslot",e);this.schedulerStore.set("showBookingForm",true);this.schedulerStore.set("isLoading",false);return o}}function l(t={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:false,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:false,nylasBranding:true,...t};i(`[defaultNylasStoreState]: `,e);const s=n(e);s.onChange("availability",(t=>{i(`[availability]: `,t);const e=t.map((t=>t.start_time));i(`[selectableDates]: `,e);s.set("selectableDates",e);const n=t[0];if(!n)return;const o=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);i(`[durationMinutes]: `,o);s.set("eventDuration",o)}));s.reset=()=>{for(const t in e){const i=e[t];s.set(t,i)}};return s}export{l as C,o as E,c as N};
|
|
2
|
+
//# sourceMappingURL=scheduler-store-36b93b74.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e,i as a,h as l}from"./index-3e0d6890.js";import{l as r}from"./utils-
|
|
1
|
+
import{r as e,i as a,h as l}from"./index-3e0d6890.js";import{l as r}from"./utils-ac8fef1e.js";import"./utc-290d564f.js";const s=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;flex-direction:column;gap:4px;font-family:var(--nylas-font-family);font-size:16px;color:var(--nylas-base-800)}label.error{color:var(--nylas-error)}label span.required{color:var(--nylas-error);padding:0 0.25rem}label p{margin:0;display:flex;gap:4px;align-items:center}label .error{color:var(--nylas-error)}textarea{display:flex;height:48px;padding-left:16px;align-items:center;gap:8px;align-self:stretch;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-300);background:var(--nylas-base-0);width:-webkit-fill-available;color:var(--nylas-base-900);font-size:16px;font-style:normal;font-weight:400;line-height:150%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}textarea:read-only{background-color:var(--nylas-base-100);cursor:not-allowed}';const o=class{constructor(l){e(this,l);this.nylasFormInputChanged=a(this,"nylasFormInputChanged",7);this.name="textarea";this.defaultValue=undefined;this.label="";this.placeholder="";this.required=false;this.readOnly=false;this.autoFocus=false;this.maxLength=255;this.type="multi_line_text";this.tooltip="";this.value="";this.error=""}componentDidLoad(){this.value=r(this.defaultValue||"")}handleBookingFormSubmitted(e){this.validate(this.value);if(this.error){e.preventDefault()}}handletriggerValidation(e){this.validate(this.value);if(this.error){e.preventDefault()}}handleInput(e){this.error="";const a=e.target;this.value=r(a.value);this.nylasFormInputChanged.emit({value:this.value,name:this.name,error:this.error,label:this.label,type:this.type})}validate(e){if(this.required&&!e){this.error=`${this.label} is required.`}else if(e.length>this.maxLength){this.error=`${this.label} cannot exceed ${this.maxLength} characters.`}else{this.error=""}}render(){return l("label",{key:"dfa36b319e151ee064e1dce59391cc1be9cd2284",part:"tc__label",class:{error:!!this.error}},l("p",{key:"5dfc3110496c05244225cabc70ccca711b4cbb3b"},l("span",{key:"87c2996b6a258d78f829fe57bcab0654216ec3b9",class:"label"},this.label),this.required&&l("span",{class:"required"},"*"),this.tooltip&&l("tooltip-component",null,l("info-icon",{slot:"tooltip-icon"}),l("span",{slot:"tooltip-content"},this.tooltip))),l("textarea",{key:"ed5c0c9044999404daa9282b70e31698a4571463",name:this.name,title:this.readOnly?"read-only field":undefined,placeholder:this.placeholder,readOnly:this.readOnly,autoFocus:this.autoFocus,value:this.value,maxLength:this.maxLength,onInput:e=>this.handleInput(e),class:{error:!!this.error},part:"tc__textarea"}),this.error&&l("span",{class:"error help-text"},this.error))}};o.style=s;export{o as textarea_component};
|
|
2
2
|
//# sourceMappingURL=textarea-component.entry.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e,i as t,h as r,e as o}from"./index-3e0d6890.js";import{h as i}from"./constants-794fe173.js";import{a as d,i as s}from"./utils-
|
|
1
|
+
import{r as e,i as t,h as r,e as o}from"./index-3e0d6890.js";import{h as i}from"./constants-794fe173.js";import{a as d,i as s}from"./utils-ac8fef1e.js";import"./utc-290d564f.js";const n=".time-period-selector.sc-time-period-selector{display:grid;gap:0.5rem;grid-template-columns:auto 1fr}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector,.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector{width:116px}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{width:84px;display:flex;align-items:center}.time-period-selector.sc-time-period-selector select-dropdown#time-period.sc-time-period-selector::part(sd_dropdown-button){width:100%}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown){width:inherit;height:100%}.time-period-selector.sc-time-period-selector input-dropdown#time-number.sc-time-period-selector::part(id_dropdown-input){border:none;border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector input-dropdown#time-number.error.sc-time-period-selector::part(id_dropdown-input){border:1px solid var(--nylas-error)}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector:hover{outline:1px solid var(--nylas-primary);border:none}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-input){padding:16px;gap:1rem}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-input):hover{border:none;outline:none}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-content){width:100%;max-height:200px}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown){width:inherit;height:100%}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown_label){height:100%}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-button){padding:1rem;gap:1rem;justify-content:space-between;border:none;align-items:center;height:100%}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-content){width:100%;max-height:200px}";const p={hours:"hour",days:"day",weeks:"week",months:"month",years:"year"};const c=class{constructor(r){e(this,r);this.timePeriodChanged=t(this,"timePeriodChanged",7);this.timePeriods=i;this.defaultSelectedPeriod=undefined;this.defaultSelectedNumber=undefined;this.hasError=false;this.selectedPeriod=this.defaultSelectedPeriod;this.selectedNumber=this.defaultSelectedNumber;this.numberOptions=this.calculateOptions(this.defaultSelectedPeriod||"hour").map((e=>({label:e.toString(),value:e.toString()})));this.timePeriodOptions=this.timePeriods.map((e=>({label:e.label,value:e.value})))}defaultSelectedPeriodChanged(e){this.selectedPeriod=e;this.updateNumberOptionsAndSelectedNumber(e)}defaultSelectedNumberChanged(e){this.selectedNumber=e}timePeriodsChanged(e){this.timePeriodOptions=[...e]}componentDidLoad(){this.selectedNumber=this.defaultSelectedNumber;this.selectedPeriod=this.defaultSelectedPeriod;const e=p[this.selectedPeriod]??this.selectedPeriod;const t=this.calculateOptions(e);this.numberOptions=t.map((e=>({label:e.toString(),value:e.toString()})))}calculateOptions(e){switch(e){case"hour":return Array.from({length:23},((e,t)=>t+1));case"minute":return Array.from({length:13},((e,t)=>t*5));case"day":return Array.from({length:30},((e,t)=>t+1));case"week":return Array.from({length:4},((e,t)=>t+1));case"month":return Array.from({length:12},((e,t)=>t+1));case"year":return Array.from({length:10},((e,t)=>t+1));default:return[]}}inputOptionChangedHandler(e){d("time-period-selector","inputOptionChangedHandler",e.detail);const{value:t,name:r}=e.detail;if(r==="time-number"){this.selectedNumber=t?parseInt(t):this.defaultSelectedNumber}const o={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(o)}nylasFormDropdownChangedHandler(e){d("time-period-selector","nylasFormDropdownChangedHandler",e.detail);const{value:t,name:r}=e.detail;if(r==="time-period"){this.selectedPeriod=t;this.updateNumberOptionsAndSelectedNumber(t)}else if(r==="time-number"){this.selectedNumber=parseInt(t)}const o={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(o)}updateNumberOptionsAndSelectedNumber(e){const t=this.calculateOptions(e);this.numberOptions=t.map((e=>({label:e.toString(),value:e.toString()})))}render(){return r("div",{key:"9e0fdc7e29a1f2736f392fa3ce86add3290d8361",class:"time-period-selector"},typeof this.selectedNumber=="number"&&r("input-dropdown",{id:"time-number",name:"time-number",class:{error:this.hasError},inputValue:this.selectedNumber.toString(),exportparts:"id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content",options:this.numberOptions,defaultInputOption:this.numberOptions.find((e=>e.value==this.selectedNumber.toString()))}),typeof this.selectedPeriod=="string"&&r("select-dropdown",{id:"time-period",name:"time-period",options:this.timePeriodOptions,exportparts:"sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content",pluralizedLabel:this.selectedNumber>1?s.t(`time.${this.selectedPeriod}s`):s.t(`time.${this.selectedPeriod}`),defaultSelectedOption:this.timePeriodOptions?.find((e=>e.value==this.selectedPeriod)),withSearch:false}))}get host(){return o(this)}static get watchers(){return{defaultSelectedPeriod:["defaultSelectedPeriodChanged"],defaultSelectedNumber:["defaultSelectedNumberChanged"],timePeriods:["timePeriodsChanged"]}}};c.style=n;export{c as time_period_selector};
|
|
2
2
|
//# sourceMappingURL=time-period-selector.entry.js.map
|