@zaptime/core
Advanced tools
+22
-20
@@ -24,4 +24,4 @@ import { Result } from 'ts-results-es'; | ||
| interface ZaptimeTheme { | ||
| preset?: 'basic' | 'elegant' | 'playful'; | ||
| mode?: 'light' | 'dark'; | ||
| preset?: "basic" | "elegant" | "playful"; | ||
| mode?: "light" | "dark"; | ||
| borderRadius?: string; | ||
@@ -31,13 +31,13 @@ colors?: { | ||
| black?: string; | ||
| '25'?: string; | ||
| '50'?: string; | ||
| '100'?: string; | ||
| '200'?: string; | ||
| '300'?: string; | ||
| '400'?: string; | ||
| '500'?: string; | ||
| '600'?: string; | ||
| '700'?: string; | ||
| '800'?: string; | ||
| '900'?: string; | ||
| "25"?: string; | ||
| "50"?: string; | ||
| "100"?: string; | ||
| "200"?: string; | ||
| "300"?: string; | ||
| "400"?: string; | ||
| "500"?: string; | ||
| "600"?: string; | ||
| "700"?: string; | ||
| "800"?: string; | ||
| "900"?: string; | ||
| accentLight?: string; | ||
@@ -51,3 +51,3 @@ accentBase?: string; | ||
| preset?: string; | ||
| startDayOfWeek?: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'; | ||
| startDayOfWeek?: "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat"; | ||
| headers?: { | ||
@@ -69,2 +69,3 @@ mon?: string; | ||
| pickTime?: string; | ||
| showNextMonth?: string; | ||
| }; | ||
@@ -112,3 +113,3 @@ confirmationForm?: { | ||
| type ConfigWithoutToken = Omit<ZaptimeConfig, 'token'>; | ||
| type ConfigWithoutToken = Omit<ZaptimeConfig, "token">; | ||
| type Analytics = { | ||
@@ -142,2 +143,3 @@ name: string; | ||
| isSubscribed: boolean; | ||
| eventTypeName: string; | ||
| }; | ||
@@ -158,5 +160,5 @@ type StripeConfig = { | ||
| uuid: string; | ||
| type: 'text' | 'email' | 'phone' | 'number' | 'textarea' | 'switch' | 'checkbox' | 'select' | 'multiselect' | 'radio'; | ||
| type: "text" | "email" | "phone" | "number" | "textarea" | "switch" | "checkbox" | "select" | "multiselect" | "radio"; | ||
| required: boolean; | ||
| mergeTag?: 'FIRST_NAME' | 'LAST_NAME' | 'EMAIL' | 'PHONE' | string; | ||
| mergeTag?: "FIRST_NAME" | "LAST_NAME" | "EMAIL" | "PHONE" | string; | ||
| placeholder?: string; | ||
@@ -167,3 +169,3 @@ options?: string[]; | ||
| type Success = InitData; | ||
| type Errors = 'invalidToken'; | ||
| type Errors = "invalidToken"; | ||
@@ -216,3 +218,3 @@ interface ReservationResponse { | ||
| } | ||
| type IConfirmationOptions = Omit<IBookingOptions, 'email' | 'location' | 'seats'>; | ||
| type IConfirmationOptions = Omit<IBookingOptions, "email" | "location" | "seats">; | ||
| /** | ||
@@ -316,3 +318,3 @@ * Book Attandee to specific time slot. | ||
| type HourCycles = 'h23' | 'h11' | 'h12' | 'h24' | undefined; | ||
| type HourCycles = "h23" | "h11" | "h12" | "h24" | undefined; | ||
| declare function useHourCycle(): { | ||
@@ -319,0 +321,0 @@ clientOriginalHourCycle: HourCycles; |
+193
-40
@@ -79,3 +79,5 @@ // src/composables/useReservationStatus.ts | ||
| } | ||
| return state.value[calendarId].some((location) => location.value === "phone"); | ||
| return state.value[calendarId].some( | ||
| (location) => location.value === "phone" | ||
| ); | ||
| } else { | ||
@@ -85,3 +87,5 @@ if (state.value.__DEFAULT__ === void 0 || state.value.__DEFAULT__.length === 0) { | ||
| } | ||
| return state.value.__DEFAULT__.some((location) => location.value === "phone"); | ||
| return state.value.__DEFAULT__.some( | ||
| (location) => location.value === "phone" | ||
| ); | ||
| } | ||
@@ -111,3 +115,4 @@ }); | ||
| choosePreferredTime: "Choose preferred time", | ||
| pickTime: "Pick a time" | ||
| pickTime: "Pick a time", | ||
| showNextMonth: "Show next month" | ||
| }, | ||
@@ -179,5 +184,9 @@ confirmationForm: { | ||
| if (calendarId === void 0) { | ||
| _config.value.__DEFAULT__.config = reactifyObject(mergeRecursive(defaultConfig_default, cfg)); | ||
| _config.value.__DEFAULT__.config = reactifyObject( | ||
| mergeRecursive(defaultConfig_default, cfg) | ||
| ); | ||
| } else { | ||
| _config.value[calendarId].config = reactifyObject(mergeRecursive(defaultConfig_default, cfg)); | ||
| _config.value[calendarId].config = reactifyObject( | ||
| mergeRecursive(defaultConfig_default, cfg) | ||
| ); | ||
| } | ||
@@ -202,3 +211,14 @@ }; | ||
| var book = async (options) => { | ||
| const { email, token, timeSlot, firstName, lastName, seats = 1, baseUrl = defaultBaseUrl, phone, location, timezone: timezone2 } = options; | ||
| const { | ||
| email, | ||
| token, | ||
| timeSlot, | ||
| firstName, | ||
| lastName, | ||
| seats = 1, | ||
| baseUrl = defaultBaseUrl, | ||
| phone, | ||
| location, | ||
| timezone: timezone2 | ||
| } = options; | ||
| try { | ||
@@ -258,3 +278,14 @@ const data = await fetch(getBookUrl(baseUrl), { | ||
| var reserve = async (options) => { | ||
| const { email, token, timeSlot, firstName, lastName, seats = 1, baseUrl = defaultBaseUrl, phone, location, timezone: timezone2 } = options; | ||
| const { | ||
| email, | ||
| token, | ||
| timeSlot, | ||
| firstName, | ||
| lastName, | ||
| seats = 1, | ||
| baseUrl = defaultBaseUrl, | ||
| phone, | ||
| location, | ||
| timezone: timezone2 | ||
| } = options; | ||
| try { | ||
@@ -287,3 +318,11 @@ const data = await fetch(getReserveUrl(baseUrl), { | ||
| var confirm = async (options) => { | ||
| const { baseUrl = defaultBaseUrl, status, token, firstName, lastName, customFields, phone } = options; | ||
| const { | ||
| baseUrl = defaultBaseUrl, | ||
| status, | ||
| token, | ||
| firstName, | ||
| lastName, | ||
| customFields, | ||
| phone | ||
| } = options; | ||
| try { | ||
@@ -466,3 +505,12 @@ const data = await fetch(getConfirmUrl(baseUrl, status.uuid), { | ||
| var book2 = async (options) => { | ||
| const { email, firstName, lastName, seats = 1, calendarId, phone, location, customFields } = options; | ||
| const { | ||
| email, | ||
| firstName, | ||
| lastName, | ||
| seats = 1, | ||
| calendarId, | ||
| phone, | ||
| location, | ||
| customFields | ||
| } = options; | ||
| const { selectedTimeSlot } = useSelectedTimeSlot(calendarId); | ||
@@ -492,6 +540,10 @@ const { config: config2 } = useConfig(calendarId); | ||
| } catch (e) { | ||
| throw new Error("Booking a time slot failed because time slot was not selected!"); | ||
| throw new Error( | ||
| "Booking a time slot failed because time slot was not selected!" | ||
| ); | ||
| } | ||
| } | ||
| throw new Error("Booking a time slot failed because time slot was not selected!"); | ||
| throw new Error( | ||
| "Booking a time slot failed because time slot was not selected!" | ||
| ); | ||
| }; | ||
@@ -516,3 +568,5 @@ var reserve2 = async (options) => { | ||
| stopReservationInterval(); | ||
| throw new Error("Confirming a time slot failed because time slot was not reserved!"); | ||
| throw new Error( | ||
| "Confirming a time slot failed because time slot was not reserved!" | ||
| ); | ||
| }; | ||
@@ -523,3 +577,7 @@ var cancel2 = async (calendarId) => { | ||
| if (reservationStatus.value !== void 0) { | ||
| return await cancel(config2.value.token, reservationStatus.value, config2.value.apiBaseUrl); | ||
| return await cancel( | ||
| config2.value.token, | ||
| reservationStatus.value, | ||
| config2.value.apiBaseUrl | ||
| ); | ||
| } | ||
@@ -543,3 +601,5 @@ return false; | ||
| } | ||
| throw new Error("Rescheduling a time slot failed because time slot was not selected!"); | ||
| throw new Error( | ||
| "Rescheduling a time slot failed because time slot was not selected!" | ||
| ); | ||
| }; | ||
@@ -550,3 +610,12 @@ var fetchRemoteConfiguration = async (token, apiBaseUrl, reservationUuid) => { | ||
| async function initReservation(options) { | ||
| const { email, firstName, lastName, seats = 1, calendarId, location, phone, customFields } = options; | ||
| const { | ||
| email, | ||
| firstName, | ||
| lastName, | ||
| seats = 1, | ||
| calendarId, | ||
| location, | ||
| phone, | ||
| customFields | ||
| } = options; | ||
| const { selectedTimeSlot } = useSelectedTimeSlot(calendarId); | ||
@@ -574,3 +643,5 @@ const { config: config2 } = useConfig(calendarId); | ||
| } | ||
| throw new Error("Booking a time slot failed because time slot was not selected!"); | ||
| throw new Error( | ||
| "Booking a time slot failed because time slot was not selected!" | ||
| ); | ||
| } | ||
@@ -580,3 +651,7 @@ async function refreshReservation(options) { | ||
| const { config: config2 } = useConfig(options.calendarId); | ||
| await refreshReserve(config2.value.token, reservationStatus.value, config2.value.apiBaseUrl); | ||
| await refreshReserve( | ||
| config2.value.token, | ||
| reservationStatus.value, | ||
| config2.value.apiBaseUrl | ||
| ); | ||
| } | ||
@@ -611,6 +686,24 @@ var startReservationInterval = (options) => { | ||
| import { computed as computed6, reactive, watch } from "vue"; | ||
| import { addMonths, format as format3, isPast as isPast2, isFuture, differenceInCalendarMonths } from "date-fns"; | ||
| import { | ||
| addMonths, | ||
| format as format3, | ||
| isPast as isPast2, | ||
| isFuture, | ||
| differenceInCalendarMonths | ||
| } from "date-fns"; | ||
| // src/utils/calendar.ts | ||
| import { getDaysInMonth, startOfMonth, subMonths, lastDayOfMonth, subDays, endOfMonth, addDays, isPast, isToday, isThisMonth, format as format2 } from "date-fns"; | ||
| import { | ||
| getDaysInMonth, | ||
| startOfMonth, | ||
| subMonths, | ||
| lastDayOfMonth, | ||
| subDays, | ||
| endOfMonth, | ||
| addDays, | ||
| isPast, | ||
| isToday, | ||
| isThisMonth, | ||
| format as format2 | ||
| } from "date-fns"; | ||
| import { tz } from "@date-fns/tz"; | ||
@@ -712,3 +805,8 @@ | ||
| let hasAnyTimeSlot = false; | ||
| const timeSlots = await getAvailableTimeSlots(zapTimeConfig.token, getStartDate(date, zapTimeConfig, timezone2), format2(endOfMonth(date), "yyyy-MM-dd", { in: tz(timezone2) }), zapTimeConfig.apiBaseUrl); | ||
| const timeSlots = await getAvailableTimeSlots( | ||
| zapTimeConfig.token, | ||
| getStartDate(date, zapTimeConfig, timezone2), | ||
| format2(endOfMonth(date), "yyyy-MM-dd", { in: tz(timezone2) }), | ||
| zapTimeConfig.apiBaseUrl | ||
| ); | ||
| if (Object.keys(timeSlots).length > 0) { | ||
@@ -718,3 +816,5 @@ hasAnyTimeSlot = true; | ||
| const startOfTheWeekIndex = zapTimeConfig && zapTimeConfig.locale !== void 0 ? getStartOfTheWeekIndex(zapTimeConfig.locale) : 0; | ||
| const numberOfDay = parseInt(format2(startDateOfTheMonth, "i", { ...dfnsConfig, in: tz(timezone2) })) - startOfTheWeekIndex + 1; | ||
| const numberOfDay = parseInt( | ||
| format2(startDateOfTheMonth, "i", { ...dfnsConfig, in: tz(timezone2) }) | ||
| ) - startOfTheWeekIndex + 1; | ||
| const previousMonth = subMonths(startDateOfTheMonth, 1); | ||
@@ -725,3 +825,5 @@ const lastDateOfPreviousMonth = lastDayOfMonth(previousMonth); | ||
| days.unshift({ | ||
| label: format2(subDays(lastDateOfPreviousMonth, k - 1), "d", { in: tz(timezone2) }), | ||
| label: format2(subDays(lastDateOfPreviousMonth, k - 1), "d", { | ||
| in: tz(timezone2) | ||
| }), | ||
| isPast: true | ||
@@ -759,3 +861,7 @@ }); | ||
| if (isThisMonth(date) && zapTimeConfig.closestBookableDay !== void 0) { | ||
| return format2(addDays(date, zapTimeConfig.closestBookableDay), "yyyy-MM-dd", { in: tz(timezone2) }); | ||
| return format2( | ||
| addDays(date, zapTimeConfig.closestBookableDay), | ||
| "yyyy-MM-dd", | ||
| { in: tz(timezone2) } | ||
| ); | ||
| } | ||
@@ -771,2 +877,3 @@ return format2(startOfMonth(date), "yyyy-MM-dd", { in: tz(timezone2) }); | ||
| const dfnsConf2 = { | ||
| // @ts-expect-error | ||
| locale: dateFnsLocale.default | ||
@@ -812,2 +919,3 @@ }; | ||
| const dfnsConf = { | ||
| // @ts-expect-error | ||
| locale: dateFnsLocale.default | ||
@@ -879,3 +987,8 @@ }; | ||
| if (state5.value.dfnsConfig !== void 0 && state5.value.dfnsConfig !== null) { | ||
| const { days, hasAnyTimeSlot } = await getDays(state5.value.date, state5.value.dfnsConfig, config2.value, timezone2.value); | ||
| const { days, hasAnyTimeSlot } = await getDays( | ||
| state5.value.date, | ||
| state5.value.dfnsConfig, | ||
| config2.value, | ||
| timezone2.value | ||
| ); | ||
| if (hasAnyTimeSlot) { | ||
@@ -963,12 +1076,24 @@ const firstAvailableDayWithTimeSlot = getFirstAvailableDayWithTimeSlot(days); | ||
| }); | ||
| watch([() => config2.value.locale?.preset, () => config2.value.closestBookableDay, () => config2.value.locale?.startDayOfWeek], async () => { | ||
| if (state5.value.initLoaded) { | ||
| await setLocales(); | ||
| await getDays2(); | ||
| watch( | ||
| [ | ||
| () => config2.value.locale?.preset, | ||
| () => config2.value.closestBookableDay, | ||
| () => config2.value.locale?.startDayOfWeek | ||
| ], | ||
| async () => { | ||
| if (state5.value.initLoaded) { | ||
| await setLocales(); | ||
| await getDays2(); | ||
| } | ||
| } | ||
| }); | ||
| ); | ||
| const setLocales = async () => { | ||
| if (config2.value && config2.value.locale) { | ||
| state5.value.dfnsConfig = await getDfnsConfig(config2.value.locale.preset || "en"); | ||
| setState("headers", getHeaders(config2.value.locale, state5.value.dfnsConfig)); | ||
| state5.value.dfnsConfig = await getDfnsConfig( | ||
| config2.value.locale.preset || "en" | ||
| ); | ||
| setState( | ||
| "headers", | ||
| getHeaders(config2.value.locale, state5.value.dfnsConfig) | ||
| ); | ||
| } | ||
@@ -981,2 +1106,5 @@ }; | ||
| await getDays2(); | ||
| if (state5.value.timeSlots.length <= 0) { | ||
| await next(); | ||
| } | ||
| setState("initLoaded", true); | ||
@@ -1008,3 +1136,5 @@ } | ||
| if (typeof window !== "undefined") { | ||
| clientOriginalHourCycle = Intl.DateTimeFormat(navigator.language, { hour: "numeric" }).resolvedOptions().hourCycle; | ||
| clientOriginalHourCycle = Intl.DateTimeFormat(navigator.language, { | ||
| hour: "numeric" | ||
| }).resolvedOptions().hourCycle; | ||
| } | ||
@@ -1053,3 +1183,8 @@ var hourCycle = ref8(clientOriginalHourCycle); | ||
| }); | ||
| var knownFieldsByMergeTag = ["FIRST_NAME", "LAST_NAME", "EMAIL", "PHONE"]; | ||
| var knownFieldsByMergeTag = [ | ||
| "FIRST_NAME", | ||
| "LAST_NAME", | ||
| "EMAIL", | ||
| "PHONE" | ||
| ]; | ||
| function useBookingForm(calendarId) { | ||
@@ -1077,4 +1212,8 @@ const setBookingForm = (customFields) => { | ||
| function collectKnownFields() { | ||
| const firstName = bookingForm.value.find((field) => field.mergeTag === "FIRST_NAME"); | ||
| const lastName = bookingForm.value.find((field) => field.mergeTag === "LAST_NAME"); | ||
| const firstName = bookingForm.value.find( | ||
| (field) => field.mergeTag === "FIRST_NAME" | ||
| ); | ||
| const lastName = bookingForm.value.find( | ||
| (field) => field.mergeTag === "LAST_NAME" | ||
| ); | ||
| const email = bookingForm.value.find((field) => field.mergeTag === "EMAIL"); | ||
@@ -1091,3 +1230,5 @@ const phone = bookingForm.value.find((field) => field.mergeTag === "PHONE"); | ||
| const customFieldsCollected = []; | ||
| const unknownCustomFields = bookingForm.value.filter((field) => !knownFieldsByMergeTag.includes(field.mergeTag)); | ||
| const unknownCustomFields = bookingForm.value.filter( | ||
| (field) => !knownFieldsByMergeTag.includes(field.mergeTag) | ||
| ); | ||
| for (const unknownCustomField of unknownCustomFields) { | ||
@@ -1179,12 +1320,24 @@ customFieldsCollected.push({ | ||
| if (hourCycle2.value === "h11") { | ||
| return format4(parseISO(date), "h:mmaaa", { in: tz2(timezone2.value), ...dateFnsConfig }); | ||
| return format4(parseISO(date), "h:mmaaa", { | ||
| in: tz2(timezone2.value), | ||
| ...dateFnsConfig | ||
| }); | ||
| } else { | ||
| return format4(parseISO(date), "H:mm", { in: tz2(timezone2.value), ...dateFnsConfig }); | ||
| return format4(parseISO(date), "H:mm", { | ||
| in: tz2(timezone2.value), | ||
| ...dateFnsConfig | ||
| }); | ||
| } | ||
| }; | ||
| const getFormattedDay = (date) => { | ||
| return format4(parseISO(date), "EEEE", { ...dateFnsConfig, in: tz2(timezone2.value) }); | ||
| return format4(parseISO(date), "EEEE", { | ||
| ...dateFnsConfig, | ||
| in: tz2(timezone2.value) | ||
| }); | ||
| }; | ||
| const getFormattedDayInMonth = (date) => { | ||
| return format4(parseISO(date), "PPPP", { ...dateFnsConfig, in: tz2(timezone2.value) }); | ||
| return format4(parseISO(date), "PPPP", { | ||
| ...dateFnsConfig, | ||
| in: tz2(timezone2.value) | ||
| }); | ||
| }; | ||
@@ -1191,0 +1344,0 @@ return { |
+1
-3
| { | ||
| "name": "@zaptime/core", | ||
| "description": "Core library for Zaptime", | ||
| "version": "2.8.7", | ||
| "version": "2.9.0", | ||
| "type": "module", | ||
@@ -38,6 +38,4 @@ "main": "dist/entry.js", | ||
| "scripts": { | ||
| "dev-legacy": "vite build --watch", | ||
| "devasd": "pnpm run build --watch", | ||
| "build": "tsup ./src/entry.ts --format esm --dts --external vue " | ||
| } | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
47969
1.77%1667
10.25%