@loczer/storefront-sdk 0.154.0 → 0.156.0
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/components/BookingPeriodSelector/index.d.ts +1 -1
- package/dist/components/BookingPeriodSelector/index.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts +25 -4
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +344 -192
- package/dist/index.d.ts +38 -3
- package/dist/lib/contactForm.d.ts +8 -0
- package/dist/lib/contactForm.d.ts.map +1 -1
- package/dist/lib/contactForm.js +21 -13
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ type BookingPeriodSelectorProps = BookingPeriodControllerOptions & {
|
|
|
4
4
|
};
|
|
5
5
|
export declare const BookingPeriodSelector: ({ className, ...options }: BookingPeriodSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export { BookingPeriodProvider, useBookingPeriod } from './BookingPeriodContext';
|
|
7
|
-
export type { BookingPeriodControllerOptions, BookingPeriodControllerValue, BookingPeriodLabels } from './useBookingPeriodController';
|
|
7
|
+
export type { BookingPeriodChangeMeta, BookingPeriodControllerOptions, BookingPeriodControllerValue, BookingPeriodLabels, BookingPeriodSelectionFlow, BookingPeriodTimeSlotsFetcher, BookingPeriodTranslator, } from './useBookingPeriodController';
|
|
8
8
|
export { BookingStartDateField } from './components/BookingStartDateField';
|
|
9
9
|
export { BookingStartTimeField } from './components/BookingStartTimeField';
|
|
10
10
|
export { BookingEndDateField } from './components/BookingEndDateField';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/BookingPeriodSelector/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,8BAA8B,CAAA;AAOlF,KAAK,0BAA0B,GAAG,8BAA8B,GAAG;IACjE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,2BAA2B,0BAA0B,4CAa1F,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAChF,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/BookingPeriodSelector/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,8BAA8B,CAAA;AAOlF,KAAK,0BAA0B,GAAG,8BAA8B,GAAG;IACjE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,2BAA2B,0BAA0B,4CAa1F,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAChF,YAAY,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,4BAA4B,EAC5B,mBAAmB,EACnB,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Locale } from 'date-fns';
|
|
2
2
|
import { HourPickerOption } from '@rpcbase/ui';
|
|
3
3
|
import { BookingPeriodConfig } from '../../lib/booking-period';
|
|
4
|
-
import { TimeSlot } from '../../lib/booking-period-time-slots';
|
|
4
|
+
import { JourneyType, TimeSlot } from '../../lib/booking-period-time-slots';
|
|
5
|
+
export type BookingPeriodChangeMeta = {
|
|
6
|
+
source: "user" | "auto";
|
|
7
|
+
};
|
|
8
|
+
export type BookingPeriodTranslator = (key: string, options?: Record<string, unknown>) => string;
|
|
9
|
+
export type BookingPeriodTimeSlotsFetcher = (date: string, journey: JourneyType) => Promise<TimeSlot[] | null>;
|
|
5
10
|
export type BookingPeriodLabels = {
|
|
6
11
|
startDate: string;
|
|
7
12
|
pickStartDate: string;
|
|
@@ -17,15 +22,17 @@ export type BookingPeriodLabels = {
|
|
|
17
22
|
count: number;
|
|
18
23
|
}) => string;
|
|
19
24
|
};
|
|
25
|
+
export type BookingPeriodSelectionFlow = "chained-times" | "dates-first";
|
|
20
26
|
export interface BookingPeriodControllerOptions {
|
|
21
27
|
startDate?: Date;
|
|
22
28
|
onStartDateChange: (date?: Date) => void;
|
|
23
29
|
startTime?: string;
|
|
24
|
-
onStartTimeChange: (time: string) => void;
|
|
30
|
+
onStartTimeChange: (time: string, meta?: BookingPeriodChangeMeta) => void;
|
|
25
31
|
endDate?: Date;
|
|
26
32
|
onEndDateChange: (date?: Date) => void;
|
|
27
33
|
endTime?: string;
|
|
28
|
-
onEndTimeChange: (time: string) => void;
|
|
34
|
+
onEndTimeChange: (time: string, meta?: BookingPeriodChangeMeta) => void;
|
|
35
|
+
onEndDateCommit?: (date?: Date, endTime?: string) => void;
|
|
29
36
|
onEndTimeCommit?: () => void;
|
|
30
37
|
errors?: {
|
|
31
38
|
startDate?: string;
|
|
@@ -33,10 +40,15 @@ export interface BookingPeriodControllerOptions {
|
|
|
33
40
|
endDate?: string;
|
|
34
41
|
endTime?: string;
|
|
35
42
|
};
|
|
36
|
-
labels
|
|
43
|
+
labels?: BookingPeriodLabels;
|
|
44
|
+
t?: BookingPeriodTranslator;
|
|
45
|
+
language?: string;
|
|
37
46
|
labelClassName?: string;
|
|
38
47
|
inputClassName?: string;
|
|
48
|
+
buttonClassName?: string;
|
|
39
49
|
bookingPeriodConfig?: BookingPeriodConfig;
|
|
50
|
+
fetchTimeSlots?: BookingPeriodTimeSlotsFetcher;
|
|
51
|
+
selectionFlow?: BookingPeriodSelectionFlow;
|
|
40
52
|
currencyCode?: string;
|
|
41
53
|
disableAutomaticTimeCorrection?: boolean;
|
|
42
54
|
openDatePickerOnFocus?: boolean;
|
|
@@ -52,13 +64,17 @@ export interface BookingPeriodControllerValue {
|
|
|
52
64
|
endTime?: string;
|
|
53
65
|
errors: NonNullable<BookingPeriodControllerOptions["errors"]>;
|
|
54
66
|
labels: BookingPeriodLabels;
|
|
67
|
+
t: BookingPeriodTranslator;
|
|
68
|
+
language: string;
|
|
55
69
|
labelClassName?: string;
|
|
56
70
|
inputClassName?: string;
|
|
71
|
+
buttonClassName?: string;
|
|
57
72
|
currencyCode: string;
|
|
58
73
|
localeCode: string;
|
|
59
74
|
slotIntervalMinutes: number;
|
|
60
75
|
dateLocale: Locale;
|
|
61
76
|
numberOfMonths: number;
|
|
77
|
+
isMobile: boolean;
|
|
62
78
|
isHydrated: boolean;
|
|
63
79
|
openDatePickerOnFocus: boolean;
|
|
64
80
|
isStartDatePopoverOpen: boolean;
|
|
@@ -76,6 +92,7 @@ export interface BookingPeriodControllerValue {
|
|
|
76
92
|
availableEndTimeSlots: TimeSlot[];
|
|
77
93
|
isStartToday: boolean;
|
|
78
94
|
isEndToday: boolean;
|
|
95
|
+
minSelectableDate: Date;
|
|
79
96
|
earliestMinutesForToday: number | null;
|
|
80
97
|
startMinutesValue: number | null;
|
|
81
98
|
isSameDaySelection: boolean;
|
|
@@ -86,10 +103,14 @@ export interface BookingPeriodControllerValue {
|
|
|
86
103
|
updateStartTime: (value: string) => void;
|
|
87
104
|
selectStartDate: (date: Date | undefined, options?: {
|
|
88
105
|
openTimePicker?: boolean;
|
|
106
|
+
openEndDatePicker?: boolean;
|
|
107
|
+
close?: boolean;
|
|
89
108
|
}) => void;
|
|
90
109
|
selectStartTime: (value: string) => void;
|
|
91
110
|
selectEndDate: (date: Date | undefined, options?: {
|
|
92
111
|
openTimePicker?: boolean;
|
|
112
|
+
close?: boolean;
|
|
113
|
+
commit?: boolean;
|
|
93
114
|
}) => void;
|
|
94
115
|
/**
|
|
95
116
|
* Immediate committed update.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBookingPeriodController.d.ts","sourceRoot":"","sources":["../../../src/components/BookingPeriodSelector/useBookingPeriodController.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,
|
|
1
|
+
{"version":3,"file":"useBookingPeriodController.d.ts","sourceRoot":"","sources":["../../../src/components/BookingPeriodSelector/useBookingPeriodController.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,EAQL,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAiC,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AAGpH,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,MAAM,CAAA;AAEX,MAAM,MAAM,6BAA6B,GAAG,CAC1C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAA;AAE/B,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAA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AAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KACtE,IAAI,CAAA;IACT;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC;AAuFD,eAAO,MAAM,0BAA0B,GACrC,SAAS,8BAA8B,KACtC,4BAywBF,CAAA"}
|
|
@@ -1,237 +1,389 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { differenceInCalendarDays as
|
|
3
|
-
import { fr as
|
|
4
|
-
import { useMediaQuery as
|
|
5
|
-
import { parseTimeToMinutes as
|
|
6
|
-
import { getBookingPeriodTimeSlotsSync as
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { useMemo as d, useState as y, useRef as N, useCallback as h, useEffect as F } from "react";
|
|
2
|
+
import { differenceInCalendarDays as Te } from "date-fns";
|
|
3
|
+
import { fr as tt, de as nt, es as rt, it, enUS as st } from "date-fns/locale";
|
|
4
|
+
import { useMediaQuery as at } from "@rpcbase/client";
|
|
5
|
+
import { createBookingPeriodConstants as ot, parseTimeToMinutes as x, dateToBusinessDateString as lt, instantToBusinessDateTimeParts as ut, businessDateStringToDate as ct, getWeekdayFromDateString as ft, minutesToTimeString as dt } from "../../lib/booking-period.js";
|
|
6
|
+
import { getBookingPeriodTimeSlotsSync as mt } from "../../lib/booking-period-time-slots.js";
|
|
7
|
+
const St = (T) => T, Tt = {
|
|
8
|
+
startDate: "Start date",
|
|
9
|
+
pickStartDate: "Pick a date",
|
|
10
|
+
startTime: "Start time",
|
|
11
|
+
endDate: "End date",
|
|
12
|
+
pickEndDate: "Pick a date",
|
|
13
|
+
endTime: "End time"
|
|
14
|
+
}, Dt = ({
|
|
15
|
+
locale: T,
|
|
16
|
+
localeCode: r
|
|
10
17
|
}) => {
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
if (!
|
|
18
|
+
if (T)
|
|
19
|
+
return T;
|
|
20
|
+
const i = r?.toLowerCase() ?? "";
|
|
21
|
+
return i.startsWith("fr") ? tt : i.startsWith("de") ? nt : i.startsWith("es") ? rt : i.startsWith("it") ? it : st;
|
|
22
|
+
}, pt = (T) => {
|
|
23
|
+
if (!T?.length)
|
|
17
24
|
return null;
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
25
|
+
const r = T.map((n) => x(n.value)).filter((n) => typeof n == "number").sort((n, K) => n - K);
|
|
26
|
+
if (r.length < 2)
|
|
20
27
|
return null;
|
|
21
|
-
const
|
|
22
|
-
return !Number.isFinite(
|
|
23
|
-
},
|
|
24
|
-
if (typeof
|
|
28
|
+
const i = r[1] - r[0];
|
|
29
|
+
return !Number.isFinite(i) || i <= 0 ? null : i;
|
|
30
|
+
}, vt = (T) => {
|
|
31
|
+
if (typeof T != "string")
|
|
25
32
|
return null;
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
},
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
33
|
+
const r = T.match(/(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})/);
|
|
34
|
+
return r ? x(r[2]) : null;
|
|
35
|
+
}, we = (T, r) => T.map((i) => {
|
|
36
|
+
const n = x(i.value);
|
|
37
|
+
if (n == null)
|
|
31
38
|
return null;
|
|
32
|
-
const
|
|
39
|
+
const K = vt(i.label) ?? n + r, m = typeof i.label == "string" ? i.label : i.value;
|
|
33
40
|
return {
|
|
34
|
-
value:
|
|
35
|
-
label:
|
|
36
|
-
startMinutes:
|
|
37
|
-
endMinutes:
|
|
41
|
+
value: i.value,
|
|
42
|
+
label: m,
|
|
43
|
+
startMinutes: n,
|
|
44
|
+
endMinutes: K,
|
|
38
45
|
isExtra: !1,
|
|
39
|
-
isDisabled: !!
|
|
46
|
+
isDisabled: !!i.disabled
|
|
40
47
|
};
|
|
41
|
-
}).filter((
|
|
48
|
+
}).filter((i) => !!i), Ot = (T) => {
|
|
42
49
|
const {
|
|
43
|
-
startDate:
|
|
44
|
-
onStartDateChange:
|
|
45
|
-
startTime:
|
|
46
|
-
onStartTimeChange:
|
|
47
|
-
endDate:
|
|
48
|
-
onEndDateChange:
|
|
49
|
-
endTime:
|
|
50
|
-
onEndTimeChange:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
50
|
+
startDate: r,
|
|
51
|
+
onStartDateChange: i,
|
|
52
|
+
startTime: n,
|
|
53
|
+
onStartTimeChange: K,
|
|
54
|
+
endDate: m,
|
|
55
|
+
onEndDateChange: _,
|
|
56
|
+
endTime: o,
|
|
57
|
+
onEndTimeChange: De,
|
|
58
|
+
onEndDateCommit: Q,
|
|
59
|
+
onEndTimeCommit: V,
|
|
60
|
+
errors: Pe = {},
|
|
61
|
+
labels: Fe,
|
|
62
|
+
t: ke = St,
|
|
63
|
+
language: pe,
|
|
64
|
+
labelClassName: Ae,
|
|
65
|
+
inputClassName: Be,
|
|
66
|
+
buttonClassName: Ie,
|
|
67
|
+
bookingPeriodConfig: D,
|
|
68
|
+
fetchTimeSlots: s,
|
|
69
|
+
selectionFlow: C = "chained-times",
|
|
70
|
+
currencyCode: Le = "EUR",
|
|
71
|
+
disableAutomaticTimeCorrection: H = !1,
|
|
72
|
+
openDatePickerOnFocus: Re = !0,
|
|
73
|
+
startTimeOptions: U = [],
|
|
74
|
+
endTimeOptions: ve,
|
|
75
|
+
locale: he,
|
|
76
|
+
localeCode: xe
|
|
77
|
+
} = T, W = at("(max-width: 767px)"), Y = xe ?? pe ?? "en-US", Ke = d(
|
|
78
|
+
() => Dt({ locale: he, localeCode: Y }),
|
|
79
|
+
[he, Y]
|
|
80
|
+
), E = d(
|
|
81
|
+
() => D ? ot(D) : null,
|
|
82
|
+
[D]
|
|
83
|
+
), R = d(() => D?.timing.slotIntervalMinutes ? D.timing.slotIntervalMinutes : pt(U) ?? 30, [D?.timing.slotIntervalMinutes, U]), [ne, j] = y(!1), [re, ie] = y(!1), [se, z] = y(!1), [ae, oe] = y(!1), [He, le] = y(void 0), [Ue, We] = y(!1), [ge, ze] = y(!1), [Ee, Ne] = y([]), [be, G] = y([]), [J, q] = y(void 0), b = N(null), ue = N(0), ce = N(0), fe = N(0), Me = N(void 0), $ = N(void 0), qe = h(() => {
|
|
84
|
+
le(void 0);
|
|
85
|
+
}, []), X = d(() => !r || !m ? !1 : Te(m, r) === 0, [r, m]), $e = d(() => x(n), [n]), k = h(
|
|
86
|
+
(e) => {
|
|
87
|
+
const c = (e instanceof Date ? e : e ? new Date(e) : void 0) ?? /* @__PURE__ */ new Date();
|
|
88
|
+
if (E)
|
|
89
|
+
return lt(c, E.timeZone) ?? void 0;
|
|
90
|
+
const u = c.getFullYear(), v = String(c.getMonth() + 1).padStart(2, "0"), S = String(c.getDate()).padStart(2, "0");
|
|
91
|
+
return `${u}-${v}-${S}`;
|
|
92
|
+
},
|
|
93
|
+
[E]
|
|
94
|
+
), A = d(() => k(r), [r, k]), l = d(() => k(m ?? r), [m, r, k]), ye = E ? ut(/* @__PURE__ */ new Date(), E.timeZone) : null, O = ye?.dateString, de = ye?.minutesFromMidnight, B = d(() => O ? !!(r && A && A === O) : !!r && Te(r, /* @__PURE__ */ new Date()) === 0, [r, A, O]), Z = d(() => O ? !!(m && l && l === O) : !!m && Te(m, /* @__PURE__ */ new Date()) === 0, [m, l, O]), Ze = d(() => {
|
|
95
|
+
if (O)
|
|
96
|
+
return ct(O);
|
|
97
|
+
const e = /* @__PURE__ */ new Date();
|
|
98
|
+
return e.setHours(0, 0, 0, 0), e;
|
|
99
|
+
}, [O]), me = D?.timing.minBufferMinutes ?? 10, I = d(() => {
|
|
100
|
+
if (!B && !Z)
|
|
101
|
+
return null;
|
|
102
|
+
if (de != null)
|
|
103
|
+
return de + me;
|
|
104
|
+
const e = /* @__PURE__ */ new Date();
|
|
105
|
+
return e.setMinutes(e.getMinutes() + me), e.getHours() * 60 + e.getMinutes();
|
|
106
|
+
}, [de, Z, B, me]), Se = d(
|
|
107
|
+
() => B ? I : null,
|
|
108
|
+
[I, B]
|
|
109
|
+
), Ce = h(
|
|
110
|
+
(e) => {
|
|
111
|
+
if (!E)
|
|
112
|
+
return;
|
|
113
|
+
const t = k(e);
|
|
114
|
+
if (!t)
|
|
115
|
+
return E.defaultEndTime;
|
|
116
|
+
const c = ft(t), u = E.getLastStartMinutesForWeekday(c, {
|
|
117
|
+
dateString: t
|
|
118
|
+
});
|
|
119
|
+
return typeof u == "number" ? dt(u) : E.defaultEndTime;
|
|
120
|
+
},
|
|
121
|
+
[E, k]
|
|
122
|
+
);
|
|
123
|
+
F(() => {
|
|
124
|
+
if (!s || !A)
|
|
78
125
|
return;
|
|
79
|
-
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
126
|
+
let e = !0;
|
|
127
|
+
return s(A, "start").then((t) => {
|
|
128
|
+
e && t && Ne(t);
|
|
129
|
+
}).catch((t) => {
|
|
130
|
+
console.error("Failed to fetch availability time slots", t);
|
|
131
|
+
}), () => {
|
|
132
|
+
e = !1;
|
|
133
|
+
};
|
|
134
|
+
}, [s, A]), F(() => {
|
|
135
|
+
if (!s)
|
|
136
|
+
return;
|
|
137
|
+
const e = Me.current, t = e !== void 0 && e !== l;
|
|
138
|
+
Me.current = l, t && l && ($.current = l);
|
|
139
|
+
}, [l, s]), F(() => {
|
|
140
|
+
if (!s)
|
|
141
|
+
return;
|
|
142
|
+
if (!l) {
|
|
143
|
+
G([]), q(void 0);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let e = !0;
|
|
147
|
+
return q(void 0), s(l, "end").then((t) => {
|
|
148
|
+
e && (t ? (G(t), q(l)) : (G([]), q(void 0)));
|
|
149
|
+
}).catch((t) => {
|
|
150
|
+
console.error("Failed to fetch availability time slots", t), e && (G([]), q(void 0));
|
|
151
|
+
}), () => {
|
|
152
|
+
e = !1;
|
|
153
|
+
};
|
|
154
|
+
}, [l, s]);
|
|
155
|
+
const ee = d(() => s || !D ? null : mt(D, {
|
|
156
|
+
date: A
|
|
157
|
+
}), [D, s, A]), w = d(() => s ? Ee : D ? ee?.startTimeSlots ?? [] : we(U, R), [
|
|
158
|
+
D,
|
|
159
|
+
ee?.startTimeSlots,
|
|
160
|
+
s,
|
|
161
|
+
Ee,
|
|
162
|
+
R,
|
|
163
|
+
U
|
|
164
|
+
]), L = d(() => s ? J === l ? be : [] : D ? ee?.endTimeSlots ?? [] : we(ve ?? U, R), [
|
|
165
|
+
D,
|
|
166
|
+
ee?.endTimeSlots,
|
|
167
|
+
l,
|
|
168
|
+
ve,
|
|
169
|
+
s,
|
|
170
|
+
be,
|
|
171
|
+
J,
|
|
172
|
+
R,
|
|
173
|
+
U
|
|
174
|
+
]), M = h(
|
|
175
|
+
(e, t) => {
|
|
176
|
+
e !== n && (ze(t === "user"), K(e, { source: t }));
|
|
177
|
+
},
|
|
178
|
+
[K, n]
|
|
179
|
+
), p = h(
|
|
180
|
+
(e, t = "auto") => {
|
|
181
|
+
e !== o && De(e, { source: t });
|
|
86
182
|
},
|
|
87
|
-
[
|
|
88
|
-
),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, [
|
|
92
|
-
if (
|
|
183
|
+
[o, De]
|
|
184
|
+
), te = d(() => w.length ? w.find((e) => !(e.isDisabled || Se != null && e.startMinutes < Se)) ?? null : null, [Se, w]);
|
|
185
|
+
F(() => {
|
|
186
|
+
H || ge || te && n !== te.value && M(te.value, "auto");
|
|
187
|
+
}, [H, te, ge, n, M]), F(() => {
|
|
188
|
+
if (H || !w.length)
|
|
93
189
|
return;
|
|
94
|
-
const e =
|
|
95
|
-
const
|
|
96
|
-
|
|
190
|
+
const e = n ? w.find((f) => f.value === n) : void 0, t = I ?? void 0, c = B ? t : null, u = (f) => {
|
|
191
|
+
const a = typeof f == "number" ? f : null, g = w.find((P) => !(P.isDisabled || a != null && P.startMinutes < a));
|
|
192
|
+
g && g.value !== n ? M(g.value, "auto") : !g && n && M("", "auto");
|
|
97
193
|
};
|
|
98
|
-
if (
|
|
99
|
-
|
|
194
|
+
if (n && !e) {
|
|
195
|
+
u(c);
|
|
100
196
|
return;
|
|
101
197
|
}
|
|
102
198
|
if (e?.isDisabled) {
|
|
103
|
-
|
|
199
|
+
u(c);
|
|
104
200
|
return;
|
|
105
201
|
}
|
|
106
|
-
if (!
|
|
202
|
+
if (!B || t == null)
|
|
107
203
|
return;
|
|
108
|
-
const v =
|
|
109
|
-
if (v != null && v >=
|
|
204
|
+
const v = x(n);
|
|
205
|
+
if (v != null && v >= t && !e?.isDisabled)
|
|
110
206
|
return;
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
}, [
|
|
114
|
-
if (
|
|
207
|
+
const S = w.find((f) => !f.isDisabled && f.startMinutes >= t);
|
|
208
|
+
S && S.value !== n && M(S.value, "auto");
|
|
209
|
+
}, [H, I, B, n, w, M]), F(() => {
|
|
210
|
+
if (H || !L.length)
|
|
115
211
|
return;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
212
|
+
if (s && $.current === l && J === l) {
|
|
213
|
+
$.current = void 0;
|
|
214
|
+
const g = [...L].reverse().find((P) => !P.isDisabled);
|
|
215
|
+
if (g && g.value !== o) {
|
|
216
|
+
p(g.value);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const e = x(n), t = x(o), c = o ? L.find((a) => a.value === o) : void 0;
|
|
221
|
+
if (X && e != null && t != null && t < e) {
|
|
222
|
+
const a = [...L].reverse().find((g) => !g.isDisabled);
|
|
223
|
+
a && a.value !== o ? p(a.value) : !a && o && p("");
|
|
120
224
|
return;
|
|
121
225
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const v =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
226
|
+
const u = [];
|
|
227
|
+
Z && I != null && u.push(I), X && e != null && u.push(e + R);
|
|
228
|
+
const v = u.length ? Math.max(...u) : null, S = (a) => {
|
|
229
|
+
const g = typeof a == "number" ? a : null, P = L.find((Oe) => !(Oe.isDisabled || g != null && Oe.startMinutes < g));
|
|
230
|
+
P && P.value !== o ? p(P.value) : !P && o && p("");
|
|
231
|
+
};
|
|
232
|
+
if (s && o && !c) {
|
|
233
|
+
S(v);
|
|
128
234
|
return;
|
|
129
235
|
}
|
|
130
|
-
if (
|
|
236
|
+
if (c?.isDisabled) {
|
|
237
|
+
S(v);
|
|
131
238
|
return;
|
|
132
|
-
|
|
133
|
-
|
|
239
|
+
}
|
|
240
|
+
if (v == null || t != null && t >= v)
|
|
241
|
+
return;
|
|
242
|
+
const f = L.find((a) => !a.isDisabled && a.startMinutes >= v);
|
|
243
|
+
f && f.value !== o ? p(f.value) : !f && o && p("");
|
|
134
244
|
}, [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}, [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
245
|
+
L,
|
|
246
|
+
H,
|
|
247
|
+
I,
|
|
248
|
+
l,
|
|
249
|
+
o,
|
|
250
|
+
s,
|
|
251
|
+
J,
|
|
252
|
+
Z,
|
|
253
|
+
X,
|
|
254
|
+
R,
|
|
255
|
+
n,
|
|
256
|
+
p
|
|
257
|
+
]), F(() => (We(!0), () => {
|
|
258
|
+
b.current != null && clearTimeout(b.current);
|
|
259
|
+
}), []), F(() => {
|
|
260
|
+
re && ne && j(!1);
|
|
261
|
+
}, [ne, re]), F(() => {
|
|
262
|
+
ae && se && z(!1);
|
|
263
|
+
}, [se, ae]);
|
|
264
|
+
const _e = h((e) => {
|
|
265
|
+
e && ue.current && Date.now() < ue.current || j(e);
|
|
266
|
+
}, []), Qe = h((e) => {
|
|
267
|
+
e && ce.current && Date.now() < ce.current || z(e);
|
|
268
|
+
}, []), Ve = h((e) => {
|
|
269
|
+
e && fe.current && Date.now() < fe.current || oe(e);
|
|
270
|
+
}, []), Ye = h(
|
|
271
|
+
(e, {
|
|
272
|
+
openTimePicker: t,
|
|
273
|
+
openEndDatePicker: c,
|
|
274
|
+
close: u = !0
|
|
275
|
+
} = {}) => {
|
|
276
|
+
const v = t ?? C === "chained-times", S = c ?? C === "dates-first";
|
|
159
277
|
if (!e) {
|
|
160
|
-
|
|
278
|
+
u && j(!1);
|
|
161
279
|
return;
|
|
162
280
|
}
|
|
163
|
-
|
|
281
|
+
i(e), (u || S) && (ue.current = Date.now() + 250, j(!1)), m && e > m && _(e), v && ie(!0), S && (b.current != null && clearTimeout(b.current), W ? (z(!0), b.current = null) : b.current = setTimeout(() => {
|
|
282
|
+
z(!0);
|
|
283
|
+
}, 100));
|
|
164
284
|
},
|
|
165
|
-
[
|
|
166
|
-
),
|
|
285
|
+
[m, W, _, i, C]
|
|
286
|
+
), je = h(
|
|
167
287
|
(e) => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}, 100) :
|
|
288
|
+
M(e, "user"), ie(!1), b.current != null && clearTimeout(b.current), C === "chained-times" && e && r ? b.current = setTimeout(() => {
|
|
289
|
+
z(!0);
|
|
290
|
+
}, 100) : b.current = null;
|
|
171
291
|
},
|
|
172
|
-
[
|
|
173
|
-
),
|
|
292
|
+
[C, r, M]
|
|
293
|
+
), Ge = h(
|
|
174
294
|
(e) => {
|
|
175
|
-
e && e !==
|
|
295
|
+
e && e !== n && M(e, "user");
|
|
176
296
|
},
|
|
177
|
-
[
|
|
178
|
-
),
|
|
179
|
-
(e, {
|
|
180
|
-
|
|
297
|
+
[n, M]
|
|
298
|
+
), Je = h(
|
|
299
|
+
(e, {
|
|
300
|
+
openTimePicker: t,
|
|
301
|
+
close: c = !0,
|
|
302
|
+
commit: u = C === "dates-first" ? W : !1
|
|
303
|
+
} = {}) => {
|
|
304
|
+
const v = t ?? C === "chained-times";
|
|
305
|
+
let S = o;
|
|
306
|
+
if (e && C === "dates-first") {
|
|
307
|
+
if (s) {
|
|
308
|
+
const a = k(e);
|
|
309
|
+
a && ($.current = a);
|
|
310
|
+
}
|
|
311
|
+
const f = Ce(e);
|
|
312
|
+
f && (S = f, p(f));
|
|
313
|
+
}
|
|
314
|
+
_(e), le(void 0), c && (ce.current = Date.now() + 250, z(!1)), e && v && oe(!0), e && u && Q && (typeof window > "u" ? Q(e, S) : requestAnimationFrame(() => Q(e, S)));
|
|
315
|
+
},
|
|
316
|
+
[
|
|
317
|
+
o,
|
|
318
|
+
s,
|
|
319
|
+
Ce,
|
|
320
|
+
W,
|
|
321
|
+
_,
|
|
322
|
+
Q,
|
|
323
|
+
C,
|
|
324
|
+
k,
|
|
325
|
+
p
|
|
326
|
+
]
|
|
327
|
+
), Xe = h(
|
|
328
|
+
(e) => {
|
|
329
|
+
p(e, "user");
|
|
181
330
|
},
|
|
182
|
-
[
|
|
183
|
-
),
|
|
184
|
-
c(e);
|
|
185
|
-
}, [c]), Be = d(
|
|
331
|
+
[p]
|
|
332
|
+
), et = h(
|
|
186
333
|
(e) => {
|
|
187
|
-
|
|
188
|
-
requestAnimationFrame(
|
|
334
|
+
$.current = void 0, p(e, "user"), fe.current = Date.now() + 250, oe(!1), V && (typeof window > "u" ? V() : requestAnimationFrame(() => {
|
|
335
|
+
requestAnimationFrame(V);
|
|
189
336
|
}));
|
|
190
337
|
},
|
|
191
|
-
[
|
|
338
|
+
[V, p]
|
|
192
339
|
);
|
|
193
340
|
return {
|
|
194
|
-
startDate:
|
|
195
|
-
startTime:
|
|
196
|
-
endDate:
|
|
197
|
-
endTime:
|
|
198
|
-
errors:
|
|
199
|
-
labels:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
341
|
+
startDate: r,
|
|
342
|
+
startTime: n,
|
|
343
|
+
endDate: m,
|
|
344
|
+
endTime: o,
|
|
345
|
+
errors: Pe,
|
|
346
|
+
labels: Fe ?? Tt,
|
|
347
|
+
t: ke,
|
|
348
|
+
language: pe ?? Y,
|
|
349
|
+
labelClassName: Ae,
|
|
350
|
+
inputClassName: Be,
|
|
351
|
+
buttonClassName: Ie,
|
|
352
|
+
currencyCode: Le,
|
|
353
|
+
localeCode: Y,
|
|
354
|
+
slotIntervalMinutes: R,
|
|
355
|
+
dateLocale: Ke,
|
|
356
|
+
numberOfMonths: W ? 1 : 2,
|
|
357
|
+
isMobile: W,
|
|
358
|
+
isHydrated: Ue,
|
|
359
|
+
openDatePickerOnFocus: Re,
|
|
360
|
+
isStartDatePopoverOpen: ne,
|
|
361
|
+
setIsStartDatePopoverOpen: _e,
|
|
362
|
+
isStartTimeSelectOpen: re,
|
|
363
|
+
setIsStartTimeSelectOpen: ie,
|
|
364
|
+
isEndDatePopoverOpen: se,
|
|
365
|
+
setIsEndDatePopoverOpen: Qe,
|
|
366
|
+
isEndTimeSelectOpen: ae,
|
|
367
|
+
setIsEndTimeSelectOpen: Ve,
|
|
368
|
+
hoveredEndDate: He,
|
|
369
|
+
setHoveredEndDate: le,
|
|
370
|
+
resetHoveredEndDate: qe,
|
|
371
|
+
startTimeSlots: w,
|
|
372
|
+
availableEndTimeSlots: L,
|
|
373
|
+
isStartToday: B,
|
|
374
|
+
isEndToday: Z,
|
|
375
|
+
minSelectableDate: Ze,
|
|
376
|
+
earliestMinutesForToday: I,
|
|
377
|
+
startMinutesValue: $e,
|
|
378
|
+
isSameDaySelection: X,
|
|
379
|
+
updateStartTime: Ge,
|
|
380
|
+
selectStartDate: Ye,
|
|
381
|
+
selectStartTime: je,
|
|
382
|
+
selectEndDate: Je,
|
|
383
|
+
updateEndTime: Xe,
|
|
384
|
+
selectEndTime: et
|
|
233
385
|
};
|
|
234
386
|
};
|
|
235
387
|
export {
|
|
236
|
-
|
|
388
|
+
Ot as useBookingPeriodController
|
|
237
389
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -586,6 +586,10 @@ declare type BookingFlowStepsProps = {
|
|
|
586
586
|
|
|
587
587
|
export declare type BookingFulfillment = "pickup" | "delivery";
|
|
588
588
|
|
|
589
|
+
export declare type BookingPeriodChangeMeta = {
|
|
590
|
+
source: "user" | "auto";
|
|
591
|
+
};
|
|
592
|
+
|
|
589
593
|
declare type BookingPeriodConfig = {
|
|
590
594
|
timing: BookingTimingConfig;
|
|
591
595
|
openingHours: StoreOpeningHours;
|
|
@@ -598,11 +602,12 @@ export declare interface BookingPeriodControllerOptions {
|
|
|
598
602
|
startDate?: Date;
|
|
599
603
|
onStartDateChange: (date?: Date) => void;
|
|
600
604
|
startTime?: string;
|
|
601
|
-
onStartTimeChange: (time: string) => void;
|
|
605
|
+
onStartTimeChange: (time: string, meta?: BookingPeriodChangeMeta) => void;
|
|
602
606
|
endDate?: Date;
|
|
603
607
|
onEndDateChange: (date?: Date) => void;
|
|
604
608
|
endTime?: string;
|
|
605
|
-
onEndTimeChange: (time: string) => void;
|
|
609
|
+
onEndTimeChange: (time: string, meta?: BookingPeriodChangeMeta) => void;
|
|
610
|
+
onEndDateCommit?: (date?: Date, endTime?: string) => void;
|
|
606
611
|
onEndTimeCommit?: () => void;
|
|
607
612
|
errors?: {
|
|
608
613
|
startDate?: string;
|
|
@@ -610,10 +615,15 @@ export declare interface BookingPeriodControllerOptions {
|
|
|
610
615
|
endDate?: string;
|
|
611
616
|
endTime?: string;
|
|
612
617
|
};
|
|
613
|
-
labels
|
|
618
|
+
labels?: BookingPeriodLabels;
|
|
619
|
+
t?: BookingPeriodTranslator;
|
|
620
|
+
language?: string;
|
|
614
621
|
labelClassName?: string;
|
|
615
622
|
inputClassName?: string;
|
|
623
|
+
buttonClassName?: string;
|
|
616
624
|
bookingPeriodConfig?: BookingPeriodConfig;
|
|
625
|
+
fetchTimeSlots?: BookingPeriodTimeSlotsFetcher;
|
|
626
|
+
selectionFlow?: BookingPeriodSelectionFlow;
|
|
617
627
|
currencyCode?: string;
|
|
618
628
|
disableAutomaticTimeCorrection?: boolean;
|
|
619
629
|
openDatePickerOnFocus?: boolean;
|
|
@@ -630,13 +640,17 @@ export declare interface BookingPeriodControllerValue {
|
|
|
630
640
|
endTime?: string;
|
|
631
641
|
errors: NonNullable<BookingPeriodControllerOptions["errors"]>;
|
|
632
642
|
labels: BookingPeriodLabels;
|
|
643
|
+
t: BookingPeriodTranslator;
|
|
644
|
+
language: string;
|
|
633
645
|
labelClassName?: string;
|
|
634
646
|
inputClassName?: string;
|
|
647
|
+
buttonClassName?: string;
|
|
635
648
|
currencyCode: string;
|
|
636
649
|
localeCode: string;
|
|
637
650
|
slotIntervalMinutes: number;
|
|
638
651
|
dateLocale: Locale;
|
|
639
652
|
numberOfMonths: number;
|
|
653
|
+
isMobile: boolean;
|
|
640
654
|
isHydrated: boolean;
|
|
641
655
|
openDatePickerOnFocus: boolean;
|
|
642
656
|
isStartDatePopoverOpen: boolean;
|
|
@@ -654,6 +668,7 @@ export declare interface BookingPeriodControllerValue {
|
|
|
654
668
|
availableEndTimeSlots: TimeSlot[];
|
|
655
669
|
isStartToday: boolean;
|
|
656
670
|
isEndToday: boolean;
|
|
671
|
+
minSelectableDate: Date;
|
|
657
672
|
earliestMinutesForToday: number | null;
|
|
658
673
|
startMinutesValue: number | null;
|
|
659
674
|
isSameDaySelection: boolean;
|
|
@@ -664,10 +679,14 @@ export declare interface BookingPeriodControllerValue {
|
|
|
664
679
|
updateStartTime: (value: string) => void;
|
|
665
680
|
selectStartDate: (date: Date | undefined, options?: {
|
|
666
681
|
openTimePicker?: boolean;
|
|
682
|
+
openEndDatePicker?: boolean;
|
|
683
|
+
close?: boolean;
|
|
667
684
|
}) => void;
|
|
668
685
|
selectStartTime: (value: string) => void;
|
|
669
686
|
selectEndDate: (date: Date | undefined, options?: {
|
|
670
687
|
openTimePicker?: boolean;
|
|
688
|
+
close?: boolean;
|
|
689
|
+
commit?: boolean;
|
|
671
690
|
}) => void;
|
|
672
691
|
/**
|
|
673
692
|
* Immediate committed update.
|
|
@@ -704,12 +723,18 @@ declare type BookingPeriodProviderProps = BookingPeriodControllerOptions & {
|
|
|
704
723
|
children: ReactNode;
|
|
705
724
|
};
|
|
706
725
|
|
|
726
|
+
export declare type BookingPeriodSelectionFlow = "chained-times" | "dates-first";
|
|
727
|
+
|
|
707
728
|
export declare const BookingPeriodSelector: ({ className, ...options }: BookingPeriodSelectorProps) => JSX.Element;
|
|
708
729
|
|
|
709
730
|
declare type BookingPeriodSelectorProps = BookingPeriodControllerOptions & {
|
|
710
731
|
className?: string;
|
|
711
732
|
};
|
|
712
733
|
|
|
734
|
+
export declare type BookingPeriodTimeSlotsFetcher = (date: string, journey: JourneyType) => Promise<TimeSlot[] | null>;
|
|
735
|
+
|
|
736
|
+
export declare type BookingPeriodTranslator = (key: string, options?: Record<string, unknown>) => string;
|
|
737
|
+
|
|
713
738
|
export declare type BookingScheduleInput = z.infer<typeof bookingScheduleInputSchema>;
|
|
714
739
|
|
|
715
740
|
export declare const bookingScheduleInputSchema: z.ZodObject<{
|
|
@@ -1682,6 +1707,8 @@ export declare function isProductVariantCodeIdentifierKind(kind: string): boolea
|
|
|
1682
1707
|
|
|
1683
1708
|
export declare const isStorefrontAvailabilityInsufficient: (record: StorefrontPublicAvailabilityRecord | undefined) => boolean;
|
|
1684
1709
|
|
|
1710
|
+
declare type JourneyType = "start" | "end";
|
|
1711
|
+
|
|
1685
1712
|
export declare const Label: React_2.ForwardRefExoticComponent<React_2.LabelHTMLAttributes<HTMLLabelElement> & VariantProps<(props?: ClassProp | undefined) => string> & React_2.RefAttributes<HTMLLabelElement>>;
|
|
1686
1713
|
|
|
1687
1714
|
export declare function Layout({ storefrontConfiguration }: LayoutProps): JSX.Element;
|
|
@@ -2467,6 +2494,14 @@ export declare type ResponsePayload = z.infer<typeof responseSchema>;
|
|
|
2467
2494
|
export declare const responseSchema: z.ZodObject<{
|
|
2468
2495
|
success: z.ZodBoolean;
|
|
2469
2496
|
error: z.ZodOptional<z.ZodString>;
|
|
2497
|
+
emailPayload: z.ZodOptional<z.ZodObject<{
|
|
2498
|
+
from: z.ZodString;
|
|
2499
|
+
replyTo: z.ZodOptional<z.ZodString>;
|
|
2500
|
+
to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
2501
|
+
subject: z.ZodString;
|
|
2502
|
+
html: z.ZodOptional<z.ZodString>;
|
|
2503
|
+
text: z.ZodOptional<z.ZodString>;
|
|
2504
|
+
}, z.core.$strip>>;
|
|
2470
2505
|
}, z.core.$strip>;
|
|
2471
2506
|
|
|
2472
2507
|
export declare type RichText = z.infer<typeof richTextSchema>;
|
|
@@ -11,6 +11,14 @@ export type RequestPayload = z.infer<typeof requestSchema>;
|
|
|
11
11
|
export declare const responseSchema: z.ZodObject<{
|
|
12
12
|
success: z.ZodBoolean;
|
|
13
13
|
error: z.ZodOptional<z.ZodString>;
|
|
14
|
+
emailPayload: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
from: z.ZodString;
|
|
16
|
+
replyTo: z.ZodOptional<z.ZodString>;
|
|
17
|
+
to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
18
|
+
subject: z.ZodString;
|
|
19
|
+
html: z.ZodOptional<z.ZodString>;
|
|
20
|
+
text: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
14
22
|
}, z.core.$strip>;
|
|
15
23
|
export type ResponsePayload = z.infer<typeof responseSchema>;
|
|
16
24
|
//# sourceMappingURL=contactForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contactForm.d.ts","sourceRoot":"","sources":["../../src/lib/contactForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,KAAK,wCAAwC,CAAA;AAE1D,eAAO,MAAM,aAAa;;;;;;iBAMxB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"contactForm.d.ts","sourceRoot":"","sources":["../../src/lib/contactForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,KAAK,wCAAwC,CAAA;AAE1D,eAAO,MAAM,aAAa;;;;;;iBAMxB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAW1D,eAAO,MAAM,cAAc;;;;;;;;;;;iBAIzB,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
package/dist/lib/contactForm.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { z as
|
|
2
|
-
const
|
|
3
|
-
storeSlug:
|
|
4
|
-
name:
|
|
5
|
-
emailAddress:
|
|
6
|
-
phoneNumber:
|
|
7
|
-
message:
|
|
8
|
-
}),
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { z as t } from "zod";
|
|
2
|
+
const i = "/api/public/storefront/contact-form", n = t.object({
|
|
3
|
+
storeSlug: t.string().trim().min(1).toLowerCase(),
|
|
4
|
+
name: t.string().trim().min(1),
|
|
5
|
+
emailAddress: t.string().trim().email(),
|
|
6
|
+
phoneNumber: t.string().trim().min(6),
|
|
7
|
+
message: t.string().trim().min(1).max(8192)
|
|
8
|
+
}), o = t.object({
|
|
9
|
+
from: t.string(),
|
|
10
|
+
replyTo: t.string().optional(),
|
|
11
|
+
to: t.union([t.string(), t.array(t.string())]),
|
|
12
|
+
subject: t.string(),
|
|
13
|
+
html: t.string().optional(),
|
|
14
|
+
text: t.string().optional()
|
|
15
|
+
}), e = t.object({
|
|
16
|
+
success: t.boolean(),
|
|
17
|
+
error: t.string().optional(),
|
|
18
|
+
emailPayload: o.optional()
|
|
11
19
|
});
|
|
12
20
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
i as ROUTE,
|
|
22
|
+
n as requestSchema,
|
|
23
|
+
e as responseSchema
|
|
16
24
|
};
|