@loczer/storefront-sdk 0.150.0 → 0.152.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.
Files changed (28) hide show
  1. package/dist/StorefrontProvider.d.ts +20 -0
  2. package/dist/booking-period-time-slots.d.ts +23 -38
  3. package/dist/booking-period.d.ts +20 -0
  4. package/dist/booking.d.ts +18 -0
  5. package/dist/checkoutSubmit.d.ts +36 -0
  6. package/dist/chunks/pkg/booking-engine/dist/schemas/{booking-engine-configuration-CnBdp3jk.js → booking-engine-configuration-BKlzwJJX.js} +20 -19
  7. package/dist/chunks/pkg/booking-engine/dist/schemas/{cart-inputs-DYgEGJ5M.js → cart-inputs-ByBK0IVJ.js} +2 -2
  8. package/dist/chunks/pkg/booking-engine/dist/schemas/{public-booking-engine-configuration-C9VB-WhU.js → public-booking-engine-configuration-DKoak4s5.js} +2 -2
  9. package/dist/chunks/pkg/booking-engine/dist/schemas/shop-opening-hours-DqNWstqT.js +51 -0
  10. package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +76 -80
  11. package/dist/index.js +308 -298
  12. package/dist/lib/booking-period-time-slots.d.ts +0 -31
  13. package/dist/lib/booking-period-time-slots.js +122 -221
  14. package/dist/lib/booking-period.d.ts +14 -0
  15. package/dist/lib/booking-period.js +168 -150
  16. package/dist/lib/booking.d.ts +3 -0
  17. package/dist/lib/booking.js +102 -89
  18. package/dist/lib/checkoutSubmit.d.ts +34 -0
  19. package/dist/lib/checkoutSubmit.js +17 -15
  20. package/dist/lib/storefrontTimeSlots.d.ts +43 -0
  21. package/dist/lib/storefrontTimeSlots.js +26 -0
  22. package/dist/storefront.css +1 -1
  23. package/dist/storefrontSchemas.d.ts +8 -0
  24. package/dist/storefrontSchemas.js +4 -4
  25. package/dist/storefrontTimeSlots.d.ts +53 -0
  26. package/dist/whatsapp.d.ts +8 -0
  27. package/package.json +1 -1
  28. package/dist/chunks/pkg/booking-engine/dist/schemas/shop-opening-hours-B47MMaoD.js +0 -45
@@ -1,18 +1,18 @@
1
1
  import { useMemo as l, useState as O, useRef as q, useCallback as d, useEffect as P } from "react";
