cronofy-elements 1.48.1 → 1.49.1
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/.gitkeep +0 -0
- package/dist/CronofyElements.js +2 -0
- package/{build/CronofyElements.v1.48.1.js.LICENSE.txt → dist/CronofyElements.js.LICENSE.txt} +0 -0
- package/package.json +10 -7
- package/.babelrc +0 -20
- package/.eslintrc.yaml +0 -43
- package/.prettierignore +0 -4
- package/.prettierrc +0 -7
- package/Makefile +0 -92
- package/brainstorm.md +0 -76
- package/build/CronofyElements.v1.48.1.js +0 -2
- package/build/npm/CronofyElements.js +0 -2
- package/compat.config.js +0 -25
- package/demo/agenda.ejs +0 -71
- package/demo/availability-viewer.ejs +0 -322
- package/demo/calendar-sync.ejs +0 -149
- package/demo/crossbrowser.ejs +0 -228
- package/demo/date-time-picker.ejs +0 -213
- package/demo/demo-styles.css +0 -134
- package/demo/index.ejs +0 -249
- package/demo/integration.ejs +0 -482
- package/demo/load-elements.ejs +0 -12
- package/demo/nav.ejs +0 -14
- package/demo/rules.ejs +0 -121
- package/demo/server.js +0 -425
- package/demo/slot-picker.ejs +0 -197
- package/git.README.md +0 -71
- package/notes.style.md +0 -197
- package/postcss.config.js +0 -3
- package/script/i18n-export +0 -11
- package/script/i18n-helpers/split_write.rb +0 -25
- package/script/i18n-import +0 -22
- package/script/i18n-reference-update +0 -241
- package/src/js/components/Agenda/Agenda.js +0 -243
- package/src/js/components/Agenda/AllDayEventsList.js +0 -37
- package/src/js/components/Agenda/Calendar.js +0 -100
- package/src/js/components/Agenda/CalendarHeader.js +0 -187
- package/src/js/components/Agenda/Event.js +0 -34
- package/src/js/components/Agenda/EventAllDay.js +0 -76
- package/src/js/components/Agenda/EventAttendees.js +0 -30
- package/src/js/components/Agenda/EventDetail.js +0 -111
- package/src/js/components/Agenda/EventMessages.js +0 -24
- package/src/js/components/Agenda/EventMeta.js +0 -48
- package/src/js/components/Agenda/EventTime.js +0 -34
- package/src/js/components/Agenda/EventWrapper.js +0 -271
- package/src/js/components/Agenda/Location.js +0 -29
- package/src/js/components/Agenda/Message.js +0 -22
- package/src/js/components/Agenda/TimedEventsList.js +0 -29
- package/src/js/components/AvailabilityRules/AddButton.js +0 -60
- package/src/js/components/AvailabilityRules/AvailabilityRules.js +0 -45
- package/src/js/components/AvailabilityRules/Calendar.js +0 -31
- package/src/js/components/AvailabilityRules/CalendarListItem.js +0 -53
- package/src/js/components/AvailabilityRules/CalendarProfiles.js +0 -67
- package/src/js/components/AvailabilityRules/CalendarSelector.js +0 -104
- package/src/js/components/AvailabilityRules/Calendars.js +0 -145
- package/src/js/components/AvailabilityRules/Checkmark.js +0 -51
- package/src/js/components/AvailabilityRules/DayLabels.js +0 -91
- package/src/js/components/AvailabilityRules/Footer.js +0 -109
- package/src/js/components/AvailabilityRules/Legend.js +0 -57
- package/src/js/components/AvailabilityRules/Loading.js +0 -53
- package/src/js/components/AvailabilityRules/RemoveButton.js +0 -57
- package/src/js/components/AvailabilityRules/Slot.js +0 -195
- package/src/js/components/AvailabilityRules/SlotDisplay.js +0 -27
- package/src/js/components/AvailabilityRules/Slots.js +0 -81
- package/src/js/components/AvailabilityRules/SlotsDisplay.js +0 -68
- package/src/js/components/AvailabilityRules/TimeExpander.js +0 -119
- package/src/js/components/AvailabilityRules/TimeLabels.js +0 -89
- package/src/js/components/AvailabilityRules/TimeZoneDisplay.js +0 -41
- package/src/js/components/AvailabilityRules/ToggleIcon.js +0 -41
- package/src/js/components/AvailabilityRules/Tooltip.js +0 -63
- package/src/js/components/AvailabilityRules/UnknownCalendar.js +0 -33
- package/src/js/components/AvailabilityRules/Week.js +0 -115
- package/src/js/components/AvailabilityRules/WeekGrid.js +0 -80
- package/src/js/components/AvailabilityRules/Wrapper.js +0 -414
- package/src/js/components/AvailabilityRules/contexts/drag-context.js +0 -15
- package/src/js/components/AvailabilityRules/scss/_base.buttons.scss +0 -58
- package/src/js/components/AvailabilityRules/scss/_base.theme.scss +0 -4
- package/src/js/components/AvailabilityRules/scss/_components.timezoneselector.scss +0 -74
- package/src/js/components/AvailabilityRules/scss/_generic.reset.scss +0 -13
- package/src/js/components/AvailabilityRules/scss/_settings.colours.scss +0 -12
- package/src/js/components/AvailabilityRules/scss/availabilityrules.scss +0 -5
- package/src/js/components/AvailabilityRules/utils/tz-utils.js +0 -44
- package/src/js/components/AvailabilityViewer/AvailabilityViewer.js +0 -524
- package/src/js/components/AvailabilityViewer/ColumnHeader.js +0 -35
- package/src/js/components/AvailabilityViewer/DayColumn.js +0 -36
- package/src/js/components/AvailabilityViewer/DayColumnDisplay.js +0 -33
- package/src/js/components/AvailabilityViewer/DayColumnWrapper.js +0 -29
- package/src/js/components/AvailabilityViewer/DayLabels.js +0 -41
- package/src/js/components/AvailabilityViewer/EmptyColumn.js +0 -29
- package/src/js/components/AvailabilityViewer/Footer.js +0 -36
- package/src/js/components/AvailabilityViewer/GridFreeSelect.js +0 -33
- package/src/js/components/AvailabilityViewer/HoverSlot.js +0 -35
- package/src/js/components/AvailabilityViewer/HoverTooltip.js +0 -34
- package/src/js/components/AvailabilityViewer/LabelColumn.js +0 -53
- package/src/js/components/AvailabilityViewer/LabelItem.js +0 -73
- package/src/js/components/AvailabilityViewer/Legend.js +0 -79
- package/src/js/components/AvailabilityViewer/Loading.js +0 -57
- package/src/js/components/AvailabilityViewer/MonthLabels.js +0 -43
- package/src/js/components/AvailabilityViewer/Navigation.js +0 -138
- package/src/js/components/AvailabilityViewer/Overlay.js +0 -60
- package/src/js/components/AvailabilityViewer/Preloading.js +0 -66
- package/src/js/components/AvailabilityViewer/SelectedSlot.js +0 -106
- package/src/js/components/AvailabilityViewer/SelectedSlots.js +0 -72
- package/src/js/components/AvailabilityViewer/SelectionMask.js +0 -44
- package/src/js/components/AvailabilityViewer/Slot.js +0 -237
- package/src/js/components/AvailabilityViewer/SlotFreeSelect.js +0 -115
- package/src/js/components/AvailabilityViewer/Slots.js +0 -57
- package/src/js/components/AvailabilityViewer/TimeExpander.js +0 -93
- package/src/js/components/AvailabilityViewer/TimeLines.js +0 -74
- package/src/js/components/AvailabilityViewer/TimeSelector.js +0 -243
- package/src/js/components/AvailabilityViewer/TimeSelectorTrigger.js +0 -42
- package/src/js/components/AvailabilityViewer/TimeZoneDisplay.js +0 -28
- package/src/js/components/AvailabilityViewer/ToggleIcon.js +0 -41
- package/src/js/components/AvailabilityViewer/Tooltip.js +0 -65
- package/src/js/components/AvailabilityViewer/Week.js +0 -255
- package/src/js/components/AvailabilityViewer/WeekWrapper.js +0 -132
- package/src/js/components/AvailabilityViewer/contexts/page-context.js +0 -17
- package/src/js/components/AvailabilityViewer/contexts/page-reducer.js +0 -28
- package/src/js/components/AvailabilityViewer/contexts/selection-context.js +0 -25
- package/src/js/components/AvailabilityViewer/contexts/selection-reducer.js +0 -18
- package/src/js/components/CalendarSync/Active.js +0 -57
- package/src/js/components/CalendarSync/AddToggle.js +0 -72
- package/src/js/components/CalendarSync/CalendarSync.js +0 -215
- package/src/js/components/CalendarSync/EditToggle.js +0 -71
- package/src/js/components/CalendarSync/Footer.js +0 -31
- package/src/js/components/CalendarSync/Inactive.js +0 -66
- package/src/js/components/CalendarSync/Loading.js +0 -52
- package/src/js/components/CalendarSync/Pending.js +0 -74
- package/src/js/components/CalendarSync/ProfileStatus.js +0 -33
- package/src/js/components/CalendarSync/Profiles.js +0 -109
- package/src/js/components/CalendarSync/ProviderLogo.js +0 -28
- package/src/js/components/CalendarSync/Providers.js +0 -80
- package/src/js/components/CalendarSync/RemoveLink.js +0 -96
- package/src/js/components/CalendarSync/SelectProvider.js +0 -25
- package/src/js/components/CalendarSync/contexts/status-reducer.js +0 -74
- package/src/js/components/DateTimePicker/Calendar.js +0 -127
- package/src/js/components/DateTimePicker/CalendarHeader.js +0 -80
- package/src/js/components/DateTimePicker/Confirm.js +0 -106
- package/src/js/components/DateTimePicker/DateTimePicker.js +0 -131
- package/src/js/components/DateTimePicker/DayButton.js +0 -38
- package/src/js/components/DateTimePicker/DayHeadings.js +0 -33
- package/src/js/components/DateTimePicker/Details.js +0 -33
- package/src/js/components/DateTimePicker/Error.js +0 -39
- package/src/js/components/DateTimePicker/Loading.js +0 -20
- package/src/js/components/DateTimePicker/LoadingCalendar.js +0 -21
- package/src/js/components/DateTimePicker/NoSlotsFound.js +0 -16
- package/src/js/components/DateTimePicker/SequencedSlotButton.js +0 -97
- package/src/js/components/DateTimePicker/SlotButton.js +0 -55
- package/src/js/components/DateTimePicker/SlotsList.js +0 -45
- package/src/js/components/DateTimePicker/Wrapper.js +0 -281
- package/src/js/components/DateTimePicker/contexts/status-context.js +0 -19
- package/src/js/components/DateTimePicker/contexts/status-reducer.js +0 -276
- package/src/js/components/DateTimePicker/contexts/theme-context.js +0 -33
- package/src/js/components/DateTimePicker/helpers/theming.js +0 -49
- package/src/js/components/DateTimePicker/scss/_base.buttons.scss +0 -58
- package/src/js/components/DateTimePicker/scss/_base.layout.scss +0 -28
- package/src/js/components/DateTimePicker/scss/_base.theme.scss +0 -17
- package/src/js/components/DateTimePicker/scss/_components.calendargrid.scss +0 -78
- package/src/js/components/DateTimePicker/scss/_components.calendarheader.scss +0 -71
- package/src/js/components/DateTimePicker/scss/_components.confirm.scss +0 -40
- package/src/js/components/DateTimePicker/scss/_components.details.scss +0 -20
- package/src/js/components/DateTimePicker/scss/_components.error.scss +0 -34
- package/src/js/components/DateTimePicker/scss/_components.loading.scss +0 -36
- package/src/js/components/DateTimePicker/scss/_components.slotslist.scss +0 -43
- package/src/js/components/DateTimePicker/scss/_components.timezoneselector.scss +0 -73
- package/src/js/components/DateTimePicker/scss/_generic.reset.scss +0 -18
- package/src/js/components/DateTimePicker/scss/_settings.colours.scss +0 -17
- package/src/js/components/DateTimePicker/scss/datetimepicker.scss +0 -5
- package/src/js/components/DateTimePicker/utils/calendar-keyboard.js +0 -109
- package/src/js/components/DateTimePicker/utils/calendar.js +0 -125
- package/src/js/components/DateTimePicker/utils/slots.js +0 -288
- package/src/js/components/SlotPicker/Confirm.js +0 -160
- package/src/js/components/SlotPicker/Days.js +0 -58
- package/src/js/components/SlotPicker/Slot.js +0 -72
- package/src/js/components/SlotPicker/SlotPicker.js +0 -292
- package/src/js/components/SlotPicker/Slots.js +0 -66
- package/src/js/components/SlotPicker/TimeSlots.js +0 -91
- package/src/js/components/generic/Button.js +0 -26
- package/src/js/components/generic/Container.js +0 -33
- package/src/js/components/generic/Error.js +0 -77
- package/src/js/components/generic/Loading.js +0 -51
- package/src/js/components/generic/LoadingSpinner.js +0 -30
- package/src/js/components/generic/ShadowScrollbars.js +0 -70
- package/src/js/components/generic/TimeZoneSelector.js +0 -158
- package/src/js/components/generic/TransitionSlide.js +0 -72
- package/src/js/contexts/i18n-context.js +0 -25
- package/src/js/contexts/log-context.js +0 -18
- package/src/js/contexts/tz-context.js +0 -18
- package/src/js/env.example.js +0 -8
- package/src/js/helpers/colors.js +0 -33
- package/src/js/helpers/comparators.AvailabilityViewer.js +0 -27
- package/src/js/helpers/connections.js +0 -370
- package/src/js/helpers/events.js +0 -166
- package/src/js/helpers/functional.js +0 -4
- package/src/js/helpers/generator.js +0 -107
- package/src/js/helpers/i18n.js +0 -153
- package/src/js/helpers/init.Agenda.js +0 -55
- package/src/js/helpers/init.AvailabilityRules.js +0 -195
- package/src/js/helpers/init.AvailabilityViewer.js +0 -215
- package/src/js/helpers/init.CalendarSync.js +0 -83
- package/src/js/helpers/init.DateTimePicker.js +0 -219
- package/src/js/helpers/init.SlotPicker.js +0 -89
- package/src/js/helpers/init.js +0 -308
- package/src/js/helpers/logging.js +0 -78
- package/src/js/helpers/mocks.js +0 -871
- package/src/js/helpers/slots.js +0 -340
- package/src/js/helpers/slots.rules.js +0 -220
- package/src/js/helpers/theming.js +0 -93
- package/src/js/helpers/translations.js +0 -42
- package/src/js/helpers/tz-list.js +0 -136
- package/src/js/helpers/utils.AvailabilityRules.js +0 -110
- package/src/js/helpers/utils.AvailabilityViewer.js +0 -789
- package/src/js/helpers/utils.CalendarSync.js +0 -199
- package/src/js/helpers/utils.js +0 -76
- package/src/js/hooks/useWindowSize.js +0 -20
- package/src/js/main.js +0 -133
- package/src/js/next.js +0 -37
- package/src/js/styles/_settings.utils.scss +0 -82
- package/src/js/styles/colors.js +0 -13
- package/src/js/styles/global.js +0 -49
- package/src/js/styles/utils.js +0 -81
- package/src/js/translations/de/agenda.json +0 -12
- package/src/js/translations/de/availability_rules.json +0 -18
- package/src/js/translations/de/availability_viewer.json +0 -14
- package/src/js/translations/de/calendar_sync.json +0 -14
- package/src/js/translations/de/core.json +0 -15
- package/src/js/translations/de/date_time_picker.json +0 -14
- package/src/js/translations/de/slot_picker.json +0 -9
- package/src/js/translations/de/time_zones.json +0 -135
- package/src/js/translations/en/agenda.json +0 -12
- package/src/js/translations/en/availability_rules.json +0 -18
- package/src/js/translations/en/availability_viewer.json +0 -14
- package/src/js/translations/en/calendar_sync.json +0 -14
- package/src/js/translations/en/core.json +0 -23
- package/src/js/translations/en/date_time_picker.json +0 -15
- package/src/js/translations/en/slot_picker.json +0 -9
- package/src/js/translations/en/time_zones.json +0 -17
- package/src/js/translations/es/agenda.json +0 -12
- package/src/js/translations/es/availability_rules.json +0 -18
- package/src/js/translations/es/availability_viewer.json +0 -14
- package/src/js/translations/es/calendar_sync.json +0 -14
- package/src/js/translations/es/core.json +0 -15
- package/src/js/translations/es/date_time_picker.json +0 -14
- package/src/js/translations/es/slot_picker.json +0 -9
- package/src/js/translations/es/time_zones.json +0 -203
- package/src/js/translations/fr/agenda.json +0 -12
- package/src/js/translations/fr/availability_rules.json +0 -18
- package/src/js/translations/fr/availability_viewer.json +0 -14
- package/src/js/translations/fr/calendar_sync.json +0 -14
- package/src/js/translations/fr/core.json +0 -15
- package/src/js/translations/fr/date_time_picker.json +0 -14
- package/src/js/translations/fr/slot_picker.json +0 -9
- package/src/js/translations/fr/time_zones.json +0 -161
- package/src/js/translations/fr-CA/agenda.json +0 -12
- package/src/js/translations/fr-CA/availability_rules.json +0 -18
- package/src/js/translations/fr-CA/availability_viewer.json +0 -14
- package/src/js/translations/fr-CA/calendar_sync.json +0 -14
- package/src/js/translations/fr-CA/core.json +0 -23
- package/src/js/translations/fr-CA/date_time_picker.json +0 -14
- package/src/js/translations/fr-CA/slot_picker.json +0 -9
- package/src/js/translations/fr-CA/time_zones.json +0 -163
- package/src/js/translations/it/agenda.json +0 -12
- package/src/js/translations/it/availability_rules.json +0 -18
- package/src/js/translations/it/availability_viewer.json +0 -14
- package/src/js/translations/it/calendar_sync.json +0 -14
- package/src/js/translations/it/core.json +0 -15
- package/src/js/translations/it/date_time_picker.json +0 -14
- package/src/js/translations/it/slot_picker.json +0 -9
- package/src/js/translations/it/time_zones.json +0 -126
- package/src/js/translations/ja/agenda.json +0 -12
- package/src/js/translations/ja/availability_rules.json +0 -18
- package/src/js/translations/ja/availability_viewer.json +0 -14
- package/src/js/translations/ja/calendar_sync.json +0 -14
- package/src/js/translations/ja/core.json +0 -15
- package/src/js/translations/ja/date_formats.json +0 -5
- package/src/js/translations/ja/date_time_picker.json +0 -14
- package/src/js/translations/ja/slot_picker.json +0 -9
- package/src/js/translations/ja/time_zones.json +0 -435
- package/src/js/translations/nl/agenda.json +0 -12
- package/src/js/translations/nl/availability_rules.json +0 -18
- package/src/js/translations/nl/availability_viewer.json +0 -14
- package/src/js/translations/nl/calendar_sync.json +0 -14
- package/src/js/translations/nl/core.json +0 -15
- package/src/js/translations/nl/date_time_picker.json +0 -14
- package/src/js/translations/nl/slot_picker.json +0 -9
- package/src/js/translations/nl/time_zones.json +0 -118
- package/src/js/translations/ru/agenda.json +0 -12
- package/src/js/translations/ru/availability_rules.json +0 -18
- package/src/js/translations/ru/availability_viewer.json +0 -14
- package/src/js/translations/ru/calendar_sync.json +0 -14
- package/src/js/translations/ru/core.json +0 -15
- package/src/js/translations/ru/date_time_picker.json +0 -14
- package/src/js/translations/ru/slot_picker.json +0 -9
- package/src/js/translations/ru/time_zones.json +0 -435
- package/src/js/translations/sv/agenda.json +0 -12
- package/src/js/translations/sv/availability_rules.json +0 -18
- package/src/js/translations/sv/availability_viewer.json +0 -14
- package/src/js/translations/sv/calendar_sync.json +0 -14
- package/src/js/translations/sv/core.json +0 -15
- package/src/js/translations/sv/date_time_picker.json +0 -14
- package/src/js/translations/sv/slot_picker.json +0 -9
- package/src/js/translations/sv/time_zones.json +0 -136
- package/tests/AvailabilityRules/AvailabilityRules.test.js +0 -39
- package/tests/AvailabilityRules/__snapshots__/AvailabilityRules.test.js.snap +0 -1045
- package/tests/AvailabilityViewer/Navigation.test.js +0 -130
- package/tests/AvailabilityViewer/contexts/page-reducer.test.js +0 -87
- package/tests/AvailabilityViewer/reducer.test.js +0 -73
- package/tests/CalendarSync/Active.test.js +0 -25
- package/tests/CalendarSync/AddToggle.test.js +0 -57
- package/tests/CalendarSync/EditToggle.test.js +0 -57
- package/tests/CalendarSync/Inactive.test.js +0 -26
- package/tests/CalendarSync/Pending.test.js +0 -25
- package/tests/CalendarSync/ProviderLogo.test.js +0 -95
- package/tests/CalendarSync/__snapshots__/Active.test.js.snap +0 -61
- package/tests/CalendarSync/__snapshots__/Inactive.test.js.snap +0 -78
- package/tests/CalendarSync/__snapshots__/Pending.test.js.snap +0 -90
- package/tests/CalendarSync/__snapshots__/ProviderLogo.test.js.snap +0 -267
- package/tests/CalendarSync/init.CalendarSync.test.js +0 -302
- package/tests/CalendarSync/mocks/theme.js +0 -14
- package/tests/CalendarSync/status-reducer.test.js +0 -435
- package/tests/DateTimePicker/SequencedSlotButton.test.js +0 -157
- package/tests/DateTimePicker/SlotButton.test.js +0 -118
- package/tests/DateTimePicker/contexts/status-reducer.test.js +0 -1036
- package/tests/DateTimePicker/dummy-data.js +0 -883
- package/tests/DateTimePicker/utils.test.js +0 -515
- package/tests/colors.test.js +0 -70
- package/tests/components/TimezoneSelector.test.js +0 -124
- package/tests/components/main.test.js +0 -203
- package/tests/components/rtl-utils.js +0 -32
- package/tests/connections.test.js +0 -684
- package/tests/events.test.js +0 -472
- package/tests/generator.test.js +0 -74
- package/tests/i18n.test.js +0 -255
- package/tests/init.Agenda.test.js +0 -122
- package/tests/init.AvailabilityRules.test.js +0 -279
- package/tests/init.AvailabilityViewer.test.js +0 -740
- package/tests/init.SlotPicker.test.js +0 -166
- package/tests/init.test.js +0 -231
- package/tests/logging.test.js +0 -235
- package/tests/mocks/i18n.js +0 -3
- package/tests/mocks/theme.js +0 -3
- package/tests/setupJest.js +0 -8
- package/tests/slots.rules.test.js +0 -195
- package/tests/slots.test.js +0 -278
- package/tests/utils.AvailabilityRules.test.js +0 -221
- package/tests/utils.AvailabilityViewer.test.js +0 -1800
- package/tests/utils.CalendarSync.test.js +0 -277
- package/tests/utils.test.js +0 -119
- package/webpack.config.js +0 -114
package/src/js/helpers/i18n.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { turnSlugIntoString, humanizeTzName, nestedValue } from "./utils";
|
|
2
|
-
import { translations } from "./translations";
|
|
3
|
-
import moment from "moment";
|
|
4
|
-
|
|
5
|
-
export const getNavigatorLanguage = (nav = navigator) =>
|
|
6
|
-
nav.languages && nav.languages.length
|
|
7
|
-
? nav.languages[0]
|
|
8
|
-
: nav.userLanguage || nav.language || nav.browserLanguage || "en";
|
|
9
|
-
|
|
10
|
-
const rootLocaleFromLocale = locale =>
|
|
11
|
-
locale.indexOf("-") > 0 ? locale.substr(0, locale.indexOf("-")) : locale;
|
|
12
|
-
|
|
13
|
-
export const modifierDateFormats = {
|
|
14
|
-
ja: {
|
|
15
|
-
dates: {
|
|
16
|
-
western: { slotFormat: "Y年 MMM Do (dd)" },
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const i18n = (
|
|
22
|
-
context = "core",
|
|
23
|
-
phrase,
|
|
24
|
-
locale = getNavigatorLanguage(),
|
|
25
|
-
allPhrases = translations
|
|
26
|
-
) => {
|
|
27
|
-
// Handle "keys" mode
|
|
28
|
-
if (locale === "keys") {
|
|
29
|
-
return `${context}.${phrase}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// get the root locale if using a dialect
|
|
33
|
-
const rootLocale = rootLocaleFromLocale(locale);
|
|
34
|
-
|
|
35
|
-
// 1. Pre-check fallbacks
|
|
36
|
-
// ...we don't have the provided context or locale.
|
|
37
|
-
|
|
38
|
-
if (typeof allPhrases[locale] === "undefined") {
|
|
39
|
-
//First check if phrase exists in rootLocale
|
|
40
|
-
if (typeof allPhrases[rootLocale] !== "undefined") {
|
|
41
|
-
//Fallback to rootLocale if it does
|
|
42
|
-
locale = rootLocale;
|
|
43
|
-
} else {
|
|
44
|
-
// Fallback to base locale if not
|
|
45
|
-
locale = "en";
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof allPhrases[locale][context] === "undefined" && context === "date_formats") {
|
|
50
|
-
// Fallback to the format in the 'en' date formats
|
|
51
|
-
return allPhrases["en"][context][phrase];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (typeof allPhrases[locale][context] === "undefined") {
|
|
55
|
-
//First check if context exists in the rootLocale
|
|
56
|
-
if (typeof allPhrases[rootLocale][context] !== "undefined") {
|
|
57
|
-
//Fallback to rootLocale if it does
|
|
58
|
-
locale = rootLocale;
|
|
59
|
-
} else {
|
|
60
|
-
// Fallback to base context if it doesn't
|
|
61
|
-
context = "core";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (typeof allPhrases[locale][context][phrase] !== "undefined") {
|
|
66
|
-
// Happy path:
|
|
67
|
-
return allPhrases[locale][context][phrase];
|
|
68
|
-
} else if (typeof allPhrases[locale]["core"][phrase] !== "undefined") {
|
|
69
|
-
// Check the phrase with our base context:
|
|
70
|
-
return allPhrases[locale]["core"][phrase];
|
|
71
|
-
} else if (typeof allPhrases["en"]["core"][phrase] !== "undefined") {
|
|
72
|
-
// Check the phrase with our base context and default locale:
|
|
73
|
-
return allPhrases["en"]["core"][phrase];
|
|
74
|
-
} else {
|
|
75
|
-
// Nothing has worked, so let's return a string to
|
|
76
|
-
// highlight the error but not break the app.
|
|
77
|
-
console.warn(
|
|
78
|
-
`Missing translation. slug: ${phrase}, context: ${context}, locale: ${locale}`
|
|
79
|
-
);
|
|
80
|
-
return turnSlugIntoString(phrase);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const tzi18n = (tzid, locale = getNavigatorLanguage(), exceptions = translations) => {
|
|
85
|
-
// console.log("timezones", timezones);
|
|
86
|
-
// Parse the locale (if it's one we want to normalize)
|
|
87
|
-
locale = locale === "en-US" ? "en" : locale;
|
|
88
|
-
|
|
89
|
-
// 1. Pre-check fallbacks
|
|
90
|
-
// ...we don't have the provided locale.
|
|
91
|
-
|
|
92
|
-
if (typeof exceptions[locale] === "undefined") {
|
|
93
|
-
// Fallback to base locale
|
|
94
|
-
locale = "en";
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (typeof exceptions[locale].time_zones === "undefined") {
|
|
98
|
-
// Fallback to base locale
|
|
99
|
-
locale = "en";
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (typeof exceptions[locale].time_zones[tzid] !== "undefined") {
|
|
103
|
-
// There is an exception:
|
|
104
|
-
return exceptions[locale].time_zones[tzid];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// If we get here, the tzid string doesn't match any exceptions,
|
|
108
|
-
// so we'll infer the visually-acceptable version.
|
|
109
|
-
return humanizeTzName(tzid);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const i18nConstructor = ({
|
|
113
|
-
context = "core",
|
|
114
|
-
locale = getNavigatorLanguage(),
|
|
115
|
-
localeModifiers = {},
|
|
116
|
-
allPhrases = translations,
|
|
117
|
-
tzid,
|
|
118
|
-
}) => {
|
|
119
|
-
const slotFormatString = () => {
|
|
120
|
-
let slotFormat = "dddd Do MMMM";
|
|
121
|
-
|
|
122
|
-
const configVariant = nestedValue([locale, "dates"], localeModifiers);
|
|
123
|
-
if (configVariant) {
|
|
124
|
-
const overrideFormat = nestedValue(
|
|
125
|
-
[locale, "dates", configVariant, "slotFormat"],
|
|
126
|
-
modifierDateFormats
|
|
127
|
-
);
|
|
128
|
-
if (overrideFormat) slotFormat = overrideFormat;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return slotFormat;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const formatDateString = (dateString, formatString) =>
|
|
135
|
-
moment(dateString).tz(tzid).locale(locale).format(formatString);
|
|
136
|
-
|
|
137
|
-
const dateToSlotStringWithoutTzShift = dateString =>
|
|
138
|
-
// TZ is not applied here as it is already shifted into local time
|
|
139
|
-
moment(dateString).locale(locale).format(slotFormatString());
|
|
140
|
-
|
|
141
|
-
const timeToSlotString = dateString => formatDateString(dateString, "LT").replace(" ", "");
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
t: slug => i18n(context, slug, locale, allPhrases),
|
|
145
|
-
f: (momentObject, formatString) => momentObject.locale(locale).format(formatString),
|
|
146
|
-
ftz: (momentObject, formatString) =>
|
|
147
|
-
momentObject.tz(tzid).locale(locale).format(formatString),
|
|
148
|
-
customFormatedTimeZone: (momentObject, ctz, formatString) =>
|
|
149
|
-
momentObject.tz(ctz).locale(locale).format(formatString),
|
|
150
|
-
dateToSlotStringWithoutTzShift,
|
|
151
|
-
timeToSlotString,
|
|
152
|
-
};
|
|
153
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { parseToken, parseTarget, parseConnectionDomains, parseTranslations } from "./init";
|
|
2
|
-
import { logConstructor } from "./logging";
|
|
3
|
-
|
|
4
|
-
export const parseAgendaOptions = (options = {}) => {
|
|
5
|
-
let config = typeof options.config === "undefined" ? {} : options.config;
|
|
6
|
-
const logs = typeof config.logs === "undefined" ? "warn" : config.logs;
|
|
7
|
-
const log = logConstructor(logs, "Agenda View", options.callback);
|
|
8
|
-
|
|
9
|
-
const demoMode = typeof options.demo === "undefined" ? false : options.demo;
|
|
10
|
-
if (demoMode) {
|
|
11
|
-
log.warn("You are running in demo mode. No API requests will be made");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const token = parseToken(options, "agenda-view", log);
|
|
15
|
-
if (!token && !demoMode) {
|
|
16
|
-
log.error(
|
|
17
|
-
"You need to include an `element_token`. If you're just testing (and don't want to use real API data) you can set the `demo` option to `true` to bypass the API connection and view dummy content."
|
|
18
|
-
);
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const target = parseTarget(options, "agenda", log);
|
|
23
|
-
|
|
24
|
-
const domains = parseConnectionDomains(
|
|
25
|
-
options.data_center,
|
|
26
|
-
options.api_domain,
|
|
27
|
-
options.app_domain
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const translations = parseTranslations(options.translations, "availability_rules");
|
|
31
|
-
|
|
32
|
-
const mode = typeof config.mode === "undefined" ? "default" : config.mode;
|
|
33
|
-
|
|
34
|
-
const validModes = ["default", "only_managed", "free_busy", "free_busy_managed"];
|
|
35
|
-
const validMode = validModes.includes(mode);
|
|
36
|
-
if (!validMode) {
|
|
37
|
-
log.error(`Please provide a valid \`config.mode\`. \`${mode}\` is not a supported value.`, {
|
|
38
|
-
docsSlug: "agenda-viewer/#config.mode",
|
|
39
|
-
});
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
delete options.target_id;
|
|
44
|
-
delete options.element_token;
|
|
45
|
-
delete options.translations;
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
...options,
|
|
49
|
-
config: { ...config, mode, logs },
|
|
50
|
-
target,
|
|
51
|
-
token,
|
|
52
|
-
domains,
|
|
53
|
-
translations,
|
|
54
|
-
};
|
|
55
|
-
};
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
parseConnectionDomains,
|
|
3
|
-
parseTarget,
|
|
4
|
-
parseTimezone,
|
|
5
|
-
parseToken,
|
|
6
|
-
parseTranslations,
|
|
7
|
-
} from "./init";
|
|
8
|
-
import { logConstructor } from "./logging";
|
|
9
|
-
import { default_availability_rules } from "./mocks";
|
|
10
|
-
import moment from "moment-timezone";
|
|
11
|
-
|
|
12
|
-
export const parseAvailabilityRulesOptions = (options = {}) => {
|
|
13
|
-
let config = typeof options.config === "undefined" ? {} : options.config;
|
|
14
|
-
const logs = typeof config.logs === "undefined" ? "warn" : config.logs;
|
|
15
|
-
const log = logConstructor(
|
|
16
|
-
logs,
|
|
17
|
-
"Availability Rules",
|
|
18
|
-
options.callback ? options.callback : false
|
|
19
|
-
);
|
|
20
|
-
const startDay =
|
|
21
|
-
typeof config.week_start_day === "undefined" ? "sunday" : config.week_start_day;
|
|
22
|
-
|
|
23
|
-
const validDays = [
|
|
24
|
-
"sunday",
|
|
25
|
-
"monday",
|
|
26
|
-
"tuesday",
|
|
27
|
-
"wednesday",
|
|
28
|
-
"thursday",
|
|
29
|
-
"friday",
|
|
30
|
-
"saturday",
|
|
31
|
-
];
|
|
32
|
-
const validStartDay = validDays.includes(startDay);
|
|
33
|
-
|
|
34
|
-
if (!validStartDay) {
|
|
35
|
-
log.error(
|
|
36
|
-
`Please provide a valid \`config.week_start_day\`. \`${startDay}\` is not a supported value.`,
|
|
37
|
-
{
|
|
38
|
-
docsSlug: "availability-viewer/#config.week_start_day",
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const defaultWeeklyPeriods =
|
|
45
|
-
typeof config.default_weekly_periods === "undefined"
|
|
46
|
-
? default_availability_rules
|
|
47
|
-
: config.default_weekly_periods;
|
|
48
|
-
|
|
49
|
-
const validateDefaultWeeklyPeriods = (default_weekly_periods, log) => {
|
|
50
|
-
if (!Array.isArray(default_weekly_periods)) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (default_weekly_periods.length < 1) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let errors = {};
|
|
59
|
-
default_weekly_periods.forEach((dwp, index) => {
|
|
60
|
-
if (
|
|
61
|
-
dwp === null ||
|
|
62
|
-
typeof dwp !== "object" ||
|
|
63
|
-
!("day" in dwp) ||
|
|
64
|
-
!("start_time" in dwp) ||
|
|
65
|
-
!("end_time" in dwp)
|
|
66
|
-
) {
|
|
67
|
-
errors[`default_weekly_period[${index}]`] = [
|
|
68
|
-
"default weekly period must be an object with day, start_time and end_time properties",
|
|
69
|
-
];
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let out = [];
|
|
74
|
-
|
|
75
|
-
if (!validDays.includes(dwp.day)) {
|
|
76
|
-
out.push(
|
|
77
|
-
"Please provide a valid day. '" + `${dwp.day}` + "' is not a supported value."
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!moment(dwp.start_time, "HH:mm", true).isValid()) {
|
|
82
|
-
out.push("start_time must be a valid time string");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!moment(dwp.end_time, "HH:mm", true).isValid()) {
|
|
86
|
-
out.push("end_time must be a valid time string");
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (dwp.start_time >= dwp.end_time) {
|
|
90
|
-
out.push("end must be after start");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (out.length > 0) errors[`default_weekly_period[${index}]`] = out;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
if (Object.keys(errors).length > 0) {
|
|
97
|
-
log.error("Some of the provided `default_weekly_periods` option have errors.", {
|
|
98
|
-
docsSlug: "availability-viewer/#default_weekly_periods",
|
|
99
|
-
errorObject: errors,
|
|
100
|
-
});
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
return true;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const validDefaultWeeklyPeriods = validateDefaultWeeklyPeriods(defaultWeeklyPeriods, log);
|
|
107
|
-
|
|
108
|
-
if (!validDefaultWeeklyPeriods) {
|
|
109
|
-
log.error("The provided default weekly periods are invalid");
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
options.error = false;
|
|
114
|
-
const demoMode = typeof options.demo === "undefined" ? false : options.demo;
|
|
115
|
-
if (demoMode) {
|
|
116
|
-
log.warn("You are running in demo mode. No API requests will be made");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const autoCreateRulesMode =
|
|
120
|
-
typeof config.auto_create_rules === "undefined" ? false : config.auto_create_rules;
|
|
121
|
-
|
|
122
|
-
const token = parseToken(options, "availability-rules", log);
|
|
123
|
-
if (!token && !demoMode) {
|
|
124
|
-
log.error(
|
|
125
|
-
"You need to include an `element_token`. If you're just testing (and don't want to use real API data) you can set the `demo` option to `true` to bypass the API connection and view dummy content."
|
|
126
|
-
);
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const target = parseTarget(options, "availability-rules", log);
|
|
131
|
-
|
|
132
|
-
if (typeof options.availability_rule_id === "undefined") {
|
|
133
|
-
// options.error = true;
|
|
134
|
-
log.warn(
|
|
135
|
-
'You have not defined an availability_rule_id, so "default" will be used instead. Full details can be found on the Cronofy Elements documention page: https://docs.cronofy.com/developers/ui-elements/'
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const translations = parseTranslations(options.translations, "availability_rules");
|
|
140
|
-
|
|
141
|
-
const tzid = parseTimezone(options.tzid, "availability-rules", log);
|
|
142
|
-
|
|
143
|
-
const keyboardSupportedValues = ["basic"];
|
|
144
|
-
|
|
145
|
-
const validateKeyBoardSupport = keyboard_support => {
|
|
146
|
-
const validKeyboardSupport = keyboardSupportedValues.includes(keyboard_support);
|
|
147
|
-
if (!validKeyboardSupport) {
|
|
148
|
-
log.error(
|
|
149
|
-
`Please provide a valid \`config.keyboard_support\`. \`${keyboard_support}\` is not a supported value.`,
|
|
150
|
-
{
|
|
151
|
-
docsSlug: "availability-rules/#config.keyboard_support",
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
return false;
|
|
155
|
-
} else {
|
|
156
|
-
return keyboard_support;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const keyboardSupport =
|
|
161
|
-
typeof config.keyboard_support === "undefined"
|
|
162
|
-
? false
|
|
163
|
-
: validateKeyBoardSupport(config.keyboard_support);
|
|
164
|
-
|
|
165
|
-
const domains = parseConnectionDomains(
|
|
166
|
-
options.data_center,
|
|
167
|
-
options.api_domain,
|
|
168
|
-
options.app_domain
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
delete options.target_id;
|
|
172
|
-
delete options.element_token;
|
|
173
|
-
delete options.translations;
|
|
174
|
-
delete config.week_start_day;
|
|
175
|
-
delete config.default_weekly_periods;
|
|
176
|
-
delete config.auto_create_rules;
|
|
177
|
-
delete config.keyboard_support;
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
...options,
|
|
181
|
-
...tzid,
|
|
182
|
-
target,
|
|
183
|
-
token,
|
|
184
|
-
domains,
|
|
185
|
-
config: {
|
|
186
|
-
...config,
|
|
187
|
-
logs,
|
|
188
|
-
startDay,
|
|
189
|
-
defaultWeeklyPeriods,
|
|
190
|
-
autoCreateRulesMode,
|
|
191
|
-
keyboardSupport,
|
|
192
|
-
},
|
|
193
|
-
translations,
|
|
194
|
-
};
|
|
195
|
-
};
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import moment from "moment-timezone";
|
|
2
|
-
import {
|
|
3
|
-
adjustInterval,
|
|
4
|
-
parseConnectionDomains,
|
|
5
|
-
parseGridTime,
|
|
6
|
-
parseInterval,
|
|
7
|
-
parseQuery,
|
|
8
|
-
parseTarget,
|
|
9
|
-
parseTimezone,
|
|
10
|
-
parseToken,
|
|
11
|
-
parseTranslations,
|
|
12
|
-
} from "./init";
|
|
13
|
-
import { logConstructor } from "./logging";
|
|
14
|
-
|
|
15
|
-
export const parseAvailabilityViewerOptions = (options = {}) => {
|
|
16
|
-
let config = typeof options.config === "undefined" ? {} : options.config;
|
|
17
|
-
const logs = typeof config.logs === "undefined" ? "warn" : config.logs;
|
|
18
|
-
const log = logConstructor(
|
|
19
|
-
logs,
|
|
20
|
-
"Availability Viewer",
|
|
21
|
-
options.callback ? options.callback : false
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
options.error = false;
|
|
25
|
-
const demoMode = typeof options.demo === "undefined" ? false : options.demo;
|
|
26
|
-
|
|
27
|
-
if (demoMode) {
|
|
28
|
-
log.warn("You are running in demo mode. No API requests will be made");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const token = parseToken(options, "availability-viewer", log);
|
|
32
|
-
if (!token && !demoMode) {
|
|
33
|
-
log.error(
|
|
34
|
-
"You need to include an `element_token`. If you're just testing (and don't want to use real API data) you can set the `demo` option to `true` to bypass the API connection and view dummy content."
|
|
35
|
-
);
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const target = parseTarget(options, "availability-viewer", log);
|
|
40
|
-
|
|
41
|
-
const startTime = parseGridTime(config.start_time, "09:00");
|
|
42
|
-
if (startTime.message) {
|
|
43
|
-
log.warn(`config.start_time: ${startTime.message}`, {
|
|
44
|
-
docsSlug: "availability-viewer/#config.start_time",
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const endTime = parseGridTime(config.end_time, "17:00", true);
|
|
49
|
-
if (endTime.message) {
|
|
50
|
-
log.warn(`config.end_time: ${endTime.message}`, {
|
|
51
|
-
docsSlug: "availability-viewer/#config.end_time",
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
if (endTime.time === "00:00") {
|
|
55
|
-
endTime.time = "24:00";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (startTime.time > endTime.time) {
|
|
59
|
-
log.error(
|
|
60
|
-
`\`config.start_time\` (${startTime.time}) must be earlier than \`config.end_time\` (${endTime.time}).`
|
|
61
|
-
);
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const rawInterval = parseInterval(config.interval);
|
|
66
|
-
|
|
67
|
-
const interval = adjustInterval(rawInterval, startTime.offset, log);
|
|
68
|
-
|
|
69
|
-
if (typeof options.extras !== "undefined") {
|
|
70
|
-
log.warn(
|
|
71
|
-
"The `extras` option has been deprecated in v1.0.0. Please use `config` option instead.",
|
|
72
|
-
{ docsSlug: "availability-viewer/#config" }
|
|
73
|
-
);
|
|
74
|
-
config = options.extras;
|
|
75
|
-
}
|
|
76
|
-
if (typeof options.config !== "undefined") {
|
|
77
|
-
config = { ...config, ...options.config };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const tzid = parseTimezone(options.tzid, "availability-viewer", log);
|
|
81
|
-
options = { ...options, ...tzid };
|
|
82
|
-
|
|
83
|
-
const mode =
|
|
84
|
-
typeof config.mode === "undefined" || config.mode === "default" ? "confirm" : config.mode;
|
|
85
|
-
|
|
86
|
-
const validModes = ["confirm", "multi_select", "no_confirm", "free_select"];
|
|
87
|
-
const validMode = validModes.includes(mode);
|
|
88
|
-
if (!validMode) {
|
|
89
|
-
log.error(`Please provide a valid \`config.mode\`. \`${mode}\` is not a supported value.`, {
|
|
90
|
-
docsSlug: "availability-viewer/#config.mode",
|
|
91
|
-
});
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const slot_selection =
|
|
96
|
-
typeof config.slot_selection === "undefined" || config.slot_selection === "default"
|
|
97
|
-
? "available"
|
|
98
|
-
: config.slot_selection;
|
|
99
|
-
|
|
100
|
-
const boundsControl =
|
|
101
|
-
typeof config.bounds_control === "undefined" || config.bounds_control === "default"
|
|
102
|
-
? false
|
|
103
|
-
: true;
|
|
104
|
-
|
|
105
|
-
const query = parseQuery({
|
|
106
|
-
options,
|
|
107
|
-
elementSlug: "availability-viewer",
|
|
108
|
-
log,
|
|
109
|
-
allowEmpty: true,
|
|
110
|
-
});
|
|
111
|
-
if (!query) return false;
|
|
112
|
-
|
|
113
|
-
if (config.mode === "free_select") {
|
|
114
|
-
query.required_duration.minutes = interval;
|
|
115
|
-
const now = moment.utc().startOf("hour").add(1, "hour");
|
|
116
|
-
// Adding 34 days to ensure that the resulting query stays within the requiered bounds defined in
|
|
117
|
-
// https://docs.cronofy.com/developers/api/scheduling/availability/#param-participants.members.available_periods.end
|
|
118
|
-
query.query_periods = [
|
|
119
|
-
{
|
|
120
|
-
start: now.format("YYYY-MM-DDTHH:mm[:00Z]"),
|
|
121
|
-
end: now
|
|
122
|
-
.clone()
|
|
123
|
-
.local()
|
|
124
|
-
.add(34, "days")
|
|
125
|
-
.endOf("day")
|
|
126
|
-
.utc()
|
|
127
|
-
.format("YYYY-MM-DDTHH:mm[:00Z]"),
|
|
128
|
-
},
|
|
129
|
-
];
|
|
130
|
-
config.week_start_day = now.tz(options.tzid).local().format("dddd").toLowerCase();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const allowExpansion =
|
|
134
|
-
typeof config.allow_expansion === "undefined" || config.allow_expansion === "default"
|
|
135
|
-
? false
|
|
136
|
-
: config.allow_expansion;
|
|
137
|
-
|
|
138
|
-
const startDay =
|
|
139
|
-
typeof config.week_start_day === "undefined" || config.week_start_day === "default"
|
|
140
|
-
? "sunday"
|
|
141
|
-
: config.week_start_day;
|
|
142
|
-
|
|
143
|
-
const validStartDays = [
|
|
144
|
-
"sunday",
|
|
145
|
-
"monday",
|
|
146
|
-
"tuesday",
|
|
147
|
-
"wednesday",
|
|
148
|
-
"thursday",
|
|
149
|
-
"friday",
|
|
150
|
-
"saturday",
|
|
151
|
-
];
|
|
152
|
-
const validStartDay = validStartDays.includes(startDay);
|
|
153
|
-
|
|
154
|
-
if (!validStartDay) {
|
|
155
|
-
log.error(
|
|
156
|
-
`Please provide a valid \`config.week_start_day\`. \`${startDay}\` is not a supported value.`,
|
|
157
|
-
{
|
|
158
|
-
docsSlug: "availability-viewer/#config.week_start_day",
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
config = {
|
|
165
|
-
...config,
|
|
166
|
-
allowExpansion,
|
|
167
|
-
start_time: startTime.time,
|
|
168
|
-
end_time: endTime.time,
|
|
169
|
-
interval,
|
|
170
|
-
startDay,
|
|
171
|
-
mode,
|
|
172
|
-
boundsControl,
|
|
173
|
-
slot_selection,
|
|
174
|
-
logs,
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const domains = parseConnectionDomains(
|
|
178
|
-
options.data_center,
|
|
179
|
-
options.api_domain,
|
|
180
|
-
options.app_domain
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
const translations = parseTranslations(options.translations, "availability_rules");
|
|
184
|
-
|
|
185
|
-
config.start_time = config.start_time || "09:00";
|
|
186
|
-
config.end_time = config.end_time || "17:30";
|
|
187
|
-
|
|
188
|
-
const validStart = moment(config.start_time, "HH:mm").isValid();
|
|
189
|
-
const validEnd = moment(config.end_time, "HH:mm").isValid();
|
|
190
|
-
|
|
191
|
-
if (!validStart || !validEnd) {
|
|
192
|
-
log.error("Please provide a valid `config.start_time` and `config.end_time`.", {
|
|
193
|
-
docsSlug: "availability-viewer/#config.start_time",
|
|
194
|
-
});
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
delete options.availability_query;
|
|
199
|
-
delete options.element_token;
|
|
200
|
-
delete options.target_id;
|
|
201
|
-
delete config.bounds_control;
|
|
202
|
-
delete config.week_start_day;
|
|
203
|
-
delete config.allow_expansion;
|
|
204
|
-
delete config.translations;
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
...options,
|
|
208
|
-
target,
|
|
209
|
-
token,
|
|
210
|
-
domains,
|
|
211
|
-
config,
|
|
212
|
-
query,
|
|
213
|
-
translations,
|
|
214
|
-
};
|
|
215
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { parseToken, parseTarget, parseConnectionDomains, parseTranslations } from "./init";
|
|
2
|
-
import { logConstructor } from "./logging";
|
|
3
|
-
|
|
4
|
-
export const parseCalendarSyncOptions = (options = {}) => {
|
|
5
|
-
let config = typeof options.config === "undefined" ? {} : options.config;
|
|
6
|
-
const logs = typeof config.logs === "undefined" ? "warn" : config.logs;
|
|
7
|
-
const log = logConstructor(logs, "Calendar Sync", options.callback ? options.callback : false);
|
|
8
|
-
|
|
9
|
-
options.error = false;
|
|
10
|
-
const demoMode = typeof options.demo === "undefined" ? false : options.demo;
|
|
11
|
-
if (demoMode) {
|
|
12
|
-
log.warn("You are running in demo mode. No API requests will be made");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const token = parseToken(options, "calendar-sync", log);
|
|
16
|
-
|
|
17
|
-
const target = parseTarget(options, "calendar-sync", log);
|
|
18
|
-
|
|
19
|
-
if (!options.authorization_url) {
|
|
20
|
-
if (typeof options.authorization === "undefined" && !demoMode) {
|
|
21
|
-
log.error("You need to specify authorization options.");
|
|
22
|
-
return false;
|
|
23
|
-
} else if (typeof options.authorization === "undefined" && demoMode) {
|
|
24
|
-
options.authorization = {
|
|
25
|
-
redirect_uri: "REDIRECT_URI",
|
|
26
|
-
client_id: "CLIENT_ID",
|
|
27
|
-
scope: "SCOPE",
|
|
28
|
-
};
|
|
29
|
-
} else {
|
|
30
|
-
if (typeof options.authorization.redirect_uri === "undefined" && !demoMode) {
|
|
31
|
-
log.error("You need to specify authorization option: `redirect_uri`.");
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
if (typeof options.authorization.client_id === "undefined" && !demoMode) {
|
|
35
|
-
log.error("You need to specify authorization option: `client_id`.");
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
if (typeof options.authorization.scope === "undefined" && !demoMode) {
|
|
39
|
-
log.error("You need to specify authorization option: `scope`.");
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const revokeMode =
|
|
46
|
-
typeof config.revoke_mode === "undefined" ? "trigger_and_callback" : config.revoke_mode;
|
|
47
|
-
const validRevokeModes = ["trigger_and_callback", "callback_only"];
|
|
48
|
-
const validRevokeMode = validRevokeModes.includes(revokeMode);
|
|
49
|
-
|
|
50
|
-
if (!validRevokeMode) {
|
|
51
|
-
log.error(
|
|
52
|
-
`Please provide a valid 'config.revoke_mode'. '${revokeMode}' is not a supported value.`,
|
|
53
|
-
{
|
|
54
|
-
docsSlug: "calendar-sync#config.revoke_mode",
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
options.single_profile =
|
|
61
|
-
typeof options.single_profile !== "undefined" ? options.single_profile : false;
|
|
62
|
-
|
|
63
|
-
const translations = parseTranslations(options.translations, "availability_rules");
|
|
64
|
-
|
|
65
|
-
delete options.target_id;
|
|
66
|
-
delete options.element_token;
|
|
67
|
-
delete options.translations;
|
|
68
|
-
|
|
69
|
-
const domains = parseConnectionDomains(
|
|
70
|
-
options.data_center,
|
|
71
|
-
options.api_domain,
|
|
72
|
-
options.app_domain
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
...options,
|
|
77
|
-
config: { ...config, logs, revoke_mode: revokeMode },
|
|
78
|
-
target,
|
|
79
|
-
token,
|
|
80
|
-
domains,
|
|
81
|
-
translations,
|
|
82
|
-
};
|
|
83
|
-
};
|