@nylas/web-elements 1.3.2 → 1.3.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/cdn/checkbox-component/checkbox-component.es.js +48 -38
- package/dist/cdn/multi-select-dropdown/multi-select-dropdown.es.js +554 -535
- package/dist/cdn/nylas-additional-participants/nylas-additional-participants.es.js +2 -2
- package/dist/cdn/nylas-booking-form/nylas-booking-form.es.js +25 -9
- package/dist/cdn/nylas-booking-form-config/nylas-booking-form-config.es.js +2182 -2171
- package/dist/cdn/nylas-buffer-time/nylas-buffer-time.es.js +13 -14
- package/dist/cdn/nylas-calendar-picker/nylas-calendar-picker.es.js +571 -552
- package/dist/cdn/nylas-connected-calendars/nylas-connected-calendars.es.js +26 -7
- package/dist/cdn/nylas-customize-booking-settings/nylas-customize-booking-settings.es.js +12 -2
- package/dist/cdn/nylas-date-component/nylas-date-component.es.js +13 -7
- package/dist/cdn/nylas-editor-tabs/nylas-editor-tabs.es.js +3550 -3473
- package/dist/cdn/nylas-event-location/nylas-event-location.es.js +633 -621
- package/dist/cdn/nylas-limit-future-bookings/nylas-limit-future-bookings.es.js +25 -2
- package/dist/cdn/nylas-min-booking-notice/nylas-min-booking-notice.es.js +25 -2
- package/dist/cdn/nylas-min-cancellation-notice/nylas-min-cancellation-notice.es.js +163 -140
- package/dist/cdn/nylas-page-styling/nylas-page-styling.es.js +5 -3
- package/dist/cdn/nylas-participants-custom-availability/nylas-participants-custom-availability.es.js +4 -3
- package/dist/cdn/nylas-provider/nylas-provider.es.js +1 -1
- package/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +173 -96
- package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +28 -12
- package/dist/cdn/scheduler-store/scheduler-store.es.js +1 -1
- package/dist/cdn/time-period-selector/time-period-selector.es.js +25 -2
- package/dist/cjs/calendar-agenda-fill-icon_53.cjs.entry.js +88 -57
- package/dist/cjs/calendar-agenda-fill-icon_53.cjs.entry.js.map +1 -1
- package/dist/cjs/checkbox-component.cjs.entry.js +9 -1
- package/dist/cjs/checkbox-component.cjs.entry.js.map +1 -1
- package/dist/cjs/checkbox-component_3.cjs.entry.js +21 -8
- package/dist/cjs/checkbox-component_3.cjs.entry.js.map +1 -1
- package/dist/cjs/google-logo-icon_4.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/multi-select-dropdown.cjs.entry.js +19 -1
- package/dist/cjs/multi-select-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-additional-participants.cjs.entry.js +1 -1
- package/dist/cjs/nylas-additional-participants.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-booking-form-config.cjs.entry.js +34 -27
- package/dist/cjs/nylas-booking-form-config.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-buffer-time.cjs.entry.js +13 -12
- package/dist/cjs/nylas-buffer-time.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-connected-calendars.cjs.entry.js +2 -2
- package/dist/cjs/nylas-connected-calendars.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-date-component.cjs.entry.js +12 -7
- package/dist/cjs/nylas-date-component.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-editor-tabs.cjs.entry.js +2 -2
- package/dist/cjs/nylas-event-location.cjs.entry.js +32 -11
- package/dist/cjs/nylas-event-location.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-page-styling.cjs.entry.js +3 -2
- package/dist/cjs/nylas-page-styling.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-participants-custom-availability.cjs.entry.js +3 -2
- package/dist/cjs/nylas-participants-custom-availability.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-provider.cjs.entry.js +1 -1
- package/dist/cjs/nylas-scheduling.cjs.entry.js +3 -3
- package/dist/cjs/nylas-web-elements.cjs.js +1 -1
- package/dist/cjs/{scheduler-store-37a0e152.js → scheduler-store-2cd220d1.js} +2 -2
- package/dist/cjs/{scheduler-store-37a0e152.js.map → scheduler-store-2cd220d1.js.map} +1 -1
- package/dist/cjs/{scheduler-store-373adf03.js → scheduler-store-70af2279.js} +2 -2
- package/dist/cjs/{scheduler-store-373adf03.js.map → scheduler-store-70af2279.js.map} +1 -1
- package/dist/cjs/time-period-selector.cjs.entry.js +21 -1
- package/dist/cjs/time-period-selector.cjs.entry.js.map +1 -1
- package/dist/collection/components/design-system/checkbox-component/checkbox-component.js +12 -1
- package/dist/collection/components/design-system/checkbox-component/checkbox-component.js.map +1 -1
- package/dist/collection/components/design-system/multi-select-dropdown/multi-select-dropdown.js +22 -1
- package/dist/collection/components/design-system/multi-select-dropdown/multi-select-dropdown.js.map +1 -1
- package/dist/collection/components/design-system/nylas-date-component/nylas-date-component.js +14 -8
- package/dist/collection/components/design-system/nylas-date-component/nylas-date-component.js.map +1 -1
- package/dist/collection/components/design-system/nylas-date-component/test/nylas-date-component.spec.js +39 -0
- package/dist/collection/components/design-system/nylas-date-component/test/nylas-date-component.spec.js.map +1 -0
- package/dist/collection/components/design-system/time-period-selector/time-period-selector.js +28 -1
- package/dist/collection/components/design-system/time-period-selector/time-period-selector.js.map +1 -1
- package/dist/collection/components/scheduler/nylas-date-picker/test/nylas-date-picker.spec.js +3 -1
- package/dist/collection/components/scheduler/nylas-date-picker/test/nylas-date-picker.spec.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-additional-participants/nylas-additional-participants.js +1 -1
- package/dist/collection/components/scheduler-editor/nylas-additional-participants/nylas-additional-participants.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-booking-form-config/nylas-booking-form-config.js +36 -27
- package/dist/collection/components/scheduler-editor/nylas-booking-form-config/nylas-booking-form-config.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-booking-form-config/test/nylas-booking-form-config.spec.js +23 -0
- package/dist/collection/components/scheduler-editor/nylas-booking-form-config/test/nylas-booking-form-config.spec.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.js +13 -12
- package/dist/collection/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-calendar-picker/test/nylas-calendar-picker.spec.js +13 -0
- package/dist/collection/components/scheduler-editor/nylas-calendar-picker/test/nylas-calendar-picker.spec.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-connected-calendars/nylas-connected-calendars.js +2 -2
- package/dist/collection/components/scheduler-editor/nylas-connected-calendars/nylas-connected-calendars.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-event-location/nylas-event-location.js +35 -10
- package/dist/collection/components/scheduler-editor/nylas-event-location/nylas-event-location.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-page-styling/nylas-page-styling.js +4 -1
- package/dist/collection/components/scheduler-editor/nylas-page-styling/nylas-page-styling.js.map +1 -1
- package/dist/collection/components/scheduler-editor/nylas-participants-custom-availability/nylas-participants-custom-availability.js +3 -2
- package/dist/collection/components/scheduler-editor/nylas-participants-custom-availability/nylas-participants-custom-availability.js.map +1 -1
- package/dist/components/checkbox-component2.js +12 -2
- package/dist/components/checkbox-component2.js.map +1 -1
- package/dist/components/multi-select-dropdown2.js +22 -2
- package/dist/components/multi-select-dropdown2.js.map +1 -1
- package/dist/components/nylas-additional-participants2.js +1 -1
- package/dist/components/nylas-additional-participants2.js.map +1 -1
- package/dist/components/nylas-booking-form-config2.js +35 -27
- package/dist/components/nylas-booking-form-config2.js.map +1 -1
- package/dist/components/nylas-buffer-time2.js +13 -12
- package/dist/components/nylas-buffer-time2.js.map +1 -1
- package/dist/components/nylas-connected-calendars2.js +2 -2
- package/dist/components/nylas-connected-calendars2.js.map +1 -1
- package/dist/components/nylas-date-component2.js +14 -8
- package/dist/components/nylas-date-component2.js.map +1 -1
- package/dist/components/nylas-editor-tabs2.js +2 -2
- package/dist/components/nylas-event-location2.js +35 -12
- package/dist/components/nylas-event-location2.js.map +1 -1
- package/dist/components/nylas-page-styling2.js +5 -3
- package/dist/components/nylas-page-styling2.js.map +1 -1
- package/dist/components/nylas-participants-custom-availability2.js +3 -2
- package/dist/components/nylas-participants-custom-availability2.js.map +1 -1
- package/dist/components/nylas-scheduling.js +2 -2
- package/dist/components/scheduler-store.js +1 -1
- package/dist/components/time-period-selector2.js +26 -2
- package/dist/components/time-period-selector2.js.map +1 -1
- package/dist/esm/calendar-agenda-fill-icon_53.entry.js +88 -57
- package/dist/esm/calendar-agenda-fill-icon_53.entry.js.map +1 -1
- package/dist/esm/checkbox-component.entry.js +9 -1
- package/dist/esm/checkbox-component.entry.js.map +1 -1
- package/dist/esm/checkbox-component_3.entry.js +21 -8
- package/dist/esm/checkbox-component_3.entry.js.map +1 -1
- package/dist/esm/google-logo-icon_4.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/multi-select-dropdown.entry.js +19 -1
- package/dist/esm/multi-select-dropdown.entry.js.map +1 -1
- package/dist/esm/nylas-additional-participants.entry.js +1 -1
- package/dist/esm/nylas-additional-participants.entry.js.map +1 -1
- package/dist/esm/nylas-booking-form-config.entry.js +34 -27
- package/dist/esm/nylas-booking-form-config.entry.js.map +1 -1
- package/dist/esm/nylas-buffer-time.entry.js +13 -12
- package/dist/esm/nylas-buffer-time.entry.js.map +1 -1
- package/dist/esm/nylas-connected-calendars.entry.js +2 -2
- package/dist/esm/nylas-connected-calendars.entry.js.map +1 -1
- package/dist/esm/nylas-date-component.entry.js +12 -7
- package/dist/esm/nylas-date-component.entry.js.map +1 -1
- package/dist/esm/nylas-editor-tabs.entry.js +2 -2
- package/dist/esm/nylas-event-location.entry.js +32 -11
- package/dist/esm/nylas-event-location.entry.js.map +1 -1
- package/dist/esm/nylas-page-styling.entry.js +3 -2
- package/dist/esm/nylas-page-styling.entry.js.map +1 -1
- package/dist/esm/nylas-participants-custom-availability.entry.js +3 -2
- package/dist/esm/nylas-participants-custom-availability.entry.js.map +1 -1
- package/dist/esm/nylas-provider.entry.js +1 -1
- package/dist/esm/nylas-scheduling.entry.js +3 -3
- package/dist/esm/nylas-web-elements.js +1 -1
- package/dist/esm/{scheduler-store-20151a77.js → scheduler-store-3acf4d70.js} +2 -2
- package/dist/esm/{scheduler-store-20151a77.js.map → scheduler-store-3acf4d70.js.map} +1 -1
- package/dist/esm/{scheduler-store-b6d12f40.js → scheduler-store-79dc16cc.js} +2 -2
- package/dist/esm/{scheduler-store-b6d12f40.js.map → scheduler-store-79dc16cc.js.map} +1 -1
- package/dist/esm/time-period-selector.entry.js +21 -1
- package/dist/esm/time-period-selector.entry.js.map +1 -1
- package/dist/nylas-web-elements/checkbox-component.entry.js +9 -1
- package/dist/nylas-web-elements/checkbox-component.entry.js.map +1 -1
- package/dist/nylas-web-elements/multi-select-dropdown.entry.js +19 -1
- package/dist/nylas-web-elements/multi-select-dropdown.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-additional-participants.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-additional-participants.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-booking-form-config.entry.js +34 -27
- package/dist/nylas-web-elements/nylas-booking-form-config.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-buffer-time.entry.js +13 -12
- package/dist/nylas-web-elements/nylas-buffer-time.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-connected-calendars.entry.js +2 -2
- package/dist/nylas-web-elements/nylas-connected-calendars.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-date-component.entry.js +12 -7
- package/dist/nylas-web-elements/nylas-date-component.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-editor-tabs.entry.js +2 -2
- package/dist/nylas-web-elements/nylas-event-location.entry.js +32 -11
- package/dist/nylas-web-elements/nylas-event-location.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-page-styling.entry.js +3 -2
- package/dist/nylas-web-elements/nylas-page-styling.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-participants-custom-availability.entry.js +3 -2
- package/dist/nylas-web-elements/nylas-participants-custom-availability.entry.js.map +1 -1
- package/dist/nylas-web-elements/nylas-provider.entry.js +1 -1
- package/dist/nylas-web-elements/nylas-scheduling.entry.js +3 -3
- package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
- package/dist/nylas-web-elements/p-040b8553.entry.js +2 -0
- package/dist/nylas-web-elements/p-040b8553.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-13a83f9a.entry.js +8 -0
- package/dist/nylas-web-elements/p-13a83f9a.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-1a9fc29a.entry.js +2 -0
- package/dist/nylas-web-elements/p-1a9fc29a.entry.js.map +1 -0
- package/dist/nylas-web-elements/{p-e543a827.entry.js → p-1dedce7c.entry.js} +2 -2
- package/dist/nylas-web-elements/{p-284c14bb.js → p-53f7b360.js} +2 -2
- package/dist/nylas-web-elements/p-7f100474.entry.js +2 -0
- package/dist/nylas-web-elements/p-7f100474.entry.js.map +1 -0
- package/dist/nylas-web-elements/{p-70d36207.entry.js → p-84e69241.entry.js} +2 -2
- package/dist/nylas-web-elements/{p-36c73819.entry.js → p-ad7f8831.entry.js} +2 -2
- package/dist/nylas-web-elements/{scheduler-store-b6d12f40.js → scheduler-store-79dc16cc.js} +2 -2
- package/dist/nylas-web-elements/{scheduler-store-b6d12f40.js.map → scheduler-store-79dc16cc.js.map} +1 -1
- package/dist/nylas-web-elements/time-period-selector.entry.js +21 -1
- package/dist/nylas-web-elements/time-period-selector.entry.js.map +1 -1
- package/dist/types/components/design-system/checkbox-component/checkbox-component.d.ts +1 -0
- package/dist/types/components/design-system/multi-select-dropdown/multi-select-dropdown.d.ts +2 -0
- package/dist/types/components/design-system/nylas-date-component/nylas-date-component.d.ts +1 -0
- package/dist/types/components/design-system/time-period-selector/time-period-selector.d.ts +3 -0
- package/dist/types/components/scheduler-editor/nylas-booking-form-config/nylas-booking-form-config.d.ts +2 -0
- package/dist/types/components/scheduler-editor/nylas-buffer-time/nylas-buffer-time.d.ts +2 -0
- package/dist/types/components/scheduler-editor/nylas-event-location/nylas-event-location.d.ts +3 -0
- package/dist/types/components/scheduler-editor/nylas-participants-custom-availability/nylas-participants-custom-availability.d.ts +2 -2
- package/package.json +1 -1
- package/dist/nylas-web-elements/p-2fa604d7.entry.js +0 -2
- package/dist/nylas-web-elements/p-2fa604d7.entry.js.map +0 -1
- package/dist/nylas-web-elements/p-52b9c0cb.entry.js +0 -2
- package/dist/nylas-web-elements/p-52b9c0cb.entry.js.map +0 -1
- package/dist/nylas-web-elements/p-9db69aed.entry.js +0 -2
- package/dist/nylas-web-elements/p-9db69aed.entry.js.map +0 -1
- package/dist/nylas-web-elements/p-a1a75dc7.entry.js +0 -8
- package/dist/nylas-web-elements/p-a1a75dc7.entry.js.map +0 -1
- /package/dist/nylas-web-elements/{p-e543a827.entry.js.map → p-1dedce7c.entry.js.map} +0 -0
- /package/dist/nylas-web-elements/{p-284c14bb.js.map → p-53f7b360.js.map} +0 -0
- /package/dist/nylas-web-elements/{p-70d36207.entry.js.map → p-84e69241.entry.js.map} +0 -0
- /package/dist/nylas-web-elements/{p-36c73819.entry.js.map → p-ad7f8831.entry.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"scheduler-store-b6d12f40.js","mappings":";;;IAAY;AAAZ,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,4BAAW,CAAA;IACX,8BAAa,CAAA;AACf,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAQD,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,qEAA+C,CAAA;IAC/C,yDAAmC,CAAA;IACnC,mEAA6C,CAAA;IAC7C,mEAA6C,CAAA;IAC7C,qDAA+B,CAAA;IAC/B,yCAAmB,CAAA;IACnB,+DAAyC,CAAA;IACzC,2DAAqC,CAAA;IACrC,2DAAqC,CAAA;AACvC,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AAED,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,mDAAmC,CAAA;IACnC,+C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AAI,sBAAsB,EAAE;YACxC,MAAM,KAAK,GAAG,sBAAsB,CAAC,GAA0C,CAAC,CAAC;YACjF,KAAK,CAAC,GAAG,CAAC,GAAU,EAAE,KAAK,CAAC,CAAC;SAC9B;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf;;;;","names":["i18next"],"sources":["src/connector/nylas-scheduler-connector/errors/index.ts","src/connector/shared/api/scheduler.ts","src/stores/scheduler-store.ts"],"sourcesContent":["export enum ErrorCategory {\n Component = 'component',\n Api = 'api',\n Auth = 'auth',\n}\n\nexport interface ErrorDetails {\n title: string;\n message: string;\n category: ErrorCategory;\n}\n\nexport enum ComponentErrorType {\n endtime_not_in_future = 'endtime_not_in_future',\n no_booking_info = 'no_booking_info',\n no_timeslot_selected = 'no_timeslot_selected',\n no_timezone_selected = 'no_timezone_selected',\n no_booking_id = 'no_booking_id',\n no_salt = 'no_salt',\n invalid_start_time = 'invalid_start_time',\n invalid_end_time = 'invalid_end_time',\n invalid_timezone = 'invalid_timezone',\n}\n\nexport enum APIErrorType {\n invalid_session = 'invalid_session',\n general_error = 'general_error',\n internal_error = 'internal_error',\n invalid_request_error = 'invalid_request_error',\n timeslot_not_available = 'timeslot_not_available',\n provider_error = 'provider_error',\n not_found_error = 'not_found_error',\n}\n\nexport class Errors {\n component = (_title: string): Record<ComponentErrorType, (message?: string) => ErrorDetails> => {\n const category = ErrorCategory.Component;\n const title = `${_title} Error`;\n return {\n endtime_not_in_future: (message: string = '\"endtime\" can not be in the future') => {\n return {\n title,\n message,\n category,\n };\n },\n no_booking_info: (message: string = 'No booking info provided') => {\n return {\n title,\n message,\n category,\n };\n },\n no_timeslot_selected: (message: string = 'No timeslot selected') => {\n return {\n title,\n message,\n category,\n };\n },\n no_timezone_selected: (message: string = 'No timezone selected') => {\n return {\n title,\n message,\n category,\n };\n },\n no_booking_id: (message: string = 'No booking id provided') => {\n return {\n title,\n message,\n category,\n };\n },\n no_salt: (message: string = 'No salt provided') => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_start_time: (message: string = 'Invalid start time') => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_end_time: (message: string = 'Invalid end time') => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_timezone: (message: string = 'Invalid timezone') => {\n return {\n title,\n message,\n category,\n };\n },\n };\n };\n\n api = (_title: string): Record<APIErrorType, (message: string) => ErrorDetails> => {\n const category = ErrorCategory.Api;\n const title = `${_title} Error`;\n\n return {\n invalid_session: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n general_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n internal_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_request_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n timeslot_not_available: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n provider_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n not_found_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n };\n };\n}\n","import { AvailabilityResponse, NylasSchedulerBookingDataWithFlatFields, NylasEvent, UISettingsResponse } from '@/common/types';\nimport { NylasSchedulerStoreType } from '../../../components';\nimport type { NylasErrorResponse, NylasResponse, NylasSchedulerBookingData, NylasSchedulerResponse, Timeslot } from '@nylas/core';\nimport { APIErrorType, Errors } from '@/connector/nylas-scheduler-connector/errors';\nimport { addDaysToCurrentDate } from '@/utils/utils';\nimport i18next from '@/utils/i18n';\n\ntype NylasSchedulerAPIConnectorOptions = {\n schedulerAPIURL: string;\n schedulerStore: NylasSchedulerStoreType;\n sessionId?: string;\n configId?: string;\n slug?: string;\n clientId?: string;\n};\n\n/**\n * NylaSchedulerConnector\n * This class is used to make API requests to the scheduler.\n */\nexport class NylaSchedulerAPIConnector {\n private schedulerStore: NylasSchedulerStoreType;\n private schedulerAPIURL: string;\n private sessionId: string | undefined;\n private configId: string | undefined;\n private slug: string | undefined;\n private clientId: string | undefined;\n private errors = new Errors();\n\n constructor({ schedulerAPIURL, schedulerStore, sessionId, configId, slug, clientId }: NylasSchedulerAPIConnectorOptions) {\n this.schedulerStore = schedulerStore;\n this.schedulerAPIURL = schedulerAPIURL;\n this.sessionId = sessionId;\n this.configId = configId;\n this.slug = slug;\n this.clientId = clientId;\n }\n\n private getHeaders() {\n return this.sessionId\n ? {\n Authorization: `Bearer ${this.sessionId}`,\n }\n : {};\n }\n\n /**\n * Makes an API request to the scheduler.\n * @param path The path to the API endpoint.\n * @param method The HTTP method.\n * @param body The request body (if any).\n * @returns {Promise<T>}\n */\n public async makeAPIRequest<T>(path: string, method: string, body: string | undefined, headers = {}): Promise<NylasResponse<T>> {\n try {\n const schedulerURL = new URL(this.schedulerAPIURL);\n const version = process.env.PACKAGE_VERSION || 'latest';\n schedulerURL.pathname = path;\n const response = await fetch(decodeURIComponent(schedulerURL.toString()), {\n method,\n headers: {\n 'Content-Type': 'application/json',\n 'Origin': window.location.origin,\n 'X-Source': 'nylas-scheduling',\n 'X-Nylas-Web-Elements-Version': version,\n ...headers,\n },\n body,\n });\n // The server returns a json object for errors: eg.\n // {\n // \"request_id\": \"<request_id>\",\n // \"error\": {\n // \"type\": \"not_found_error\",\n // \"message\": \"Session not found\"\n // }\n // }\n const data = await response.json();\n return data as NylasResponse<T>;\n } catch (error: any) {\n // NOTE: current server implementation doesn't return a JSON object for errors on some endpoints\n // handle this case by returning the error response as a string to be handled downstream\n return {\n error: {\n message: error.message,\n title: 'API request failed',\n type: 'api',\n },\n } as NylasErrorResponse;\n }\n }\n\n private getErrorMessage(error: NylasErrorResponse['error']) {\n let errorMessage = error?.message || error?.title || 'Something went wrong';\n if (error?.type === 'provider_error') {\n errorMessage = error?.provider_error?.error?.message || error?.provider_error?.error?.title || 'Something went wrong';\n }\n return errorMessage;\n }\n\n public setConfigId(configId: string) {\n this.configId = configId;\n }\n\n /**\n * Selects a date in the scheduler.\n */\n public selectDate(date: Date) {\n this.schedulerStore.set('selectedDate', date);\n this.schedulerStore.set('selectedTimeslot', null);\n }\n\n /**\n * Selects a time in the scheduler.\n */\n public selectTime(time: Timeslot) {\n this.schedulerStore.set('selectedTimeslot', time);\n }\n\n /**\n * Sets the timezone in the scheduler.\n */\n public selectTimezone(timezone: string) {\n this.schedulerStore.set('selectedTimezone', timezone);\n }\n\n /**\n * Sets the language in the scheduler.\n */\n public selectLanguage(language: string) {\n this.schedulerStore.set('selectedLanguage', language);\n i18next.changeLanguage(language);\n }\n\n /**\n * Toggles showBookingForm\n * @param value boolean\n */\n public async toggleAdditionalData(value: boolean) {\n if (!value) {\n // Refetch availability\n await this.refetchAvailability();\n }\n this.schedulerStore.set('showBookingForm', value);\n }\n\n /**\n * Set/update the name of the participant booking the event.\n */\n public setParticipantName(name: string) {\n const { bookingInfo } = this.schedulerStore.state;\n this.schedulerStore.set('bookingInfo', {\n ...bookingInfo,\n primaryParticipant: {\n ...(bookingInfo?.primaryParticipant as NylasSchedulerBookingData['primaryParticipant']),\n name,\n },\n });\n }\n\n /**\n * Set/update the email of the participant booking the event.\n */\n public setParticipantEmail(email: string) {\n const { bookingInfo } = this.schedulerStore.state;\n this.schedulerStore.set('bookingInfo', {\n ...bookingInfo,\n primaryParticipant: {\n ...(bookingInfo?.primaryParticipant as NylasSchedulerBookingData['primaryParticipant']),\n email,\n },\n });\n }\n\n private async refetchAvailability() {\n const today = new Date();\n // Refetch availability\n const startTime = new Date(today.getFullYear(), today.getMonth(), 1).getTime() / 1000;\n const startTimeWithOffset = startTime < today.getTime() / 1000 ? Math.floor(today.getTime() / 1000) : startTime;\n const endTime = new Date(today.getFullYear(), today.getMonth() + 1, 1).getTime() / 1000;\n const result = await this.getAvailability(startTimeWithOffset, endTime);\n return result;\n }\n\n private async resetStoreStateAndFetchAvailability() {\n const today = new Date();\n // Refetch availability\n const result = await this.refetchAvailability();\n // Set selected date to first available date\n const firstAvailableDate = this.schedulerStore.get('availability').find((timeslot: any) => new Date(timeslot.start_time) > new Date());\n let _selectedDate = today;\n if (firstAvailableDate) {\n _selectedDate = firstAvailableDate.start_time;\n }\n this.schedulerStore.set('selectedDate', _selectedDate);\n // Reset store state\n this.schedulerStore.set('eventInfo', null);\n this.schedulerStore.set('showBookingForm', false);\n this.schedulerStore.set('selectedTimeslot', null);\n\n return result;\n }\n\n /**\n * Set reschedule booking id\n */\n public async setReschedule(bookingID: string) {\n this.schedulerStore.set('isLoading', true);\n const eventInfo = this.schedulerStore.state.eventInfo;\n if (eventInfo) {\n this.schedulerStore.set('reschedulingEventInfo', eventInfo);\n }\n this.schedulerStore.set('rescheduleBookingId', bookingID);\n await this.getUISettings();\n // Set reschedule booking id\n const result = await this.resetStoreStateAndFetchAvailability().finally(() => {\n this.schedulerStore.set('isLoading', false);\n });\n\n return result;\n }\n\n /**\n * Set cancel booking id\n */\n public async setCancel(bookingID: string) {\n this.schedulerStore.set('cancelBookingId', bookingID);\n }\n\n /**\n * Set reject booking id\n */\n public async setReject(bookingID: string) {\n this.schedulerStore.set('rejectBookingId', bookingID);\n }\n\n public async resetCancel() {\n const result = await this.resetStoreStateAndFetchAvailability();\n this.schedulerStore.set('cancelBookingId', '');\n this.schedulerStore.set('rejectBookingId', '');\n this.schedulerStore.set('cancelledEventInfo', null);\n return result;\n }\n\n public async goBack() {\n this.schedulerStore.set('cancelBookingId', '');\n return;\n }\n\n public async resetConfirm() {\n const result = await this.resetStoreStateAndFetchAvailability();\n this.schedulerStore.set('organizerConfirmationBookingId', '');\n this.schedulerStore.set('confirmedEventInfo', undefined);\n return result;\n }\n\n /**\n * Book the selected timeslot.\n * @param data The booking info.\n * @returns {Promise<NylasResponse<NylasEvent>>}\n */\n public async bookTimeslot(data?: NylasSchedulerBookingDataWithFlatFields & { timeslot?: Timeslot }): Promise<NylasSchedulerResponse<NylasEvent>> {\n this.schedulerStore.set('isLoading', true);\n const { selectedTimeslot, selectedTimezone, bookingInfo, selectedLanguage } = this.schedulerStore.state;\n if (!data && !bookingInfo) {\n return { error: this.errors.component(i18next.t('createBookingErrorTitle')).no_booking_info() };\n }\n\n const timeslot = data?.timeslot || selectedTimeslot;\n if (!timeslot) {\n return { error: this.errors.component(i18next.t('createBookingErrorTitle')).no_timeslot_selected() };\n }\n\n const timezone = data && data?.timezone ? data?.timezone : selectedTimezone;\n const language = selectedLanguage || 'en-US';\n\n if (!timezone) {\n return { error: this.errors.component(i18next.t('createBookingErrorTitle')).no_timezone_selected() };\n }\n const order = this.schedulerStore.get('availabilityOrderEmails');\n let participantToBookWith = '';\n if (order.length > 0) {\n // Get the emails in the timeslot\n const emails = timeslot?.emails || [];\n for (let i = 0; i < order.length; i++) {\n if (emails.includes(order[i])) {\n participantToBookWith = order[i];\n break;\n }\n }\n }\n const addFields = {};\n Object.entries(bookingInfo?.additionalFields || {}).forEach(([key, entry]) => {\n addFields[key] = (entry as { value: string; type?: string }).value;\n });\n const primaryGuest = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;\n const guests = data ? data?.guests || [] : bookingInfo?.guests || [];\n const additional_fields = data ? data?.additionalFields : addFields;\n\n const headers = this.getHeaders();\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings${configIdParam}`;\n\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'POST',\n JSON.stringify({\n participants: participantToBookWith ? [{ email: participantToBookWith }] : undefined,\n additional_fields,\n additional_guests: guests,\n guest: { ...primaryGuest },\n start_time: timeslot.start_time.getTime() / 1000,\n end_time: timeslot.end_time.getTime() / 1000,\n timezone: timezone,\n email_language: this.getTwoLetterLanguageCode(language),\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api('Create Booking')) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api('Create Booking')[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n if ('data' in response) {\n this.schedulerStore.set('eventInfo', response?.data);\n }\n\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Get UI settings for the scheduler.\n */\n public async getUISettings(): Promise<NylasSchedulerResponse<UISettingsResponse>> {\n this.schedulerStore.set('isLoading', true);\n const bookingId = this.schedulerStore.get('rescheduleBookingId');\n const headers = this.getHeaders();\n let configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n if (bookingId && !!configIdParam) {\n configIdParam += `&booking_id=${bookingId}`;\n } else if (bookingId) {\n configIdParam += `?booking_id=${bookingId}`;\n }\n\n const url = `/v3/scheduling/ui-settings${configIdParam}`;\n\n const response = await this.makeAPIRequest<UISettingsResponse>(url, 'GET', undefined, headers);\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(i18next.t('getUISettingErrorTitle'))) {\n error = this.errors.api(i18next.t('getUISettingErrorTitle'))[errorType as APIErrorType](error?.message || error?.title || 'Something went wrong');\n }\n return { error };\n }\n if ('data' in response) {\n this.schedulerStore.set('configSettings', response.data);\n }\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n private getTwoLetterLanguageCode(language: string) {\n return language.split('-')[0];\n }\n\n private getStartTimeWithMinBookingNotice(startTime: number) {\n const scheduler = this.schedulerStore.get('configSettings')?.scheduler;\n const min_booking_notice = scheduler?.min_booking_notice;\n if (!min_booking_notice) {\n return startTime;\n }\n const today = new Date().getTime();\n\n if (startTime < (today + min_booking_notice * 60 * 1000) / 1000) {\n return Math.floor((today + min_booking_notice * 60 * 1000) / 1000);\n } else {\n return startTime;\n }\n }\n\n private getEndTimeForAvailableDaysInFuture(endTime: number) {\n const today = new Date();\n const availableDaysInFuture = this.schedulerStore.get('configSettings')?.scheduler?.available_days_in_future;\n const endTimeForAvailableDaysInFuture = Math.floor(addDaysToCurrentDate(today, availableDaysInFuture).getTime() / 1000);\n const endTimeWithOffset = Math.min(endTimeForAvailableDaysInFuture, endTime);\n return endTimeWithOffset;\n }\n\n /**\n * Gets the availability for a page.\n * @param startTime The start time.\n * @param endTime The end time.\n * @returns {Promise<AvailabilityResponse>}\n */\n public async getAvailability(startTime: number = 0, endTime: number = 0): Promise<NylasSchedulerResponse<AvailabilityResponse>> {\n this.schedulerStore.set('isLoading', true);\n const params = new URLSearchParams();\n const now = new Date();\n const nowTime = now.getTime();\n\n if (endTime && endTime < nowTime / 1000) {\n this.schedulerStore.set('isLoading', false);\n const error = this.errors.component(i18next.t('getAvailabilityErrorTitle')).endtime_not_in_future();\n return { error };\n }\n\n // Calculate the start of the current month if startTime is not provided\n if (!startTime) {\n const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);\n startTime = Math.floor(startOfMonth.getTime() / 1000); // Convert to UNIX timestamp in seconds\n }\n\n // Calculate the end of the current month if endTime is not provided\n if (!endTime) {\n const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0); // Setting day to 0 gets the last day of the previous month, so in this case, the last day of the current month\n endTime = Math.floor(endOfMonth.getTime() / 1000); // Convert to UNIX timestamp in seconds\n }\n\n endTime = this.getEndTimeForAvailableDaysInFuture(endTime);\n const startTimeWithMinBooking = this.getStartTimeWithMinBookingNotice(startTime);\n startTime = startTimeWithMinBooking;\n endTime = startTimeWithMinBooking > endTime ? startTimeWithMinBooking + 1 : endTime;\n\n params.append('start_time', encodeURIComponent(startTime.toString()));\n params.append('end_time', encodeURIComponent(endTime.toString()));\n if (this.configId && !this.sessionId) {\n params.append('configuration_id', encodeURIComponent(this.configId));\n } else if (this.slug && this.clientId && !this.sessionId) {\n params.append('slug', encodeURIComponent(this.slug));\n params.append('client_id', encodeURIComponent(this.clientId));\n }\n\n const rescheduleBookingId = this.schedulerStore.get('rescheduleBookingId');\n if (rescheduleBookingId) {\n params.append('booking_id', encodeURIComponent(rescheduleBookingId));\n }\n const queryString = params.toString();\n const url = `/v3/scheduling/availability${queryString ? `?${queryString}` : ''}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<AvailabilityResponse>(decodeURIComponent(url), 'GET', undefined, headers);\n\n if ('error' in response) {\n this.schedulerStore.set('availability', []);\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(i18next.t('getAvailabilityErrorTitle'))) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api(i18next.t('getAvailabilityErrorTitle'))[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n if ('data' in response) {\n const availability =\n response.data?.time_slots?.map(timeslot => {\n return {\n ...timeslot,\n start_time: new Date(timeslot.start_time * 1000),\n end_time: new Date(timeslot.end_time * 1000),\n };\n }) || [];\n\n // Filter out timeslots that are in the past\n const availabilityTimeslotsFiltered = availability.filter(timeslot => timeslot.start_time.getTime() > nowTime);\n this.schedulerStore.set('availability', availabilityTimeslotsFiltered);\n const order = response.data?.order || [];\n this.schedulerStore.set('availabilityOrderEmails', order);\n }\n\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Cancels a booking.\n * @param bookingId The booking ID.\n */\n public async cancelBooking(bookingId: string, reason: string): Promise<NylasSchedulerResponse<Partial<NylasEvent>>> {\n this.schedulerStore.set('isLoading', true);\n if (!bookingId) {\n return { error: this.errors.component(i18next.t('cancelBookingErrorTitle')).no_booking_id() };\n }\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings/${bookingId}${configIdParam}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<Partial<NylasEvent>>(\n decodeURIComponent(url),\n 'DELETE',\n JSON.stringify({\n action: 'cancel',\n cancellation_reason: reason,\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(i18next.t('cancelBookingErrorTitle'))) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api(i18next.t('cancelBookingErrorTitle'))[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n this.schedulerStore.set('cancelledEventInfo', {\n booking_id: bookingId,\n });\n this.schedulerStore.set('rescheduleBookingId', '');\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Reschedules a booking.\n * @param bookingId The booking ID.\n * @param data The booking info.\n * @returns {Promise<NylasResponse<NylasEvent>>}\n */\n public async rescheduleBooking(bookingId: string, data: NylasSchedulerBookingDataWithFlatFields): Promise<NylasSchedulerResponse<NylasEvent>> {\n this.schedulerStore.set('isLoading', true);\n if (!bookingId) {\n return { error: this.errors.component(i18next.t('rescheduleBookingErrorTitle')).no_booking_id() };\n }\n const apiErrors = this.errors.api(i18next.t('rescheduleBookingErrorTitle'));\n const componentErrors = this.errors.component(i18next.t('rescheduleBookingErrorTitle'));\n const { bookingInfo, selectedTimeslot, selectedTimezone, selectedLanguage } = this.schedulerStore.state;\n // Validate data\n const { startTime, endTime, timezone } = data;\n const start_time = startTime || selectedTimeslot?.start_time;\n\n if (!start_time) {\n return { error: componentErrors.invalid_start_time('Please pass \"startTime\" in data or set \"selectedTimeslot\" in the defaultSchedulerState.') };\n }\n const end_time = endTime || selectedTimeslot?.end_time;\n if (!end_time) {\n return { error: componentErrors.invalid_end_time('Please pass \"endTime\" in data or set \"selectedTimeslot\" in the defaultSchedulerState.') };\n }\n\n const order = this.schedulerStore.get('availabilityOrderEmails');\n let participantToBookWith = '';\n if (order.length > 0) {\n // Get the emails in the timeslot\n const emails = selectedTimeslot?.emails || [];\n for (let i = 0; i < order.length; i++) {\n if (emails.includes(order[i])) {\n participantToBookWith = order[i];\n break;\n }\n }\n }\n\n const time_zone = timezone || selectedTimezone;\n if (!time_zone) {\n return { error: componentErrors.invalid_timezone('Please pass \"timezone\" in data or set \"selectedTimezone\" in the defaultSchedulerState.') };\n }\n const addFields = {};\n Object.entries(bookingInfo?.additionalFields || {}).forEach(([key, entry]) => {\n addFields[key] = (entry as { value: string; type?: string }).value;\n });\n const primaryGuest = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;\n const guests = data ? data?.guests || [] : bookingInfo?.guests || [];\n const additional_fields = data ? data?.additionalFields : addFields;\n\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings/${bookingId}${configIdParam}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'PATCH',\n JSON.stringify({\n start_time: start_time.getTime() / 1000,\n end_time: end_time.getTime() / 1000,\n timezone: time_zone,\n additional_fields,\n guest: { ...primaryGuest },\n additional_guests: guests,\n participants: participantToBookWith ? [{ email: participantToBookWith }] : undefined,\n email_language: this.getTwoLetterLanguageCode(selectedLanguage),\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in apiErrors) {\n const errorMessage = this.getErrorMessage(error);\n error = apiErrors[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n const eventInfo = this.schedulerStore.get('reschedulingEventInfo');\n if ('data' in response) {\n this.schedulerStore.set('eventInfo', response?.data);\n } else if (eventInfo) {\n this.schedulerStore.set('eventInfo', eventInfo);\n } else {\n // We should technically never reach this point\n const event = {\n booking_id: bookingId,\n } as NylasEvent;\n this.schedulerStore.set('eventInfo', event);\n }\n\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Updates the booking.\n * @param bookingId The booking ID.\n */\n public async updateBooking(payload: { bookingId: string; status: 'confirmed' | 'cancelled'; reason?: string }): Promise<NylasSchedulerResponse<NylasEvent>> {\n this.schedulerStore.set('isLoading', true);\n const { bookingId, status, reason } = payload;\n const salt = this.schedulerStore.get('organizerConfirmationSalt');\n const errorTitle = status === 'confirmed' ? i18next.t('confirmBookingErrorTitle') : i18next.t('rejectBookingErrorTitle');\n\n if (!bookingId) {\n return { error: this.errors.component(errorTitle).no_booking_id() };\n }\n if (!salt) {\n return { error: this.errors.component(errorTitle).no_salt() };\n }\n\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings/${bookingId}${configIdParam}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'PUT',\n JSON.stringify({\n status: status,\n cancellation_reason: reason,\n salt,\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(errorTitle)) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api(errorTitle)[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n if ('data' in response && status === 'confirmed') {\n this.schedulerStore.set('confirmedEventInfo', response?.data);\n } else if ('request_id' in response && status === 'cancelled') {\n this.schedulerStore.set('cancelledEventInfo', {\n booking_id: bookingId,\n });\n }\n\n this.schedulerStore.set('organizerConfirmationBookingId', '');\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n}\n","import { DataState, NylasEvent } from '@/common/types';\nimport { debug } from '@/utils/utils';\nimport { AdditionalFields, Appearance, NylasSchedulerBookingData, ThemeConfig, Timeslot } from '@nylas/core';\nimport { createStore } from '@stencil/store';\n\nexport type AvailabilityTimeslot = {\n emails: string[];\n start_time: Date;\n end_time: Date;\n};\n\nexport type LoadingState = {\n api: 'availability' | 'createBooking' | 'cancelBooking' | 'rescheduleBooking';\n};\n\nexport type ConfigSettings = {\n configuration_id: string;\n booking?: {\n additional_fields: Record<string, string>;\n additional_guests: {\n email: string;\n name: string;\n }[];\n booking_ref: string;\n booking_ref_salt: string;\n guest: {\n email: string;\n name: string;\n };\n timezone: string;\n email_language: string;\n event_data: {\n location: string;\n when: {\n start_time: Date;\n end_time: Date;\n end_timezone: string;\n start_timezone: string;\n object: string;\n };\n };\n event_organizer: {\n name: string;\n email: string;\n is_organizer: boolean;\n };\n };\n scheduler: {\n available_days_in_future: number;\n min_cancellation_notice: number;\n min_booking_notice: number;\n rescheduling_url?: string;\n cancellation_url?: string;\n cancellation_policy?: string;\n hide_additional_guests?: boolean;\n hide_cancellation_options?: boolean;\n hide_rescheduling_options?: boolean;\n additional_fields?: Record<string, AdditionalFields>;\n confirmation_redirect_url?: string;\n organizer_confirmation_url?: string;\n };\n organizer: {\n name: string;\n email: string;\n };\n slug: string;\n appearance: Appearance;\n booking_type: string;\n name: string;\n};\n\nexport interface NylasSchedulerStoreState {\n selectedDate: Date | null;\n selectedLanguage: string;\n selectedTimezone: string;\n selectedTimeslot: Timeslot | null;\n availabilityOrderEmails: string[];\n showBookingForm: boolean;\n selectableDates: Date[] | null;\n eventDuration: number;\n availability: AvailabilityTimeslot[];\n state: DataState;\n eventInfo: NylasEvent | null;\n cancelledEventInfo: Partial<NylasEvent> | null;\n reschedulingEventInfo?: NylasEvent;\n confirmedEventInfo?: NylasEvent;\n bookingInfo?: NylasSchedulerBookingData;\n rescheduleBookingId?: string;\n cancelBookingId?: string;\n isLoading: boolean;\n nylasBranding?: boolean;\n configSettings?: ConfigSettings;\n organizerConfirmationBookingId?: string;\n rejectBookingId?: string;\n organizerConfirmationSalt?: string;\n themeConfig?: ThemeConfig;\n}\n\nexport type NylasSchedulerStoreType = ReturnType<typeof CreateNylasSchedulerStore>;\n\nexport function CreateNylasSchedulerStore(defaultState: Partial<NylasSchedulerStoreState> = {}) {\n const defaultNylasStoreState: NylasSchedulerStoreState = {\n selectedDate: null,\n selectedLanguage: navigator.language,\n selectedTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n selectedTimeslot: null,\n showBookingForm: false,\n availabilityOrderEmails: [],\n selectableDates: null,\n availability: [],\n eventDuration: 0,\n state: 'ready',\n eventInfo: null,\n cancelledEventInfo: null,\n isLoading: false,\n nylasBranding: true,\n ...defaultState,\n };\n debug(`[defaultNylasStoreState]: `, defaultNylasStoreState);\n const store = createStore<NylasSchedulerStoreState>(defaultNylasStoreState);\n\n store.onChange('availability', availability => {\n debug(`[availability]: `, availability);\n const selectableDates = availability.map(timeslot => timeslot.start_time);\n debug(`[selectableDates]: `, selectableDates);\n store.set('selectableDates', selectableDates);\n const timeslot = availability[0];\n if (!timeslot) return;\n const durationMinutes = Math.floor((timeslot.end_time.getTime() - timeslot.start_time.getTime()) / 60000);\n debug(`[durationMinutes]: `, durationMinutes);\n store.set('eventDuration', durationMinutes);\n });\n\n /**\n * Reset the Nylas store to its default state.\n * There is something wrong with the stencil/store reset method,\n * so we have to do it via this hack.\n */\n store.reset = () => {\n for (const key in defaultNylasStoreState) {\n const value = defaultNylasStoreState[key as keyof typeof defaultNylasStoreState];\n store.set(key as any, value);\n }\n };\n\n return store;\n}\n"],"version":3}
|
|
1
|
+
{"file":"scheduler-store-79dc16cc.js","mappings":";;;IAAY;AAAZ,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,4BAAW,CAAA;IACX,8BAAa,CAAA;AACf,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAQD,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,qEAA+C,CAAA;IAC/C,yDAAmC,CAAA;IACnC,mEAA6C,CAAA;IAC7C,mEAA6C,CAAA;IAC7C,qDAA+B,CAAA;IAC/B,yCAAmB,CAAA;IACnB,+DAAyC,CAAA;IACzC,2DAAqC,CAAA;IACrC,2DAAqC,CAAA;AACvC,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AAED,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,mDAAmC,CAAA;IACnC,+CAA+B,CAAA;IAC/B,iD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xC,MAAM,KAAK,GAAG,sBAAsB,CAAC,GAA0C,CAAC,CAAC;YACjF,KAAK,CAAC,GAAG,CAAC,GAAU,EAAE,KAAK,CAAC,CAAC;SAC9B;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf;;;;","names":["i18next"],"sources":["src/connector/nylas-scheduler-connector/errors/index.ts","src/connector/shared/api/scheduler.ts","src/stores/scheduler-store.ts"],"sourcesContent":["export enum ErrorCategory {\n Component = 'component',\n Api = 'api',\n Auth = 'auth',\n}\n\nexport interface ErrorDetails {\n title: string;\n message: string;\n category: ErrorCategory;\n}\n\nexport enum ComponentErrorType {\n endtime_not_in_future = 'endtime_not_in_future',\n no_booking_info = 'no_booking_info',\n no_timeslot_selected = 'no_timeslot_selected',\n no_timezone_selected = 'no_timezone_selected',\n no_booking_id = 'no_booking_id',\n no_salt = 'no_salt',\n invalid_start_time = 'invalid_start_time',\n invalid_end_time = 'invalid_end_time',\n invalid_timezone = 'invalid_timezone',\n}\n\nexport enum APIErrorType {\n invalid_session = 'invalid_session',\n general_error = 'general_error',\n internal_error = 'internal_error',\n invalid_request_error = 'invalid_request_error',\n timeslot_not_available = 'timeslot_not_available',\n provider_error = 'provider_error',\n not_found_error = 'not_found_error',\n}\n\nexport class Errors {\n component = (_title: string): Record<ComponentErrorType, (message?: string) => ErrorDetails> => {\n const category = ErrorCategory.Component;\n const title = `${_title} Error`;\n return {\n endtime_not_in_future: (message: string = '\"endtime\" can not be in the future') => {\n return {\n title,\n message,\n category,\n };\n },\n no_booking_info: (message: string = 'No booking info provided') => {\n return {\n title,\n message,\n category,\n };\n },\n no_timeslot_selected: (message: string = 'No timeslot selected') => {\n return {\n title,\n message,\n category,\n };\n },\n no_timezone_selected: (message: string = 'No timezone selected') => {\n return {\n title,\n message,\n category,\n };\n },\n no_booking_id: (message: string = 'No booking id provided') => {\n return {\n title,\n message,\n category,\n };\n },\n no_salt: (message: string = 'No salt provided') => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_start_time: (message: string = 'Invalid start time') => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_end_time: (message: string = 'Invalid end time') => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_timezone: (message: string = 'Invalid timezone') => {\n return {\n title,\n message,\n category,\n };\n },\n };\n };\n\n api = (_title: string): Record<APIErrorType, (message: string) => ErrorDetails> => {\n const category = ErrorCategory.Api;\n const title = `${_title} Error`;\n\n return {\n invalid_session: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n general_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n internal_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n invalid_request_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n timeslot_not_available: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n provider_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n not_found_error: (message: string) => {\n return {\n title,\n message,\n category,\n };\n },\n };\n };\n}\n","import { AvailabilityResponse, NylasSchedulerBookingDataWithFlatFields, NylasEvent, UISettingsResponse } from '@/common/types';\nimport { NylasSchedulerStoreType } from '../../../components';\nimport type { NylasErrorResponse, NylasResponse, NylasSchedulerBookingData, NylasSchedulerResponse, Timeslot } from '@nylas/core';\nimport { APIErrorType, Errors } from '@/connector/nylas-scheduler-connector/errors';\nimport { addDaysToCurrentDate } from '@/utils/utils';\nimport i18next from '@/utils/i18n';\n\ntype NylasSchedulerAPIConnectorOptions = {\n schedulerAPIURL: string;\n schedulerStore: NylasSchedulerStoreType;\n sessionId?: string;\n configId?: string;\n slug?: string;\n clientId?: string;\n};\n\n/**\n * NylaSchedulerConnector\n * This class is used to make API requests to the scheduler.\n */\nexport class NylaSchedulerAPIConnector {\n private schedulerStore: NylasSchedulerStoreType;\n private schedulerAPIURL: string;\n private sessionId: string | undefined;\n private configId: string | undefined;\n private slug: string | undefined;\n private clientId: string | undefined;\n private errors = new Errors();\n\n constructor({ schedulerAPIURL, schedulerStore, sessionId, configId, slug, clientId }: NylasSchedulerAPIConnectorOptions) {\n this.schedulerStore = schedulerStore;\n this.schedulerAPIURL = schedulerAPIURL;\n this.sessionId = sessionId;\n this.configId = configId;\n this.slug = slug;\n this.clientId = clientId;\n }\n\n private getHeaders() {\n return this.sessionId\n ? {\n Authorization: `Bearer ${this.sessionId}`,\n }\n : {};\n }\n\n /**\n * Makes an API request to the scheduler.\n * @param path The path to the API endpoint.\n * @param method The HTTP method.\n * @param body The request body (if any).\n * @returns {Promise<T>}\n */\n public async makeAPIRequest<T>(path: string, method: string, body: string | undefined, headers = {}): Promise<NylasResponse<T>> {\n try {\n const schedulerURL = new URL(this.schedulerAPIURL);\n const version = process.env.PACKAGE_VERSION || 'latest';\n schedulerURL.pathname = path;\n const response = await fetch(decodeURIComponent(schedulerURL.toString()), {\n method,\n headers: {\n 'Content-Type': 'application/json',\n 'Origin': window.location.origin,\n 'X-Source': 'nylas-scheduling',\n 'X-Nylas-Web-Elements-Version': version,\n ...headers,\n },\n body,\n });\n // The server returns a json object for errors: eg.\n // {\n // \"request_id\": \"<request_id>\",\n // \"error\": {\n // \"type\": \"not_found_error\",\n // \"message\": \"Session not found\"\n // }\n // }\n const data = await response.json();\n return data as NylasResponse<T>;\n } catch (error: any) {\n // NOTE: current server implementation doesn't return a JSON object for errors on some endpoints\n // handle this case by returning the error response as a string to be handled downstream\n return {\n error: {\n message: error.message,\n title: 'API request failed',\n type: 'api',\n },\n } as NylasErrorResponse;\n }\n }\n\n private getErrorMessage(error: NylasErrorResponse['error']) {\n let errorMessage = error?.message || error?.title || 'Something went wrong';\n if (error?.type === 'provider_error') {\n errorMessage = error?.provider_error?.error?.message || error?.provider_error?.error?.title || 'Something went wrong';\n }\n return errorMessage;\n }\n\n public setConfigId(configId: string) {\n this.configId = configId;\n }\n\n /**\n * Selects a date in the scheduler.\n */\n public selectDate(date: Date) {\n this.schedulerStore.set('selectedDate', date);\n this.schedulerStore.set('selectedTimeslot', null);\n }\n\n /**\n * Selects a time in the scheduler.\n */\n public selectTime(time: Timeslot) {\n this.schedulerStore.set('selectedTimeslot', time);\n }\n\n /**\n * Sets the timezone in the scheduler.\n */\n public selectTimezone(timezone: string) {\n this.schedulerStore.set('selectedTimezone', timezone);\n }\n\n /**\n * Sets the language in the scheduler.\n */\n public selectLanguage(language: string) {\n this.schedulerStore.set('selectedLanguage', language);\n i18next.changeLanguage(language);\n }\n\n /**\n * Toggles showBookingForm\n * @param value boolean\n */\n public async toggleAdditionalData(value: boolean) {\n if (!value) {\n // Refetch availability\n await this.refetchAvailability();\n }\n this.schedulerStore.set('showBookingForm', value);\n }\n\n /**\n * Set/update the name of the participant booking the event.\n */\n public setParticipantName(name: string) {\n const { bookingInfo } = this.schedulerStore.state;\n this.schedulerStore.set('bookingInfo', {\n ...bookingInfo,\n primaryParticipant: {\n ...(bookingInfo?.primaryParticipant as NylasSchedulerBookingData['primaryParticipant']),\n name,\n },\n });\n }\n\n /**\n * Set/update the email of the participant booking the event.\n */\n public setParticipantEmail(email: string) {\n const { bookingInfo } = this.schedulerStore.state;\n this.schedulerStore.set('bookingInfo', {\n ...bookingInfo,\n primaryParticipant: {\n ...(bookingInfo?.primaryParticipant as NylasSchedulerBookingData['primaryParticipant']),\n email,\n },\n });\n }\n\n private async refetchAvailability() {\n const today = new Date();\n // Refetch availability\n const startTime = new Date(today.getFullYear(), today.getMonth(), 1).getTime() / 1000;\n const startTimeWithOffset = startTime < today.getTime() / 1000 ? Math.floor(today.getTime() / 1000) : startTime;\n const endTime = new Date(today.getFullYear(), today.getMonth() + 1, 1).getTime() / 1000;\n const result = await this.getAvailability(startTimeWithOffset, endTime);\n return result;\n }\n\n private async resetStoreStateAndFetchAvailability() {\n const today = new Date();\n // Refetch availability\n const result = await this.refetchAvailability();\n // Set selected date to first available date\n const firstAvailableDate = this.schedulerStore.get('availability').find((timeslot: any) => new Date(timeslot.start_time) > new Date());\n let _selectedDate = today;\n if (firstAvailableDate) {\n _selectedDate = firstAvailableDate.start_time;\n }\n this.schedulerStore.set('selectedDate', _selectedDate);\n // Reset store state\n this.schedulerStore.set('eventInfo', null);\n this.schedulerStore.set('showBookingForm', false);\n this.schedulerStore.set('selectedTimeslot', null);\n\n return result;\n }\n\n /**\n * Set reschedule booking id\n */\n public async setReschedule(bookingID: string) {\n this.schedulerStore.set('isLoading', true);\n const eventInfo = this.schedulerStore.state.eventInfo;\n if (eventInfo) {\n this.schedulerStore.set('reschedulingEventInfo', eventInfo);\n }\n this.schedulerStore.set('rescheduleBookingId', bookingID);\n await this.getUISettings();\n // Set reschedule booking id\n const result = await this.resetStoreStateAndFetchAvailability().finally(() => {\n this.schedulerStore.set('isLoading', false);\n });\n\n return result;\n }\n\n /**\n * Set cancel booking id\n */\n public async setCancel(bookingID: string) {\n this.schedulerStore.set('cancelBookingId', bookingID);\n }\n\n /**\n * Set reject booking id\n */\n public async setReject(bookingID: string) {\n this.schedulerStore.set('rejectBookingId', bookingID);\n }\n\n public async resetCancel() {\n const result = await this.resetStoreStateAndFetchAvailability();\n this.schedulerStore.set('cancelBookingId', '');\n this.schedulerStore.set('rejectBookingId', '');\n this.schedulerStore.set('cancelledEventInfo', null);\n return result;\n }\n\n public async goBack() {\n this.schedulerStore.set('cancelBookingId', '');\n return;\n }\n\n public async resetConfirm() {\n const result = await this.resetStoreStateAndFetchAvailability();\n this.schedulerStore.set('organizerConfirmationBookingId', '');\n this.schedulerStore.set('confirmedEventInfo', undefined);\n return result;\n }\n\n /**\n * Book the selected timeslot.\n * @param data The booking info.\n * @returns {Promise<NylasResponse<NylasEvent>>}\n */\n public async bookTimeslot(data?: NylasSchedulerBookingDataWithFlatFields & { timeslot?: Timeslot }): Promise<NylasSchedulerResponse<NylasEvent>> {\n this.schedulerStore.set('isLoading', true);\n const { selectedTimeslot, selectedTimezone, bookingInfo, selectedLanguage } = this.schedulerStore.state;\n if (!data && !bookingInfo) {\n return { error: this.errors.component(i18next.t('createBookingErrorTitle')).no_booking_info() };\n }\n\n const timeslot = data?.timeslot || selectedTimeslot;\n if (!timeslot) {\n return { error: this.errors.component(i18next.t('createBookingErrorTitle')).no_timeslot_selected() };\n }\n\n const timezone = data && data?.timezone ? data?.timezone : selectedTimezone;\n const language = selectedLanguage || 'en-US';\n\n if (!timezone) {\n return { error: this.errors.component(i18next.t('createBookingErrorTitle')).no_timezone_selected() };\n }\n const order = this.schedulerStore.get('availabilityOrderEmails');\n let participantToBookWith = '';\n if (order.length > 0) {\n // Get the emails in the timeslot\n const emails = timeslot?.emails || [];\n for (let i = 0; i < order.length; i++) {\n if (emails.includes(order[i])) {\n participantToBookWith = order[i];\n break;\n }\n }\n }\n const addFields = {};\n Object.entries(bookingInfo?.additionalFields || {}).forEach(([key, entry]) => {\n addFields[key] = (entry as { value: string; type?: string }).value;\n });\n const primaryGuest = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;\n const guests = data ? data?.guests || [] : bookingInfo?.guests || [];\n const additional_fields = data ? data?.additionalFields : addFields;\n\n const headers = this.getHeaders();\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings${configIdParam}`;\n\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'POST',\n JSON.stringify({\n participants: participantToBookWith ? [{ email: participantToBookWith }] : undefined,\n additional_fields,\n additional_guests: guests,\n guest: { ...primaryGuest },\n start_time: timeslot.start_time.getTime() / 1000,\n end_time: timeslot.end_time.getTime() / 1000,\n timezone: timezone,\n email_language: this.getTwoLetterLanguageCode(language),\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api('Create Booking')) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api('Create Booking')[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n if ('data' in response) {\n this.schedulerStore.set('eventInfo', response?.data);\n }\n\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Get UI settings for the scheduler.\n */\n public async getUISettings(): Promise<NylasSchedulerResponse<UISettingsResponse>> {\n this.schedulerStore.set('isLoading', true);\n const bookingId = this.schedulerStore.get('rescheduleBookingId');\n const headers = this.getHeaders();\n let configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n if (bookingId && !!configIdParam) {\n configIdParam += `&booking_id=${bookingId}`;\n } else if (bookingId) {\n configIdParam += `?booking_id=${bookingId}`;\n }\n\n const url = `/v3/scheduling/ui-settings${configIdParam}`;\n\n const response = await this.makeAPIRequest<UISettingsResponse>(url, 'GET', undefined, headers);\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(i18next.t('getUISettingErrorTitle'))) {\n error = this.errors.api(i18next.t('getUISettingErrorTitle'))[errorType as APIErrorType](error?.message || error?.title || 'Something went wrong');\n }\n return { error };\n }\n if ('data' in response) {\n this.schedulerStore.set('configSettings', response.data);\n }\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n private getTwoLetterLanguageCode(language: string) {\n return language.split('-')[0];\n }\n\n private getStartTimeWithMinBookingNotice(startTime: number) {\n const scheduler = this.schedulerStore.get('configSettings')?.scheduler;\n const min_booking_notice = scheduler?.min_booking_notice;\n if (!min_booking_notice) {\n return startTime;\n }\n const today = new Date().getTime();\n\n if (startTime < (today + min_booking_notice * 60 * 1000) / 1000) {\n return Math.floor((today + min_booking_notice * 60 * 1000) / 1000);\n } else {\n return startTime;\n }\n }\n\n private getEndTimeForAvailableDaysInFuture(endTime: number) {\n const today = new Date();\n const availableDaysInFuture = this.schedulerStore.get('configSettings')?.scheduler?.available_days_in_future;\n const endTimeForAvailableDaysInFuture = Math.floor(addDaysToCurrentDate(today, availableDaysInFuture).getTime() / 1000);\n const endTimeWithOffset = Math.min(endTimeForAvailableDaysInFuture, endTime);\n return endTimeWithOffset;\n }\n\n /**\n * Gets the availability for a page.\n * @param startTime The start time.\n * @param endTime The end time.\n * @returns {Promise<AvailabilityResponse>}\n */\n public async getAvailability(startTime: number = 0, endTime: number = 0): Promise<NylasSchedulerResponse<AvailabilityResponse>> {\n this.schedulerStore.set('isLoading', true);\n const params = new URLSearchParams();\n const now = new Date();\n const nowTime = now.getTime();\n\n if (endTime && endTime < nowTime / 1000) {\n this.schedulerStore.set('isLoading', false);\n const error = this.errors.component(i18next.t('getAvailabilityErrorTitle')).endtime_not_in_future();\n return { error };\n }\n\n // Calculate the start of the current month if startTime is not provided\n if (!startTime) {\n const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);\n startTime = Math.floor(startOfMonth.getTime() / 1000); // Convert to UNIX timestamp in seconds\n }\n\n // Calculate the end of the current month if endTime is not provided\n if (!endTime) {\n const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0); // Setting day to 0 gets the last day of the previous month, so in this case, the last day of the current month\n endTime = Math.floor(endOfMonth.getTime() / 1000); // Convert to UNIX timestamp in seconds\n }\n\n endTime = this.getEndTimeForAvailableDaysInFuture(endTime);\n const startTimeWithMinBooking = this.getStartTimeWithMinBookingNotice(startTime);\n startTime = startTimeWithMinBooking;\n endTime = startTimeWithMinBooking > endTime ? startTimeWithMinBooking + 1 : endTime;\n\n params.append('start_time', encodeURIComponent(startTime.toString()));\n params.append('end_time', encodeURIComponent(endTime.toString()));\n if (this.configId && !this.sessionId) {\n params.append('configuration_id', encodeURIComponent(this.configId));\n } else if (this.slug && this.clientId && !this.sessionId) {\n params.append('slug', encodeURIComponent(this.slug));\n params.append('client_id', encodeURIComponent(this.clientId));\n }\n\n const rescheduleBookingId = this.schedulerStore.get('rescheduleBookingId');\n if (rescheduleBookingId) {\n params.append('booking_id', encodeURIComponent(rescheduleBookingId));\n }\n const queryString = params.toString();\n const url = `/v3/scheduling/availability${queryString ? `?${queryString}` : ''}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<AvailabilityResponse>(decodeURIComponent(url), 'GET', undefined, headers);\n\n if ('error' in response) {\n this.schedulerStore.set('availability', []);\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(i18next.t('getAvailabilityErrorTitle'))) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api(i18next.t('getAvailabilityErrorTitle'))[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n if ('data' in response) {\n const availability =\n response.data?.time_slots?.map(timeslot => {\n return {\n ...timeslot,\n start_time: new Date(timeslot.start_time * 1000),\n end_time: new Date(timeslot.end_time * 1000),\n };\n }) || [];\n\n // Filter out timeslots that are in the past\n const availabilityTimeslotsFiltered = availability.filter(timeslot => timeslot.start_time.getTime() > nowTime);\n this.schedulerStore.set('availability', availabilityTimeslotsFiltered);\n const order = response.data?.order || [];\n this.schedulerStore.set('availabilityOrderEmails', order);\n }\n\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Cancels a booking.\n * @param bookingId The booking ID.\n */\n public async cancelBooking(bookingId: string, reason: string): Promise<NylasSchedulerResponse<Partial<NylasEvent>>> {\n this.schedulerStore.set('isLoading', true);\n if (!bookingId) {\n return { error: this.errors.component(i18next.t('cancelBookingErrorTitle')).no_booking_id() };\n }\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings/${bookingId}${configIdParam}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<Partial<NylasEvent>>(\n decodeURIComponent(url),\n 'DELETE',\n JSON.stringify({\n action: 'cancel',\n cancellation_reason: reason,\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(i18next.t('cancelBookingErrorTitle'))) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api(i18next.t('cancelBookingErrorTitle'))[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n this.schedulerStore.set('cancelledEventInfo', {\n booking_id: bookingId,\n });\n this.schedulerStore.set('rescheduleBookingId', '');\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Reschedules a booking.\n * @param bookingId The booking ID.\n * @param data The booking info.\n * @returns {Promise<NylasResponse<NylasEvent>>}\n */\n public async rescheduleBooking(bookingId: string, data: NylasSchedulerBookingDataWithFlatFields): Promise<NylasSchedulerResponse<NylasEvent>> {\n this.schedulerStore.set('isLoading', true);\n if (!bookingId) {\n return { error: this.errors.component(i18next.t('rescheduleBookingErrorTitle')).no_booking_id() };\n }\n const apiErrors = this.errors.api(i18next.t('rescheduleBookingErrorTitle'));\n const componentErrors = this.errors.component(i18next.t('rescheduleBookingErrorTitle'));\n const { bookingInfo, selectedTimeslot, selectedTimezone, selectedLanguage } = this.schedulerStore.state;\n // Validate data\n const { startTime, endTime, timezone } = data;\n const start_time = startTime || selectedTimeslot?.start_time;\n\n if (!start_time) {\n return { error: componentErrors.invalid_start_time('Please pass \"startTime\" in data or set \"selectedTimeslot\" in the defaultSchedulerState.') };\n }\n const end_time = endTime || selectedTimeslot?.end_time;\n if (!end_time) {\n return { error: componentErrors.invalid_end_time('Please pass \"endTime\" in data or set \"selectedTimeslot\" in the defaultSchedulerState.') };\n }\n\n const order = this.schedulerStore.get('availabilityOrderEmails');\n let participantToBookWith = '';\n if (order.length > 0) {\n // Get the emails in the timeslot\n const emails = selectedTimeslot?.emails || [];\n for (let i = 0; i < order.length; i++) {\n if (emails.includes(order[i])) {\n participantToBookWith = order[i];\n break;\n }\n }\n }\n\n const time_zone = timezone || selectedTimezone;\n if (!time_zone) {\n return { error: componentErrors.invalid_timezone('Please pass \"timezone\" in data or set \"selectedTimezone\" in the defaultSchedulerState.') };\n }\n const addFields = {};\n Object.entries(bookingInfo?.additionalFields || {}).forEach(([key, entry]) => {\n addFields[key] = (entry as { value: string; type?: string }).value;\n });\n const primaryGuest = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;\n const guests = data ? data?.guests || [] : bookingInfo?.guests || [];\n const additional_fields = data ? data?.additionalFields : addFields;\n\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings/${bookingId}${configIdParam}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'PATCH',\n JSON.stringify({\n start_time: start_time.getTime() / 1000,\n end_time: end_time.getTime() / 1000,\n timezone: time_zone,\n additional_fields,\n guest: { ...primaryGuest },\n additional_guests: guests,\n participants: participantToBookWith ? [{ email: participantToBookWith }] : undefined,\n email_language: this.getTwoLetterLanguageCode(selectedLanguage),\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in apiErrors) {\n const errorMessage = this.getErrorMessage(error);\n error = apiErrors[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n const eventInfo = this.schedulerStore.get('reschedulingEventInfo');\n if ('data' in response) {\n this.schedulerStore.set('eventInfo', response?.data);\n } else if (eventInfo) {\n this.schedulerStore.set('eventInfo', eventInfo);\n } else {\n // We should technically never reach this point\n const event = {\n booking_id: bookingId,\n } as NylasEvent;\n this.schedulerStore.set('eventInfo', event);\n }\n\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n\n /**\n * Updates the booking.\n * @param bookingId The booking ID.\n */\n public async updateBooking(payload: { bookingId: string; status: 'confirmed' | 'cancelled'; reason?: string }): Promise<NylasSchedulerResponse<NylasEvent>> {\n this.schedulerStore.set('isLoading', true);\n const { bookingId, status, reason } = payload;\n const salt = this.schedulerStore.get('organizerConfirmationSalt');\n const errorTitle = status === 'confirmed' ? i18next.t('confirmBookingErrorTitle') : i18next.t('rejectBookingErrorTitle');\n\n if (!bookingId) {\n return { error: this.errors.component(errorTitle).no_booking_id() };\n }\n if (!salt) {\n return { error: this.errors.component(errorTitle).no_salt() };\n }\n\n const configIdParam =\n !this.sessionId && this.configId\n ? `?configuration_id=${this.configId}`\n : !this.sessionId && this.slug && this.clientId\n ? `?slug=${this.slug}&client_id=${this.clientId}`\n : '';\n const url = `/v3/scheduling/bookings/${bookingId}${configIdParam}`;\n const headers = this.getHeaders();\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'PUT',\n JSON.stringify({\n status: status,\n cancellation_reason: reason,\n salt,\n }),\n headers,\n );\n\n if ('error' in response) {\n this.schedulerStore.set('isLoading', false);\n const errorType = response.error?.type;\n let error = response.error;\n if (errorType && errorType in this.errors.api(errorTitle)) {\n const errorMessage = this.getErrorMessage(error);\n error = this.errors.api(errorTitle)[errorType as APIErrorType](errorMessage);\n }\n return { error };\n }\n\n if ('data' in response && status === 'confirmed') {\n this.schedulerStore.set('confirmedEventInfo', response?.data);\n } else if ('request_id' in response && status === 'cancelled') {\n this.schedulerStore.set('cancelledEventInfo', {\n booking_id: bookingId,\n });\n }\n\n this.schedulerStore.set('organizerConfirmationBookingId', '');\n this.schedulerStore.set('isLoading', false);\n return response;\n }\n}\n","import { DataState, NylasEvent } from '@/common/types';\nimport { debug } from '@/utils/utils';\nimport { AdditionalFields, Appearance, NylasSchedulerBookingData, ThemeConfig, Timeslot } from '@nylas/core';\nimport { createStore } from '@stencil/store';\n\nexport type AvailabilityTimeslot = {\n emails: string[];\n start_time: Date;\n end_time: Date;\n};\n\nexport type LoadingState = {\n api: 'availability' | 'createBooking' | 'cancelBooking' | 'rescheduleBooking';\n};\n\nexport type ConfigSettings = {\n configuration_id: string;\n booking?: {\n additional_fields: Record<string, string>;\n additional_guests: {\n email: string;\n name: string;\n }[];\n booking_ref: string;\n booking_ref_salt: string;\n guest: {\n email: string;\n name: string;\n };\n timezone: string;\n email_language: string;\n event_data: {\n location: string;\n when: {\n start_time: Date;\n end_time: Date;\n end_timezone: string;\n start_timezone: string;\n object: string;\n };\n };\n event_organizer: {\n name: string;\n email: string;\n is_organizer: boolean;\n };\n };\n scheduler: {\n available_days_in_future: number;\n min_cancellation_notice: number;\n min_booking_notice: number;\n rescheduling_url?: string;\n cancellation_url?: string;\n cancellation_policy?: string;\n hide_additional_guests?: boolean;\n hide_cancellation_options?: boolean;\n hide_rescheduling_options?: boolean;\n additional_fields?: Record<string, AdditionalFields>;\n confirmation_redirect_url?: string;\n organizer_confirmation_url?: string;\n };\n organizer: {\n name: string;\n email: string;\n };\n slug: string;\n appearance: Appearance;\n booking_type: string;\n name: string;\n};\n\nexport interface NylasSchedulerStoreState {\n selectedDate: Date | null;\n selectedLanguage: string;\n selectedTimezone: string;\n selectedTimeslot: Timeslot | null;\n availabilityOrderEmails: string[];\n showBookingForm: boolean;\n selectableDates: Date[] | null;\n eventDuration: number;\n availability: AvailabilityTimeslot[];\n state: DataState;\n eventInfo: NylasEvent | null;\n cancelledEventInfo: Partial<NylasEvent> | null;\n reschedulingEventInfo?: NylasEvent;\n confirmedEventInfo?: NylasEvent;\n bookingInfo?: NylasSchedulerBookingData;\n rescheduleBookingId?: string;\n cancelBookingId?: string;\n isLoading: boolean;\n nylasBranding?: boolean;\n configSettings?: ConfigSettings;\n organizerConfirmationBookingId?: string;\n rejectBookingId?: string;\n organizerConfirmationSalt?: string;\n themeConfig?: ThemeConfig;\n}\n\nexport type NylasSchedulerStoreType = ReturnType<typeof CreateNylasSchedulerStore>;\n\nexport function CreateNylasSchedulerStore(defaultState: Partial<NylasSchedulerStoreState> = {}) {\n const defaultNylasStoreState: NylasSchedulerStoreState = {\n selectedDate: null,\n selectedLanguage: navigator.language,\n selectedTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n selectedTimeslot: null,\n showBookingForm: false,\n availabilityOrderEmails: [],\n selectableDates: null,\n availability: [],\n eventDuration: 0,\n state: 'ready',\n eventInfo: null,\n cancelledEventInfo: null,\n isLoading: false,\n nylasBranding: true,\n ...defaultState,\n };\n debug(`[defaultNylasStoreState]: `, defaultNylasStoreState);\n const store = createStore<NylasSchedulerStoreState>(defaultNylasStoreState);\n\n store.onChange('availability', availability => {\n debug(`[availability]: `, availability);\n const selectableDates = availability.map(timeslot => timeslot.start_time);\n debug(`[selectableDates]: `, selectableDates);\n store.set('selectableDates', selectableDates);\n const timeslot = availability[0];\n if (!timeslot) return;\n const durationMinutes = Math.floor((timeslot.end_time.getTime() - timeslot.start_time.getTime()) / 60000);\n debug(`[durationMinutes]: `, durationMinutes);\n store.set('eventDuration', durationMinutes);\n });\n\n /**\n * Reset the Nylas store to its default state.\n * There is something wrong with the stencil/store reset method,\n * so we have to do it via this hack.\n */\n store.reset = () => {\n for (const key in defaultNylasStoreState) {\n const value = defaultNylasStoreState[key as keyof typeof defaultNylasStoreState];\n store.set(key as any, value);\n }\n };\n\n return store;\n}\n"],"version":3}
|
|
@@ -31,6 +31,21 @@ const TimePeriodSelector = class {
|
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
defaultSelectedPeriodChanged(newValue) {
|
|
35
|
+
this.selectedPeriod = newValue;
|
|
36
|
+
this.updateNumberOptionsAndSelectedNumber(newValue);
|
|
37
|
+
}
|
|
38
|
+
defaultSelectedNumberChanged(newValue) {
|
|
39
|
+
this.selectedNumber = newValue;
|
|
40
|
+
}
|
|
41
|
+
timePeriodsChanged(newValue) {
|
|
42
|
+
this.timePeriodOptions = newValue.map(period => {
|
|
43
|
+
return {
|
|
44
|
+
label: period,
|
|
45
|
+
value: period,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
34
49
|
componentDidLoad() {
|
|
35
50
|
this.selectedNumber = this.defaultSelectedNumber;
|
|
36
51
|
this.selectedPeriod = this.defaultSelectedPeriod;
|
|
@@ -98,9 +113,14 @@ const TimePeriodSelector = class {
|
|
|
98
113
|
this.selectedNumber = parseInt(this.numberOptions[0].value);
|
|
99
114
|
}
|
|
100
115
|
render() {
|
|
101
|
-
return (h("div", { key: '
|
|
116
|
+
return (h("div", { key: 'f40a2be9bc76a0a5be0ffa3c87779fab644e52f2', class: "time-period-selector" }, typeof this.selectedNumber == 'number' && (h("input-dropdown", { id: "time-number", name: 'time-number', inputValue: this.selectedNumber.toString(), exportparts: "id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content", options: this.numberOptions, defaultInputOption: this.numberOptions.find(i => i.value == this.selectedNumber.toString()) })), typeof this.selectedPeriod == 'string' && (h("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' : '', defaultSelectedOption: this.timePeriodOptions.find(i => i.value == this.selectedPeriod), withSearch: false }))));
|
|
102
117
|
}
|
|
103
118
|
get host() { return getElement(this); }
|
|
119
|
+
static get watchers() { return {
|
|
120
|
+
"defaultSelectedPeriod": ["defaultSelectedPeriodChanged"],
|
|
121
|
+
"defaultSelectedNumber": ["defaultSelectedNumberChanged"],
|
|
122
|
+
"timePeriods": ["timePeriodsChanged"]
|
|
123
|
+
}; }
|
|
104
124
|
};
|
|
105
125
|
TimePeriodSelector.style = timePeriodSelectorCss;
|
|
106
126
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"time-period-selector.entry.js","mappings":";;;AAAA,MAAM,qBAAqB,GAAG,0rDAA0rD;;ACIxtD,MAAM,gBAAgB,GAAG;IACvB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,OAAO;CAChB,CAAC;MAOW,kBAAkB;;;;2BAIG,CAAC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,OAAO,IAAI,CAAC,cAAc,IAAI,QAAQ,KACrC,uBACE,EAAE,EAAC,aAAa,EAChB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAC/B,WAAW,EAAC,uIAAuI,EACnJ,eAAe,EAAE,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,EACnD,qBAAqB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,EACvF,UAAU,EAAE,KAAK,GACjB,CACH,CACG,EACN;KACH;;;;;;;","names":[],"sources":["src/components/design-system/time-period-selector/time-period-selector.scss?tag=time-period-selector&encapsulation=scoped","src/components/design-system/time-period-selector/time-period-selector.tsx"],"sourcesContent":[".time-period-selector {\n display: grid;\n gap: 0.5rem;\n grid-template-columns: auto 1fr;\n\n select-dropdown,\n input-dropdown {\n border: 1px solid var(--nylas-base-200);\n border-radius: var(--nylas-border-radius-2x);\n }\n select-dropdown {\n width: 116px;\n }\n input-dropdown {\n width: 84px;\n display: flex;\n align-items: center;\n }\n\n select-dropdown#time-period::part(sd_dropdown-button) {\n width: 100%;\n }\n input-dropdown::part(id_dropdown) {\n width: inherit;\n height: 100%;\n }\n input-dropdown#time-number::part(id_dropdown-input) {\n border: none;\n border-radius: var(--nylas-border-radius-2x);\n }\n input-dropdown::part(id_dropdown-input) {\n padding: 17px;\n gap: 1rem;\n }\n input-dropdown::part(id_dropdown-content) {\n width: 100%;\n max-height: 200px;\n }\n select-dropdown::part(sd_dropdown) {\n width: inherit;\n }\n select-dropdown::part(sd_dropdown-button) {\n padding: 1rem;\n gap: 1rem;\n justify-content: space-between;\n }\n select-dropdown::part(sd_dropdown-content) {\n width: 100%;\n max-height: 200px;\n }\n}\n","import { debug } from '@/utils/utils';\nimport { Element, Event, EventEmitter } from '@stencil/core';\nimport { Component, h, Listen, Prop, State } from '@stencil/core';\n\nconst pluralToSingular = {\n hours: 'hour',\n days: 'day',\n weeks: 'week',\n months: 'month',\n};\n\n@Component({\n tag: 'time-period-selector',\n styleUrl: 'time-period-selector.scss',\n scoped: true,\n})\nexport class TimePeriodSelector {\n @Element() host!: HTMLElement;\n\n // The possible values for the time periods dropdown\n @Prop() timePeriods: string[] = ['hour', 'day', 'week', 'month'];\n\n /**\n * The default selected time period.\n */\n @Prop() defaultSelectedPeriod!: string;\n\n /**\n * The default selected number.\n */\n @Prop() defaultSelectedNumber!: number;\n\n /**\n * The currently selected time period\n */\n @State() selectedPeriod: string = this.defaultSelectedPeriod;\n\n /**\n * The currently selected number of the time period\n */\n @State() selectedNumber: number = this.defaultSelectedNumber;\n\n /*\n * The options for the number dropdown, to be calculated based on the selectedPeriod\n */\n @State() numberOptions: { label: string; value: string }[] = this.calculateOptions(this.defaultSelectedPeriod || 'hour').map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n\n /**\n * The options for the time period dropdown\n */\n @State() timePeriodOptions = this.timePeriods.map(period => {\n return {\n label: period,\n value: period,\n };\n });\n\n componentDidLoad() {\n this.selectedNumber = this.defaultSelectedNumber;\n this.selectedPeriod = this.defaultSelectedPeriod;\n const period = pluralToSingular[this.selectedPeriod] ?? this.selectedPeriod;\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n }\n\n @Event() timePeriodChanged!: EventEmitter<{ number: number; period: string }>;\n\n private calculateOptions(period: string): number[] {\n switch (period) {\n case 'hour':\n return Array.from({ length: 23 }, (_, i) => i + 1);\n case 'minute':\n return Array.from({ length: 13 }, (_, i) => i * 5);\n case 'day':\n return Array.from({ length: 30 }, (_, i) => i + 1);\n case 'week':\n return Array.from({ length: 4 }, (_, i) => i + 1);\n case 'month':\n return Array.from({ length: 12 }, (_, i) => i + 1);\n default:\n return [];\n }\n }\n\n @Listen('inputOptionChanged')\n inputOptionChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'inputOptionChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-number') {\n this.selectedNumber = value ? parseInt(value) : this.defaultSelectedNumber;\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n @Listen('nylasFormDropdownChanged')\n nylasFormDropdownChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'nylasFormDropdownChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-period') {\n this.selectedPeriod = value;\n this.updateNumberOptionsAndSelectedNumber(value);\n } else if (name === 'time-number') {\n this.selectedNumber = parseInt(value);\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n updateNumberOptionsAndSelectedNumber(period: string) {\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n this.selectedNumber = parseInt(this.numberOptions[0].value);\n }\n\n render() {\n return (\n <div class=\"time-period-selector\">\n {typeof this.selectedNumber == 'number' && (\n <input-dropdown\n id=\"time-number\"\n name={'time-number'}\n inputValue={this.selectedNumber.toString()}\n exportparts=\"id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content\"\n options={this.numberOptions}\n defaultInputOption={this.numberOptions.find(i => i.value == this.selectedNumber.toString())}\n />\n )}\n {typeof this.selectedPeriod == 'string' && (\n <select-dropdown\n id=\"time-period\"\n name={'time-period'}\n options={this.timePeriodOptions}\n exportparts=\"sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content\"\n pluralizedLabel={this.selectedNumber > 1 ? 's' : ''}\n defaultSelectedOption={this.timePeriodOptions.find(i => i.value == this.selectedPeriod)}\n withSearch={false}\n />\n )}\n </div>\n );\n }\n}\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;gBACL,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE;gBACnB,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE;aACpB,CAAC;SACH,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;KAC7D;IAED,MAAM;QACJ,QACE,4DAAK,KAAK,EAAC,sBAAsB,IAC9B,OAAO,IAAI,CAAC,cAAc,IAAI,QAAQ,KACrC,sBACE,EAAE,EAAC,aAAa,EAChB,IAAI,EAAE,aAAa,EACnB,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,EAC1C,WAAW,EAAC,sIAAsI,EAClJ,OAAO,EAAE,IAAI,CAAC,aAAa,EAC3B,kBAAkB,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,GAC3F,CACH,EACA,OAAO,IAAI,CAAC,cAAc,IAAI,QAAQ,KACrC,uBACE,EAAE,EAAC,aAAa,EAChB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAC/B,WAAW,EAAC,uIAAuI,EACnJ,eAAe,EAAE,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,EACnD,qBAAqB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,EACvF,UAAU,EAAE,KAAK,GACjB,CACH,CACG,EACN;KACH;;;;;;;;;;;;","names":[],"sources":["src/components/design-system/time-period-selector/time-period-selector.scss?tag=time-period-selector&encapsulation=scoped","src/components/design-system/time-period-selector/time-period-selector.tsx"],"sourcesContent":[".time-period-selector {\n display: grid;\n gap: 0.5rem;\n grid-template-columns: auto 1fr;\n\n select-dropdown,\n input-dropdown {\n border: 1px solid var(--nylas-base-200);\n border-radius: var(--nylas-border-radius-2x);\n }\n select-dropdown {\n width: 116px;\n }\n input-dropdown {\n width: 84px;\n display: flex;\n align-items: center;\n }\n\n select-dropdown#time-period::part(sd_dropdown-button) {\n width: 100%;\n }\n input-dropdown::part(id_dropdown) {\n width: inherit;\n height: 100%;\n }\n input-dropdown#time-number::part(id_dropdown-input) {\n border: none;\n border-radius: var(--nylas-border-radius-2x);\n }\n input-dropdown::part(id_dropdown-input) {\n padding: 17px;\n gap: 1rem;\n }\n input-dropdown::part(id_dropdown-content) {\n width: 100%;\n max-height: 200px;\n }\n select-dropdown::part(sd_dropdown) {\n width: inherit;\n }\n select-dropdown::part(sd_dropdown-button) {\n padding: 1rem;\n gap: 1rem;\n justify-content: space-between;\n }\n select-dropdown::part(sd_dropdown-content) {\n width: 100%;\n max-height: 200px;\n }\n}\n","import { debug } from '@/utils/utils';\nimport { Element, Event, EventEmitter, Watch } from '@stencil/core';\nimport { Component, h, Listen, Prop, State } from '@stencil/core';\n\nconst pluralToSingular = {\n hours: 'hour',\n days: 'day',\n weeks: 'week',\n months: 'month',\n};\n\n@Component({\n tag: 'time-period-selector',\n styleUrl: 'time-period-selector.scss',\n scoped: true,\n})\nexport class TimePeriodSelector {\n @Element() host!: HTMLElement;\n\n // The possible values for the time periods dropdown\n @Prop() timePeriods: string[] = ['hour', 'day', 'week', 'month'];\n\n /**\n * The default selected time period.\n */\n @Prop() defaultSelectedPeriod!: string;\n\n /**\n * The default selected number.\n */\n @Prop() defaultSelectedNumber!: number;\n\n /**\n * The currently selected time period\n */\n @State() selectedPeriod: string = this.defaultSelectedPeriod;\n\n /**\n * The currently selected number of the time period\n */\n @State() selectedNumber: number = this.defaultSelectedNumber;\n\n /*\n * The options for the number dropdown, to be calculated based on the selectedPeriod\n */\n @State() numberOptions: { label: string; value: string }[] = this.calculateOptions(this.defaultSelectedPeriod || 'hour').map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n\n /**\n * The options for the time period dropdown\n */\n @State() timePeriodOptions = this.timePeriods.map(period => {\n return {\n label: period,\n value: period,\n };\n });\n\n @Watch('defaultSelectedPeriod')\n defaultSelectedPeriodChanged(newValue: string) {\n this.selectedPeriod = newValue;\n this.updateNumberOptionsAndSelectedNumber(newValue);\n }\n\n @Watch('defaultSelectedNumber')\n defaultSelectedNumberChanged(newValue: number) {\n this.selectedNumber = newValue;\n }\n\n @Watch('timePeriods')\n timePeriodsChanged(newValue: string[]) {\n this.timePeriodOptions = newValue.map(period => {\n return {\n label: period,\n value: period,\n };\n });\n }\n\n componentDidLoad() {\n this.selectedNumber = this.defaultSelectedNumber;\n this.selectedPeriod = this.defaultSelectedPeriod;\n const period = pluralToSingular[this.selectedPeriod] ?? this.selectedPeriod;\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n }\n\n @Event() timePeriodChanged!: EventEmitter<{ number: number; period: string }>;\n\n private calculateOptions(period: string): number[] {\n switch (period) {\n case 'hour':\n return Array.from({ length: 23 }, (_, i) => i + 1);\n case 'minute':\n return Array.from({ length: 13 }, (_, i) => i * 5);\n case 'day':\n return Array.from({ length: 30 }, (_, i) => i + 1);\n case 'week':\n return Array.from({ length: 4 }, (_, i) => i + 1);\n case 'month':\n return Array.from({ length: 12 }, (_, i) => i + 1);\n default:\n return [];\n }\n }\n\n @Listen('inputOptionChanged')\n inputOptionChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'inputOptionChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-number') {\n this.selectedNumber = value ? parseInt(value) : this.defaultSelectedNumber;\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n @Listen('nylasFormDropdownChanged')\n nylasFormDropdownChangedHandler(event: CustomEvent<{ value: string; name: string }>) {\n debug('time-period-selector', 'nylasFormDropdownChangedHandler', event.detail);\n const { value, name } = event.detail;\n if (name === 'time-period') {\n this.selectedPeriod = value;\n this.updateNumberOptionsAndSelectedNumber(value);\n } else if (name === 'time-number') {\n this.selectedNumber = parseInt(value);\n }\n const selected = {\n number: this.selectedNumber,\n period: this.selectedPeriod,\n };\n this.timePeriodChanged.emit(selected);\n }\n\n updateNumberOptionsAndSelectedNumber(period: string) {\n const numberOptions = this.calculateOptions(period);\n this.numberOptions = numberOptions.map(i => {\n return {\n label: i.toString(),\n value: i.toString(),\n };\n });\n this.selectedNumber = parseInt(this.numberOptions[0].value);\n }\n\n render() {\n return (\n <div class=\"time-period-selector\">\n {typeof this.selectedNumber == 'number' && (\n <input-dropdown\n id=\"time-number\"\n name={'time-number'}\n inputValue={this.selectedNumber.toString()}\n exportparts=\"id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content\"\n options={this.numberOptions}\n defaultInputOption={this.numberOptions.find(i => i.value == this.selectedNumber.toString())}\n />\n )}\n {typeof this.selectedPeriod == 'string' && (\n <select-dropdown\n id=\"time-period\"\n name={'time-period'}\n options={this.timePeriodOptions}\n exportparts=\"sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content\"\n pluralizedLabel={this.selectedNumber > 1 ? 's' : ''}\n defaultSelectedOption={this.timePeriodOptions.find(i => i.value == this.selectedPeriod)}\n withSearch={false}\n />\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -14,6 +14,11 @@ const CheckboxComponent = class {
|
|
|
14
14
|
this.isChecked = undefined;
|
|
15
15
|
this.error = '';
|
|
16
16
|
}
|
|
17
|
+
checkedPropChangedHandler(newValue) {
|
|
18
|
+
if (typeof newValue === 'boolean') {
|
|
19
|
+
this.isChecked = newValue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
17
22
|
componentWillLoad() {
|
|
18
23
|
this.el.setAttribute('component-type', this.componentType);
|
|
19
24
|
}
|
|
@@ -39,9 +44,12 @@ const CheckboxComponent = class {
|
|
|
39
44
|
});
|
|
40
45
|
}
|
|
41
46
|
render() {
|
|
42
|
-
return (h("div", { key: '
|
|
47
|
+
return (h("div", { key: '0be06ba2c6b6ed277b3ba736827f9f60e18c6056', class: "checkbox-container" }, h("label", { key: 'a0a0cf6b1f546b8d1485dd3aee1b686f0e9c9cba' }, h("input", { key: '96bdb407b3ab6f668cf94b83e8091a604743f93f', type: "checkbox", name: this.name, checked: this.isChecked, onChange: () => this.toggleCheck() }), h("span", { key: 'd345d3b47c14213487a9108d78abbf0db26f25af', class: "checkmark" }), h("slot", { key: 'aba536e12ed7a97d18790f1a212ead284c1253ec', name: "label" }, h("span", { key: 'e7767302bc6865b99cf42949e8bd032e237d2ad9', class: "label" }, this.label))), this.error && h("p", { class: "error" }, this.error)));
|
|
43
48
|
}
|
|
44
49
|
get el() { return getElement(this); }
|
|
50
|
+
static get watchers() { return {
|
|
51
|
+
"checked": ["checkedPropChangedHandler"]
|
|
52
|
+
}; }
|
|
45
53
|
};
|
|
46
54
|
CheckboxComponent.style = checkboxComponentCss;
|
|
47
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"checkbox-component.entry.esm.js","mappings":";;AAAA,MAAM,oBAAoB,GAAG,0pEAA0pE;;MCW1qE,iBAAiB;;;;QAEX,kBAAa,GAAW,UAAU,CAAC;oBAK7B,UAAU;;qBAQT,EAAE;wBAKE,KAAK;;qBAQR,EAAE;;IAY3B,iBAAiB;QACf,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;KAC5D;IAED,gBAAgB;QACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC;KACxC;IAOD,0BAA0B,CAAC,KAAkB;QAC3C,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACpC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ox-component/checkbox-component.scss?tag=checkbox-component&encapsulation=shadow","src/components/design-system/checkbox-component/checkbox-component.tsx"],"sourcesContent":["@import '../../../common/styles/variables.scss';\n\n.checkbox-container {\n @include default-css-variables;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n\n p.error {\n color: var(--nylas-error);\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n font-family: var(--nylas-font-family);\n margin: 0;\n }\n}\n\nlabel {\n display: flex;\n align-items: center;\n font-family: var(--nylas-font-family);\n cursor: pointer;\n position: relative;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n\n input[type='checkbox'] {\n position: absolute;\n opacity: 0;\n cursor: pointer;\n\n &:focus ~ .checkmark,\n &:hover ~ .checkmark {\n border-color: var(--nylas-primary);\n }\n\n &:checked ~ .checkmark {\n color: var(--nylas-base-0);\n background: var(--nylas-primary)\n url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnIHdpZHRoPSIxMiIgaGVpZ2h0PSI5IiB2aWV3Qm94PSIwIDAgMTIgOSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPHBhdGggZD0iTTQuNTc1IDguOTc3cy0uNDA0LS4wMDctLjUzNi0uMTY1TC4wNTcgNS42NGwuODI5LTEuMjI3TDQuNDcgNy4yNjggMTAuOTIxLjA4NmwuOTIzIDEuMTAzLTYuODYzIDcuNjRjLS4xMzQtLjAwMy0uNDA2LjE0OC0uNDA2LjE0OHoiIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPg0KPC9zdmc+)\n 50% 40% no-repeat;\n border: 2px solid var(--nylas-primary);\n }\n }\n\n .checkmark {\n border-radius: var(--nylas-border-radius);\n border: 2px solid var(--nylas-base-800);\n position: absolute;\n left: 0;\n top: 2px;\n width: 18px;\n height: 18px;\n cursor: pointer;\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n\n .label {\n margin-left: 32px;\n font-size: 16px;\n font-weight: 400;\n color: var(--nylas-base-800);\n line-height: 24px;\n }\n}\n","import { Component, h, Prop, State, Event, EventEmitter, Listen, Element, Watch } from '@stencil/core';\n\n/**\n * The `checkbox-component` component is a UI component that allows users to select a checkbox.\n * This component is used in the scheduling form to input checkbox type inputs.\n */\n@Component({\n tag: 'checkbox-component',\n styleUrl: 'checkbox-component.scss',\n shadow: true,\n})\nexport class CheckboxComponent {\n @Element() el!: HTMLElement;\n private readonly componentType: string = 'checkbox';\n\n /**\n * The name of the checkbox. This is used to identify the checkbox when submitting a form.\n */\n @Prop() name: string = 'checkbox';\n /**\n * The default value of the checkbox. This is the value that is displayed when the checkbox is rendered.\n */\n @Prop() checked?: boolean;\n /**\n * The label of the checkbox. This is displayed next to the checkbox.\n */\n @Prop() label: string = '';\n /**\n * Whether the checkbox is required. If true, the checkbox must be checked when submitting a form.\n * Default is false. If the checkbox is required and not checked, an error message is displayed.\n */\n @Prop() required: boolean = false;\n /**\n * The checked state of the checkbox.\n */\n @State() isChecked!: boolean;\n /**\n * The error message state.\n */\n @State() error: string = '';\n\n /**\n * This event is fired when the checkbox is toggled.\n */\n @Event() nylasFormCheckboxToggled!: EventEmitter<{\n checked: boolean;\n name: string;\n label: string;\n }>;\n\n @Watch('checked')\n checkedPropChangedHandler(newValue: boolean) {\n if (typeof newValue === 'boolean') {\n this.isChecked = newValue;\n }\n }\n\n // Lifecycle events\n componentWillLoad() {\n this.el.setAttribute('component-type', this.componentType);\n }\n\n componentDidLoad() {\n this.isChecked = this.checked || false;\n }\n\n // Event listeners\n /**\n * Listen for the bookingFormSubmitted event to validate the input value when the form is submitted.\n */\n @Listen('bookingFormSubmitted', { target: 'document' })\n handleBookingFormSubmitted(event: CustomEvent) {\n if (this.required && !this.isChecked) {\n this.error = `${this.label} is required.`;\n return;\n }\n if (this.error) {\n event.preventDefault();\n }\n }\n\n // Methods\n toggleCheck() {\n this.error = '';\n this.isChecked = !this.isChecked;\n this.nylasFormCheckboxToggled.emit({\n checked: this.isChecked,\n name: this.name,\n label: this.label,\n });\n }\n\n render() {\n return (\n <div class=\"checkbox-container\">\n <label>\n <input type=\"checkbox\" name={this.name} checked={this.isChecked} onChange={() => this.toggleCheck()} />\n <span class=\"checkmark\"></span>\n <slot name=\"label\">\n <span class=\"label\">{this.label}</span>\n </slot>\n </label>\n {this.error && <p class=\"error\">{this.error}</p>}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -16,6 +16,21 @@ const MultiSelectDropdown = class {
|
|
|
16
16
|
this.ariaActivedescendant = '';
|
|
17
17
|
this.shouldFocusFirstOption = false;
|
|
18
18
|
}
|
|
19
|
+
areOptionsEqual(arr1, arr2) {
|
|
20
|
+
if (arr1.length !== arr2.length)
|
|
21
|
+
return false;
|
|
22
|
+
const sorted1 = [...arr1].sort((a, b) => a.label.localeCompare(b.label) || a.value.localeCompare(b.value));
|
|
23
|
+
const sorted2 = [...arr2].sort((a, b) => a.label.localeCompare(b.label) || a.value.localeCompare(b.value));
|
|
24
|
+
return sorted1.every((opt1, index) => {
|
|
25
|
+
const opt2 = sorted2[index];
|
|
26
|
+
return opt1.label === opt2.label && opt1.value === opt2.value;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
optionsChangedHandler(newValue) {
|
|
30
|
+
if (!this.areOptionsEqual(newValue, this.availableOptions)) {
|
|
31
|
+
this.availableOptions = newValue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
19
34
|
componentDidLoad() {
|
|
20
35
|
debug('multi-select-dropdown', 'componentDidLoad');
|
|
21
36
|
if (this.options) {
|
|
@@ -130,9 +145,12 @@ const MultiSelectDropdown = class {
|
|
|
130
145
|
}, class: { selected: !!option.selected } }, h("label", { htmlFor: option.value }, h("input", { "aria-hidden": "true", id: option.value, type: "checkbox", checked: option.selected }), h("span", null, option.label))));
|
|
131
146
|
}
|
|
132
147
|
render() {
|
|
133
|
-
return (h(Host, { key: '
|
|
148
|
+
return (h(Host, { key: 'f8e72e38ce1323acd6ca5ada6c9b8e4a52fd5cd3' }, h("div", { key: 'acd2eead0fe45b85da48057a52d3f99337870795', class: "dropdown", part: "msd_dropdown" }, h("label", { key: 'c586999e4b30f366d6033bef3cbf1142040db8a3', class: "dropdown-label" }, this.label, h("slot", { key: '2817a8851a72bbabe9309c3da79e8ca25c1c461e', name: "label-icon", "aria-hidden": "true" })), h("button", { key: '588fd27317e0c73ad8a83ac18e826b62ab968128', name: this.name, part: `msd_dropdown-button ${this.error ? 'msd_dropdown-button--error' : ''}`, class: { dropbtn: true, open: this.isOpen, error: !!this.error }, onClick: () => this.toggleDropdown(), "aria-haspopup": "listbox", "aria-expanded": this.isOpen ? 'true' : 'false', "aria-label": this.name, onKeyDown: e => this.handleSelectButtonKeyDown(e) }, h("slot", { key: 'e6fc309a7ffb30921118e1cd1d1fb4aea321a0fb', name: "select-icon", "aria-hidden": "true" }), h("span", { key: '62a4abccd0100022f7e163410ffaf8fca8ebaefb', class: "selected-option", part: "msd_dropdown-button-selected-label" }, this.getSelectedOptions().length > 1 ? `Multiple options selected` : this.availableOptions.filter(o => o.selected)[0]?.label ?? this.availableOptions[0]?.label), h("span", { key: '1fff4fa8e566dcec2ac9e28bcededc41c7b42585', class: this.isOpen ? 'open' : 'closed', "aria-hidden": "true" }, h("chevron-icon", { key: '39b47d625b2e3e78f795e3853e8a4811842036de', width: "16", height: "16" }))), this.error ? h("span", { class: "error" }, this.error) : null, this.isOpen ? null : (h("div", { class: 'selected-options' }, this.getSelectedOptions().map(option => (h("span", { class: "selected-option" }, option.label, h("button", { key: option.label, onClick: () => this.selectOption(option) }, h("close-icon", null))))))), this.isOpen ? (h("div", { class: "dropdown-content", part: "msd_dropdown-content" }, h("ul", { tabindex: "-1", role: "listbox", "aria-label": this.name, "aria-multiselectable": true, "aria-activedescendant": this.ariaActivedescendant, onKeyDown: e => this.handleListboxKeydown(e) }, this.availableOptions.map(option => this.renderOption(option))))) : null)));
|
|
134
149
|
}
|
|
135
150
|
get el() { return getElement(this); }
|
|
151
|
+
static get watchers() { return {
|
|
152
|
+
"options": ["optionsChangedHandler"]
|
|
153
|
+
}; }
|
|
136
154
|
};
|
|
137
155
|
MultiSelectDropdown.style = multiSelectDropdownCss;
|
|
138
156
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"multi-select-dropdown.entry.esm.js","mappings":";;;AAAA,MAAM,sBAAsB,GAAG,oyFAAoyF;;MCctzF,mBAAmB;;;;;;uBAiBM,EAAE;qBAKb,EAAE;gCAMmB,IAAI,CAAC,OAAO;sBAI/B,KAAK;oCAIQ,EAAE;sCAMC,KAAK;;IAYhD,gBAAgB;QACd,KAAK,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;SACtC;KACF;IAED,kBAAkB;QAChB,KAAK,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,CAAC;QACrD,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAE9C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;YAC5D,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAEpB,IAAI,CAAC,sBAAsB,GAAG,KAAK,CAAC;SACrC;KACF;IAID,kBAAkB,CAAC,KAAiB;QAElC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC;QAGlC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,MAAM,EAAE;YACjC,IAAI,CAAC,MAAM,GAAG,KAAK,C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C,MAAM,EAAC,IAAI,GAAG,CAClC,CACA,EACR,IAAI,CAAC,KAAK,GAAG,YAAM,KAAK,EAAC,OAAO,IAAE,IAAI,CAAC,KAAK,CAAQ,GAAG,IAAI,EAC3D,IAAI,CAAC,MAAM,GAAG,IAAI,IACjB,WAAK,KAAK,EAAE,kBAAkB,IAC3B,IAAI,CAAC,kBAAkB,EAAE,CAAC,GAAG,CAAC,MAAM,KACnC,YAAM,KAAK,EAAC,iBAAiB,IAC1B,MAAM,CAAC,KAAK,EACb,cAAQ,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IACjE,qBAAc,CACP,CACJ,CACR,CAAC,CACE,CACP,EACA,IAAI,CAAC,MAAM,IACV,WAAK,KAAK,EAAC,kBAAkB,EAAC,IAAI,EAAC,sBAAsB,IACvD,UACE,QAAQ,EAAC,IAAI,EACb,IAAI,EAAC,SAAS,gBACF,IAAI,CAAC,IAAI,0BACC,IAAI,2BACH,IAAI,CAAC,oBAAoB,EAChD,SAAS,EAAE,CAAC,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAE3C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAC5D,CACD,IACJ,IAAI,CACJ,CACD,EACP;KACH;;;;;;;","names":[],"sources":["src/components/design-system/multi-select-dropdown/multi-select-dropdown.scss?tag=multi-select-dropdown&encapsulation=shadow","src/components/design-system/multi-select-dropdown/multi-select-dropdown.tsx"],"sourcesContent":["@import '../../../common/styles/variables.scss';\n\n:host {\n display: block;\n width: inherit;\n @include default-css-variables;\n}\n\n.dropdown {\n display: inline-block;\n width: 100%;\n position: relative;\n\n .dropdown-label {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n color: var(--nylas-base-800);\n }\n\n span.error {\n color: var(--nylas-error);\n font-size: 14px;\n }\n}\n\n.dropbtn {\n width: inherit;\n height: 48px;\n color: black;\n padding: 0.5rem;\n font-size: 1rem;\n cursor: pointer;\n display: flex;\n gap: 0.5rem;\n justify-content: space-between;\n align-items: center;\n background: transparent;\n border: 1px solid var(--nylas-base-200);\n border-radius: var(--nylas-border-radius-2x);\n\n &.focus {\n background: transparent;\n }\n\n &.error {\n border: 1px solid var(--nylas-error);\n }\n\n &:hover,\n &:active {\n border: 1px solid var(--nylas-primary);\n }\n\n &:active {\n outline: 2px solid var(--nylas-primary);\n }\n\n span {\n &.open {\n transform: rotate(90deg);\n }\n\n &.closed {\n transform: rotate(270deg);\n }\n }\n}\n\n.dropdown-content {\n display: block;\n margin-top: 0.5rem;\n background-color: var(--nylas-base-0);\n width: 100%;\n max-height: 336px;\n overflow: auto;\n z-index: 1;\n border-radius: 4px;\n position: absolute;\n top: calc(48px + 24px);\n box-shadow: 0px 4px 6px -2px #0000000d;\n box-shadow: 0px 10px 15px -3px #0000001a;\n}\n\n.dropdown-content ul {\n padding: 0;\n list-style-type: none;\n color: var(--nylas-base-900);\n max-height: 336px;\n\n li {\n padding: 16px, 12px, 16px, 12px;\n color: black;\n padding: 12px 16px;\n text-decoration: none;\n display: block;\n font-family: inherit;\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n letter-spacing: 0px;\n text-align: left;\n cursor: pointer;\n\n &:hover,\n &:focus {\n background-color: var(--nylas-base-100);\n }\n\n label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n\n input {\n margin: 0;\n }\n }\n }\n}\n\n.selected-options {\n display: flex;\n flex-wrap: wrap;\n gap: 0.5rem;\n padding: 0.5rem 0;\n margin-top: 0.25rem;\n background: var(--nylas-base-0);\n\n .selected-option {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 4px 8px;\n border-radius: var(--nylas-border-radius-2x);\n background: var(--nylas-base-100);\n color: var(--nylas-base-800);\n font-size: 16px;\n font-weight: 500;\n line-height: 1.5rem;\n letter-spacing: 0.5px;\n\n button {\n background: transparent;\n border: none;\n cursor: pointer;\n padding: 0;\n\n &:hover {\n color: var(--nylas-primary);\n }\n }\n }\n}\n","import { debug } from '@/utils/utils';\nimport { Component, Element, Event, EventEmitter, Host, Listen, Prop, State, h } from '@stencil/core';\n\ninterface DropdownOption {\n label: string;\n value: string;\n selected?: boolean; // Add a selected flag to each option\n}\n\n@Component({\n tag: 'multi-select-dropdown',\n styleUrl: 'multi-select-dropdown.scss',\n shadow: true,\n})\nexport class MultiSelectDropdown {\n @Element() el!: HTMLElement;\n\n // Props\n /**\n * The name of the dropdown\n */\n @Prop() name!: string;\n\n /**\n * The label of the dropdown\n */\n @Prop() label?: string;\n\n /**\n * The options to display in the dropdown\n */\n @Prop() options: DropdownOption[] = [];\n\n /**\n * Error message to display\n */\n @Prop() error?: string = '';\n\n // States\n /**\n * The copy of the options to display in the dropdown\n */\n @State() availableOptions: DropdownOption[] = this.options;\n /**\n * The open state of the dropdown\n */\n @State() isOpen: boolean = false;\n /**\n * The aria-activedescendant attribute for the listbox element to indicate the currently active\n */\n @State() ariaActivedescendant: string = '';\n\n /**\n * This flag is used to focus the first option when the dropdown is opened\n * and reset after the first option is focused\n */\n @State() shouldFocusFirstOption: boolean = false;\n\n // Events\n /**\n * This event is fired when the selected options are changed\n */\n @Event({ bubbles: true, composed: true }) selectedOptionsChanged!: EventEmitter<{\n value: string[];\n name: string;\n }>;\n\n // Lifecycle methods\n componentDidLoad() {\n debug('multi-select-dropdown', 'componentDidLoad');\n if (this.options) {\n this.availableOptions = this.options;\n }\n }\n\n componentDidRender() {\n debug('multi-select-dropdown', 'componentDidRender');\n if (this.isOpen && this.shouldFocusFirstOption) {\n // The dropdown is open and we should focus the first option\n this.ariaActivedescendant = this.availableOptions[0]?.value;\n this.focusOption(0);\n // Reset the flag\n this.shouldFocusFirstOption = false;\n }\n }\n\n // Event listeners\n @Listen('click', { target: 'document', capture: true })\n handleOutsideClick(event: MouseEvent) {\n // Get the path of the event\n const path = event.composedPath();\n\n // Check if the path includes the host element\n const isClickInside = path.includes(this.el);\n\n if (!isClickInside && this.isOpen) {\n this.isOpen = false;\n }\n }\n\n // Methods\n\n selectOption(option: DropdownOption): void {\n this.availableOptions = this.availableOptions.map(o => {\n if (o.value === option.value) {\n o.selected = option.selected ? false : true;\n }\n return o;\n });\n const selectedOptions = this.availableOptions.filter(o => o.selected).map(o => o.value);\n this.selectedOptionsChanged.emit({\n value: selectedOptions,\n name: this.name,\n });\n }\n\n toggleDropdown(): void {\n this.isOpen = !this.isOpen;\n if (this.isOpen) {\n this.shouldFocusFirstOption = true;\n } else {\n this.ariaActivedescendant = '';\n }\n }\n\n handleSelectButtonKeyDown(event: KeyboardEvent): void {\n switch (event.key) {\n case 'ArrowDown':\n case 'Enter':\n event.preventDefault();\n if (!this.isOpen) {\n this.toggleDropdown();\n }\n break;\n case 'Escape':\n this.isOpen = false;\n break;\n }\n }\n\n handleListboxKeydown(e: KeyboardEvent) {\n const items = this.availableOptions;\n const currentIndex = items.findIndex(item => item.value === this.ariaActivedescendant);\n\n switch (e.key) {\n case 'ArrowDown':\n case 'Tab':\n if (!e.shiftKey) {\n e.preventDefault();\n const nextIndex = currentIndex + 1 < items.length ? currentIndex + 1 : 0;\n this.ariaActivedescendant = items[nextIndex].value;\n this.focusOption(nextIndex);\n } else {\n e.preventDefault();\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : items.length - 1;\n this.ariaActivedescendant = items[prevIndex].value;\n this.focusOption(prevIndex);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : items.length - 1;\n this.ariaActivedescendant = items[prevIndex].value;\n this.focusOption(prevIndex);\n break;\n case 'Enter':\n e.preventDefault();\n if (this.ariaActivedescendant) {\n this.selectOption(items[currentIndex]);\n }\n break;\n case 'Escape':\n this.isOpen = false;\n break;\n }\n }\n\n focusOption(index: number) {\n const option = this.availableOptions[index];\n if (!option) return; // Guard clause in case index is out of bounds\n\n const elementId = option.value;\n const element = this.el.shadowRoot?.getElementById(elementId) as HTMLLIElement;\n\n if (element) {\n element.focus(); // Set focus on the element\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n }\n }\n\n getSelectedOptions() {\n return this.availableOptions.filter(option => option.selected);\n }\n\n renderOption(option: DropdownOption) {\n return (\n <li\n key={option.value}\n id={option.value}\n role=\"option\"\n tabindex=\"0\"\n aria-selected={option.selected ? 'true' : 'false'}\n onClick={e => {\n e.stopImmediatePropagation();\n this.selectOption(option);\n }}\n class={{ selected: !!option.selected }}\n >\n <label htmlFor={option.value}>\n <input aria-hidden=\"true\" id={option.value} type=\"checkbox\" checked={option.selected} />\n <span>{option.label}</span>\n </label>\n </li>\n );\n }\n\n render() {\n return (\n <Host>\n <div class=\"dropdown\" part=\"msd_dropdown\">\n <label class=\"dropdown-label\">\n {this.label}\n <slot name=\"label-icon\" aria-hidden=\"true\"></slot>\n </label>\n <button\n name={this.name}\n part={`msd_dropdown-button ${this.error ? 'msd_dropdown-button--error' : ''}`}\n class={{ dropbtn: true, open: this.isOpen, error: !!this.error }}\n onClick={() => this.toggleDropdown()}\n aria-haspopup=\"listbox\"\n aria-expanded={this.isOpen ? 'true' : 'false'}\n aria-label={this.name}\n onKeyDown={e => this.handleSelectButtonKeyDown(e)}\n >\n <slot name=\"select-icon\" aria-hidden=\"true\"></slot>\n <span class=\"selected-option\" part=\"msd_dropdown-button-selected-label\">\n {this.getSelectedOptions().length > 1 ? `Multiple options selected` : this.availableOptions.filter(o => o.selected)[0]?.label ?? this.availableOptions[0]?.label}\n </span>\n <span class={this.isOpen ? 'open' : 'closed'} aria-hidden=\"true\">\n <chevron-icon width=\"16\" height=\"16\" />\n </span>\n </button>\n {this.error ? <span class=\"error\">{this.error}</span> : null}\n {this.isOpen ? null : (\n <div class={'selected-options'}>\n {this.getSelectedOptions().map(option => (\n <span class=\"selected-option\">\n {option.label}\n <button key={option.label} onClick={() => this.selectOption(option)}>\n <close-icon />\n </button>\n </span>\n ))}\n </div>\n )}\n {this.isOpen ? (\n <div class=\"dropdown-content\" part=\"msd_dropdown-content\">\n <ul\n tabindex=\"-1\"\n role=\"listbox\"\n aria-label={this.name}\n aria-multiselectable={true}\n aria-activedescendant={this.ariaActivedescendant}\n onKeyDown={e => this.handleListboxKeydown(e)}\n >\n {this.availableOptions.map(option => this.renderOption(option))}\n </ul>\n </div>\n ) : null}\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"multi-select-dropdown.entry.esm.js","mappings":";;;AAAA,MAAM,sBAAsB,GAAG,oyFAAoyF;;MCctzF,mBAAmB;;;;;;uBAiBM,EAAE;qBAKb,EAAE;gCAMmB,IAAI,CAAC,OAAO;sBAI/B,KAAK;oCAIQ,EAAE;sCAMC,KAAK;;IAWhD,eAAe,CAAC,IAAsB,EAAE,IAAsB;QAC5D,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAG9C,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3G,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAG3G,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK;YAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,OAAO,IAAI,CAAC,KAAK,KAAK,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AAI,CAAC,kBAAkB,EAAE,CAAC,GAAG,CAAC,MAAM,KACnC,YAAM,KAAK,EAAC,iBAAiB,IAC1B,MAAM,CAAC,KAAK,EACb,cAAQ,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IACjE,qBAAc,CACP,CACJ,CACR,CAAC,CACE,CACP,EACA,IAAI,CAAC,MAAM,IACV,WAAK,KAAK,EAAC,kBAAkB,EAAC,IAAI,EAAC,sBAAsB,IACvD,UACE,QAAQ,EAAC,IAAI,EACb,IAAI,EAAC,SAAS,gBACF,IAAI,CAAC,IAAI,0BACC,IAAI,2BACH,IAAI,CAAC,oBAAoB,EAChD,SAAS,EAAE,CAAC,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAE3C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAC5D,CACD,IACJ,IAAI,CACJ,CACD,EACP;KACH;;;;;;;;;;","names":[],"sources":["src/components/design-system/multi-select-dropdown/multi-select-dropdown.scss?tag=multi-select-dropdown&encapsulation=shadow","src/components/design-system/multi-select-dropdown/multi-select-dropdown.tsx"],"sourcesContent":["@import '../../../common/styles/variables.scss';\n\n:host {\n display: block;\n width: inherit;\n @include default-css-variables;\n}\n\n.dropdown {\n display: inline-block;\n width: 100%;\n position: relative;\n\n .dropdown-label {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n color: var(--nylas-base-800);\n }\n\n span.error {\n color: var(--nylas-error);\n font-size: 14px;\n }\n}\n\n.dropbtn {\n width: inherit;\n height: 48px;\n color: black;\n padding: 0.5rem;\n font-size: 1rem;\n cursor: pointer;\n display: flex;\n gap: 0.5rem;\n justify-content: space-between;\n align-items: center;\n background: transparent;\n border: 1px solid var(--nylas-base-200);\n border-radius: var(--nylas-border-radius-2x);\n\n &.focus {\n background: transparent;\n }\n\n &.error {\n border: 1px solid var(--nylas-error);\n }\n\n &:hover,\n &:active {\n border: 1px solid var(--nylas-primary);\n }\n\n &:active {\n outline: 2px solid var(--nylas-primary);\n }\n\n span {\n &.open {\n transform: rotate(90deg);\n }\n\n &.closed {\n transform: rotate(270deg);\n }\n }\n}\n\n.dropdown-content {\n display: block;\n margin-top: 0.5rem;\n background-color: var(--nylas-base-0);\n width: 100%;\n max-height: 336px;\n overflow: auto;\n z-index: 1;\n border-radius: 4px;\n position: absolute;\n top: calc(48px + 24px);\n box-shadow: 0px 4px 6px -2px #0000000d;\n box-shadow: 0px 10px 15px -3px #0000001a;\n}\n\n.dropdown-content ul {\n padding: 0;\n list-style-type: none;\n color: var(--nylas-base-900);\n max-height: 336px;\n\n li {\n padding: 16px, 12px, 16px, 12px;\n color: black;\n padding: 12px 16px;\n text-decoration: none;\n display: block;\n font-family: inherit;\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n letter-spacing: 0px;\n text-align: left;\n cursor: pointer;\n\n &:hover,\n &:focus {\n background-color: var(--nylas-base-100);\n }\n\n label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n\n input {\n margin: 0;\n }\n }\n }\n}\n\n.selected-options {\n display: flex;\n flex-wrap: wrap;\n gap: 0.5rem;\n padding: 0.5rem 0;\n margin-top: 0.25rem;\n background: var(--nylas-base-0);\n\n .selected-option {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 4px 8px;\n border-radius: var(--nylas-border-radius-2x);\n background: var(--nylas-base-100);\n color: var(--nylas-base-800);\n font-size: 16px;\n font-weight: 500;\n line-height: 1.5rem;\n letter-spacing: 0.5px;\n\n button {\n background: transparent;\n border: none;\n cursor: pointer;\n padding: 0;\n\n &:hover {\n color: var(--nylas-primary);\n }\n }\n }\n}\n","import { debug } from '@/utils/utils';\nimport { Component, Element, Event, EventEmitter, Host, Listen, Prop, State, Watch, h } from '@stencil/core';\n\ninterface DropdownOption {\n label: string;\n value: string;\n selected?: boolean; // Add a selected flag to each option\n}\n\n@Component({\n tag: 'multi-select-dropdown',\n styleUrl: 'multi-select-dropdown.scss',\n shadow: true,\n})\nexport class MultiSelectDropdown {\n @Element() el!: HTMLElement;\n\n // Props\n /**\n * The name of the dropdown\n */\n @Prop() name!: string;\n\n /**\n * The label of the dropdown\n */\n @Prop() label?: string;\n\n /**\n * The options to display in the dropdown\n */\n @Prop() options: DropdownOption[] = [];\n\n /**\n * Error message to display\n */\n @Prop() error?: string = '';\n\n // States\n /**\n * The copy of the options to display in the dropdown\n */\n @State() availableOptions: DropdownOption[] = this.options;\n /**\n * The open state of the dropdown\n */\n @State() isOpen: boolean = false;\n /**\n * The aria-activedescendant attribute for the listbox element to indicate the currently active\n */\n @State() ariaActivedescendant: string = '';\n\n /**\n * This flag is used to focus the first option when the dropdown is opened\n * and reset after the first option is focused\n */\n @State() shouldFocusFirstOption: boolean = false;\n\n // Events\n /**\n * This event is fired when the selected options are changed\n */\n @Event({ bubbles: true, composed: true }) selectedOptionsChanged!: EventEmitter<{\n value: string[];\n name: string;\n }>;\n\n areOptionsEqual(arr1: DropdownOption[], arr2: DropdownOption[]): boolean {\n if (arr1.length !== arr2.length) return false;\n\n // Sort both arrays by a consistent key (e.g., label and value)\n const sorted1 = [...arr1].sort((a, b) => a.label.localeCompare(b.label) || a.value.localeCompare(b.value));\n const sorted2 = [...arr2].sort((a, b) => a.label.localeCompare(b.label) || a.value.localeCompare(b.value));\n\n // Compare each object in the sorted arrays\n return sorted1.every((opt1, index) => {\n const opt2 = sorted2[index];\n return opt1.label === opt2.label && opt1.value === opt2.value;\n });\n }\n\n @Watch('options')\n optionsChangedHandler(newValue: DropdownOption[]) {\n if (!this.areOptionsEqual(newValue, this.availableOptions)) {\n this.availableOptions = newValue;\n }\n }\n\n // Lifecycle methods\n componentDidLoad() {\n debug('multi-select-dropdown', 'componentDidLoad');\n if (this.options) {\n this.availableOptions = this.options;\n }\n }\n\n componentDidRender() {\n debug('multi-select-dropdown', 'componentDidRender');\n if (this.isOpen && this.shouldFocusFirstOption) {\n // The dropdown is open and we should focus the first option\n this.ariaActivedescendant = this.availableOptions[0]?.value;\n this.focusOption(0);\n // Reset the flag\n this.shouldFocusFirstOption = false;\n }\n }\n\n // Event listeners\n @Listen('click', { target: 'document', capture: true })\n handleOutsideClick(event: MouseEvent) {\n // Get the path of the event\n const path = event.composedPath();\n\n // Check if the path includes the host element\n const isClickInside = path.includes(this.el);\n\n if (!isClickInside && this.isOpen) {\n this.isOpen = false;\n }\n }\n\n // Methods\n\n selectOption(option: DropdownOption): void {\n this.availableOptions = this.availableOptions.map(o => {\n if (o.value === option.value) {\n o.selected = option.selected ? false : true;\n }\n return o;\n });\n const selectedOptions = this.availableOptions.filter(o => o.selected).map(o => o.value);\n this.selectedOptionsChanged.emit({\n value: selectedOptions,\n name: this.name,\n });\n }\n\n toggleDropdown(): void {\n this.isOpen = !this.isOpen;\n if (this.isOpen) {\n this.shouldFocusFirstOption = true;\n } else {\n this.ariaActivedescendant = '';\n }\n }\n\n handleSelectButtonKeyDown(event: KeyboardEvent): void {\n switch (event.key) {\n case 'ArrowDown':\n case 'Enter':\n event.preventDefault();\n if (!this.isOpen) {\n this.toggleDropdown();\n }\n break;\n case 'Escape':\n this.isOpen = false;\n break;\n }\n }\n\n handleListboxKeydown(e: KeyboardEvent) {\n const items = this.availableOptions;\n const currentIndex = items.findIndex(item => item.value === this.ariaActivedescendant);\n\n switch (e.key) {\n case 'ArrowDown':\n case 'Tab':\n if (!e.shiftKey) {\n e.preventDefault();\n const nextIndex = currentIndex + 1 < items.length ? currentIndex + 1 : 0;\n this.ariaActivedescendant = items[nextIndex].value;\n this.focusOption(nextIndex);\n } else {\n e.preventDefault();\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : items.length - 1;\n this.ariaActivedescendant = items[prevIndex].value;\n this.focusOption(prevIndex);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : items.length - 1;\n this.ariaActivedescendant = items[prevIndex].value;\n this.focusOption(prevIndex);\n break;\n case 'Enter':\n e.preventDefault();\n if (this.ariaActivedescendant) {\n this.selectOption(items[currentIndex]);\n }\n break;\n case 'Escape':\n this.isOpen = false;\n break;\n }\n }\n\n focusOption(index: number) {\n const option = this.availableOptions[index];\n if (!option) return; // Guard clause in case index is out of bounds\n\n const elementId = option.value;\n const element = this.el.shadowRoot?.getElementById(elementId) as HTMLLIElement;\n\n if (element) {\n element.focus(); // Set focus on the element\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n }\n }\n\n getSelectedOptions() {\n return this.availableOptions.filter(option => option.selected);\n }\n\n renderOption(option: DropdownOption) {\n return (\n <li\n key={option.value}\n id={option.value}\n role=\"option\"\n tabindex=\"0\"\n aria-selected={option.selected ? 'true' : 'false'}\n onClick={e => {\n e.stopImmediatePropagation();\n this.selectOption(option);\n }}\n class={{ selected: !!option.selected }}\n >\n <label htmlFor={option.value}>\n <input aria-hidden=\"true\" id={option.value} type=\"checkbox\" checked={option.selected} />\n <span>{option.label}</span>\n </label>\n </li>\n );\n }\n\n render() {\n return (\n <Host>\n <div class=\"dropdown\" part=\"msd_dropdown\">\n <label class=\"dropdown-label\">\n {this.label}\n <slot name=\"label-icon\" aria-hidden=\"true\"></slot>\n </label>\n <button\n name={this.name}\n part={`msd_dropdown-button ${this.error ? 'msd_dropdown-button--error' : ''}`}\n class={{ dropbtn: true, open: this.isOpen, error: !!this.error }}\n onClick={() => this.toggleDropdown()}\n aria-haspopup=\"listbox\"\n aria-expanded={this.isOpen ? 'true' : 'false'}\n aria-label={this.name}\n onKeyDown={e => this.handleSelectButtonKeyDown(e)}\n >\n <slot name=\"select-icon\" aria-hidden=\"true\"></slot>\n <span class=\"selected-option\" part=\"msd_dropdown-button-selected-label\">\n {this.getSelectedOptions().length > 1 ? `Multiple options selected` : this.availableOptions.filter(o => o.selected)[0]?.label ?? this.availableOptions[0]?.label}\n </span>\n <span class={this.isOpen ? 'open' : 'closed'} aria-hidden=\"true\">\n <chevron-icon width=\"16\" height=\"16\" />\n </span>\n </button>\n {this.error ? <span class=\"error\">{this.error}</span> : null}\n {this.isOpen ? null : (\n <div class={'selected-options'}>\n {this.getSelectedOptions().map(option => (\n <span class=\"selected-option\">\n {option.label}\n <button key={option.label} onClick={() => this.selectOption(option)}>\n <close-icon />\n </button>\n </span>\n ))}\n </div>\n )}\n {this.isOpen ? (\n <div class=\"dropdown-content\" part=\"msd_dropdown-content\">\n <ul\n tabindex=\"-1\"\n role=\"listbox\"\n aria-label={this.name}\n aria-multiselectable={true}\n aria-activedescendant={this.ariaActivedescendant}\n onKeyDown={e => this.handleListboxKeydown(e)}\n >\n {this.availableOptions.map(option => this.renderOption(option))}\n </ul>\n </div>\n ) : null}\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|