2
- import { differenceInCalendarDays as ee } from "date-fns";
3
- import { fr as Fe, de as He, es as Re, it as Ue, enUS as Ae } from "date-fns/locale";
4
- import { useMediaQuery as Le } from "@rpcbase/client";
5
- import { parseTimeToMinutes as M, dateToBusinessDateString as We } from "../../lib/booking-period.js";
6
- import { getBookingPeriodTimeSlotsSync as qe } from "../../lib/booking-period-time-slots.js";
7
- const Ne = ({
2
+ import { differenceInCalendarDays as _ } from "date-fns";
3
+ import { fr as ke, de as Fe, es as xe, it as He, enUS as Re } from "date-fns/locale";
4
+ import { useMediaQuery as Ue } from "@rpcbase/client";
5
+ import { parseTimeToMinutes as M, dateToBusinessDateString as Ae } from "../../lib/booking-period.js";
6
+ import { getBookingPeriodTimeSlotsSync as Le } from "../../lib/booking-period-time-slots.js";
7
+ const We = ({
8
8
  locale: u,
9
9
  localeCode: n
10
10
  }) => {
11
11
  if (u)
12
12
  return u;
13
13
  const s = n?.toLowerCase() ?? "";
14
- return s.startsWith("fr") ? Fe : s.startsWith("de") ? He : s.startsWith("es") ? Re : s.startsWith("it") ? Ue : Ae;
15
- }, ze = (u) => {
14
+ return s.startsWith("fr") ? ke : s.startsWith("de") ? Fe : s.startsWith("es") ? xe : s.startsWith("it") ? He : Re;
15
+ }, qe = (u) => {
16
16
  if (!u?.length)
17
17
  return null;
18
18
  const n = u.map((t) => M(t.value)).filter((t) => typeof t == "number").sort((t, C) => t - C);
@@ -20,16 +20,16 @@ const Ne = ({
20
20
  return null;
21
21
  const s = n[1] - n[0];
22
22
  return !Number.isFinite(s) || s <= 0 ? null : s;
23
- }, $e = (u) => {
23
+ }, Ne = (u) => {
24
24
  if (typeof u != "string")
25
25
  return null;
26
26
  const n = u.match(/(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})/);
27
27
  return n ? M(n[2]) : null;
28
- }, ue = (u, n) => u.map((s) => {
28
+ }, ae = (u, n) => u.map((s) => {
29
29
  const t = M(s.value);
30
30
  if (t == null)
31
31
  return null;
32
- const C = $e(s.label) ?? t + n, o = typeof s.label == "string" ? s.label : s.value;
32
+ const C = Ne(s.label) ?? t + n, o = typeof s.label == "string" ? s.label : s.value;
33
33
  return {
34
34
  value: s.value,
35
35
  label: o,
@@ -38,65 +38,61 @@ const Ne = ({
38
38
  isExtra: !1,
39
39
  isDisabled: !!s.disabled
40
40
  };
41
- }).filter((s) => !!s), Ke = (u) => {
41
+ }).filter((s) => !!s), Je = (u) => {
42
42
  const {
43
43
  startDate: n,
44
44
  onStartDateChange: s,
45
45
  startTime: t,
46
46
  onStartTimeChange: C,
47
47
  endDate: o,
48
- onEndDateChange: x,
48
+ onEndDateChange: F,
49
49
  endTime: f,
50
50
  onEndTimeChange: c,
51
- onEndTimeCommit: F,
52
- errors: oe = {},
53
- labels: fe,
54
- labelClassName: ce,
55
- inputClassName: de,
51
+ onEndTimeCommit: x,
52
+ errors: le = {},
53
+ labels: ue,
54
+ labelClassName: oe,
55
+ inputClassName: fe,
56
56
  bookingPeriodConfig: a,
57
- currencyCode: me = "EUR",
58
- showEndExtraSlots: te = !0,
57
+ currencyCode: ce = "EUR",
59
58
  disableAutomaticTimeCorrection: w = !1,
60
- openDatePickerOnFocus: Se = !0,
59
+ openDatePickerOnFocus: de = !0,
61
60
  startTimeOptions: y = [],
62
- endTimeOptions: ne,
63
- locale: re,
61
+ endTimeOptions: ee,
62
+ locale: te,
64
63
  localeCode: N
65
- } = u, De = Le("(max-width: 767px)"), pe = l(() => Ne({ locale: re, localeCode: N }), [re, N]), ve = N ?? "en-US", b = l(() => a?.timing.slotIntervalMinutes ? a.timing.slotIntervalMinutes : ze(y) ?? 30, [a?.timing.slotIntervalMinutes, y]), [z, H] = O(!1), [$, Q] = O(!1), [V, R] = O(!1), [Z, j] = O(!1), [Te, G] = O(void 0), [Me, be] = O(!1), [se, ge] = O(!1), I = q(null), J = q(0), K = q(0), X = q(0), he = d(() => {
64
+ } = u, me = Ue("(max-width: 767px)"), Se = l(() => We({ locale: te, localeCode: N }), [te, N]), De = N ?? "en-US", b = l(() => a?.timing.slotIntervalMinutes ? a.timing.slotIntervalMinutes : qe(y) ?? 30, [a?.timing.slotIntervalMinutes, y]), [z, H] = O(!1), [$, Q] = O(!1), [V, R] = O(!1), [Z, j] = O(!1), [pe, G] = O(void 0), [ve, Te] = O(!1), [ne, Me] = O(!1), I = q(null), J = q(0), K = q(0), X = q(0), be = d(() => {
66
65
  G(void 0);
67
- }, []), U = l(() => !n || !o ? !1 : ee(o, n) === 0, [n, o]), Ee = l(() => M(t), [t]), D = l(
68
- () => !!n && ee(n, /* @__PURE__ */ new Date()) === 0,
66
+ }, []), U = l(() => !n || !o ? !1 : _(o, n) === 0, [n, o]), ge = l(() => M(t), [t]), D = l(
67
+ () => !!n && _(n, /* @__PURE__ */ new Date()) === 0,
69
68
  [n]
70
69
  ), B = l(
71
- () => !!o && ee(o, /* @__PURE__ */ new Date()) === 0,
70
+ () => !!o && _(o, /* @__PURE__ */ new Date()) === 0,
72
71
  [o]
73
- ), ie = l(() => {
72
+ ), re = l(() => {
74
73
  if (!D && !B) return null;
75
74
  const e = /* @__PURE__ */ new Date(), i = a?.timing.minBufferMinutes ?? 10;
76
75
  return e.setMinutes(e.getMinutes() + i), `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}`;
77
- }, [a?.timing.minBufferMinutes, B, D]), p = l(() => M(ie), [ie]), Y = l(() => D ? p : null, [p, D]), ae = l(() => {
76
+ }, [a?.timing.minBufferMinutes, B, D]), p = l(() => M(re), [re]), Y = l(() => D ? p : null, [p, D]), se = l(() => {
78
77
  if (!a)
79
78
  return;
80
79
  const i = (n instanceof Date ? n : n ? new Date(n) : void 0) ?? /* @__PURE__ */ new Date();
81
- return We(i, a.timeZone) ?? void 0;
82
- }, [a, n]), A = l(() => a ? qe(a, {
83
- date: ae
84
- }) : null, [a, ae]), S = l(() => a ? A?.startTimeSlots ?? [] : ue(y, b), [a, A?.startTimeSlots, b, y]), _ = l(() => a ? A?.endTimeSlots ?? [] : ue(ne ?? y, b), [a, A?.endTimeSlots, ne, b, y]), g = l(
85
- () => te ? _ : _.filter((e) => !e.isExtra),
86
- [_, te]
87
- ), m = d(
80
+ return Ae(i, a.timeZone) ?? void 0;
81
+ }, [a, n]), A = l(() => a ? Le(a, {
82
+ date: se
83
+ }) : null, [a, se]), S = l(() => a ? A?.startTimeSlots ?? [] : ae(y, b), [a, A?.startTimeSlots, b, y]), g = l(() => a ? A?.endTimeSlots ?? [] : ae(ee ?? y, b), [a, A?.endTimeSlots, ee, b, y]), m = d(
88
84
  (e, i) => {
89
- ge(i === "user"), C(e);
85
+ Me(i === "user"), C(e);
90
86
  },
91
87
  [C]
92
88
  ), L = l(() => S.length ? S.find((e) => !(e.isDisabled || Y != null && e.startMinutes < Y)) ?? null : null, [Y, S]);
93
89
  P(() => {
94
- w || se || L && t !== L.value && m(L.value, "auto");
95
- }, [w, L, se, t, m]), P(() => {
90
+ w || ne || L && t !== L.value && m(L.value, "auto");
91
+ }, [w, L, ne, t, m]), P(() => {
96
92
  if (w || !S.length)
97
93
  return;
98
94
  const e = t ? S.find((r) => r.value === t) : void 0, i = p ?? void 0, k = D ? i : null, h = (r) => {
99
- const E = typeof r == "number" ? r : null, W = S.find((le) => !(le.isDisabled || E != null && le.startMinutes < E));
95
+ const E = typeof r == "number" ? r : null, W = S.find((ie) => !(ie.isDisabled || E != null && ie.startMinutes < E));
100
96
  W && W.value !== t ? m(W.value, "auto") : !W && t && m("", "auto");
101
97
  };
102
98
  if (t && !e) {
@@ -145,97 +141,97 @@ const Ne = ({
145
141
  c,
146
142
  b,
147
143
  t
148
- ]), P(() => (be(!0), () => {
144
+ ]), P(() => (Te(!0), () => {
149
145
  I.current != null && clearTimeout(I.current);
150
146
  }), []), P(() => {
151
147
  $ && z && H(!1);
152
148
  }, [z, $]), P(() => {
153
149
  Z && V && R(!1);
154
150
  }, [V, Z]);
155
- const Oe = d((e) => {
151
+ const he = d((e) => {
156
152
  e && J.current && Date.now() < J.current || H(e);
157
- }, []), Ce = d((e) => {
153
+ }, []), Ee = d((e) => {
158
154
  e && K.current && Date.now() < K.current || R(e);
159
- }, []), we = d((e) => {
155
+ }, []), Oe = d((e) => {
160
156
  e && X.current && Date.now() < X.current || j(e);
161
- }, []), ye = d(
157
+ }, []), Ce = d(
162
158
  (e, { openTimePicker: i = !0 } = {}) => {
163
159
  if (!e) {
164
160
  H(!1);
165
161
  return;
166
162
  }
167
- s(e), J.current = Date.now() + 250, H(!1), o && e > o && x(e), i && Q(!0);
163
+ s(e), J.current = Date.now() + 250, H(!1), o && e > o && F(e), i && Q(!0);
168
164
  },
169
- [s, o, x]
170
- ), Ie = d(
165
+ [s, o, F]
166
+ ), we = d(
171
167
  (e) => {
172
168
  m(e, "user"), Q(!1), I.current != null && clearTimeout(I.current), e && n ? I.current = setTimeout(() => {
173
169
  R(!0);
174
170
  }, 100) : I.current = null;
175
171
  },
176
172
  [n, m]
177
- ), Pe = d(
173
+ ), ye = d(
178
174
  (e) => {
179
175
  e && e !== t && m(e, "user");
180
176
  },
181
177
  [t, m]
182
- ), Be = d(
178
+ ), Ie = d(
183
179
  (e, { openTimePicker: i = !0 } = {}) => {
184
- x(e), G(void 0), K.current = Date.now() + 250, R(!1), e && i && j(!0);
180
+ F(e), G(void 0), K.current = Date.now() + 250, R(!1), e && i && j(!0);
185
181
  },
186
- [x]
187
- ), ke = d((e) => {
182
+ [F]
183
+ ), Pe = d((e) => {
188
184
  c(e);
189
- }, [c]), xe = d(
185
+ }, [c]), Be = d(
190
186
  (e) => {
191
- c(e), X.current = Date.now() + 250, j(!1), F && (typeof window > "u" ? F() : requestAnimationFrame(() => {
192
- requestAnimationFrame(F);
187
+ c(e), X.current = Date.now() + 250, j(!1), x && (typeof window > "u" ? x() : requestAnimationFrame(() => {
188
+ requestAnimationFrame(x);
193
189
  }));
194
190
  },
195
- [c, F]
191
+ [c, x]
196
192
  );
197
193
  return {
198
194
  startDate: n,
199
195
  startTime: t,
200
196
  endDate: o,
201
197
  endTime: f,
202
- errors: oe,
203
- labels: fe,
204
- labelClassName: ce,
205
- inputClassName: de,
206
- currencyCode: me,
207
- localeCode: ve,
198
+ errors: le,
199
+ labels: ue,
200
+ labelClassName: oe,
201
+ inputClassName: fe,
202
+ currencyCode: ce,
203
+ localeCode: De,
208
204
  slotIntervalMinutes: b,
209
- dateLocale: pe,
210
- numberOfMonths: De ? 1 : 2,
211
- isHydrated: Me,
212
- openDatePickerOnFocus: Se,
205
+ dateLocale: Se,
206
+ numberOfMonths: me ? 1 : 2,
207
+ isHydrated: ve,
208
+ openDatePickerOnFocus: de,
213
209
  isStartDatePopoverOpen: z,
214
- setIsStartDatePopoverOpen: Oe,
210
+ setIsStartDatePopoverOpen: he,
215
211
  isStartTimeSelectOpen: $,
216
212
  setIsStartTimeSelectOpen: Q,
217
213
  isEndDatePopoverOpen: V,
218
- setIsEndDatePopoverOpen: Ce,
214
+ setIsEndDatePopoverOpen: Ee,
219
215
  isEndTimeSelectOpen: Z,
220
- setIsEndTimeSelectOpen: we,
221
- hoveredEndDate: Te,
216
+ setIsEndTimeSelectOpen: Oe,
217
+ hoveredEndDate: pe,
222
218
  setHoveredEndDate: G,
223
- resetHoveredEndDate: he,
219
+ resetHoveredEndDate: be,
224
220
  startTimeSlots: S,
225
221
  availableEndTimeSlots: g,
226
222
  isStartToday: D,
227
223
  isEndToday: B,
228
224
  earliestMinutesForToday: p,
229
- startMinutesValue: Ee,
225
+ startMinutesValue: ge,
230
226
  isSameDaySelection: U,
231
- updateStartTime: Pe,
232
- selectStartDate: ye,
233
- selectStartTime: Ie,
234
- selectEndDate: Be,
235
- updateEndTime: ke,
236
- selectEndTime: xe
227
+ updateStartTime: ye,
228
+ selectStartDate: Ce,
229
+ selectStartTime: we,
230
+ selectEndDate: Ie,
231
+ updateEndTime: Pe,
232
+ selectEndTime: Be
237
233
  };
238
234
  };
239
235
  export {
240
- Ke as useBookingPeriodController
236
+ Je as useBookingPeriodController
241
237
  };