@loczer/storefront-sdk 0.153.0 → 0.155.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 (50) hide show
  1. package/dist/components/BookingPeriodSelector/index.d.ts +1 -1
  2. package/dist/components/BookingPeriodSelector/index.d.ts.map +1 -1
  3. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts +25 -4
  4. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
  5. package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +344 -192
  6. package/dist/components/Footer/businessHoursUtils.d.ts.map +1 -1
  7. package/dist/components/Footer/businessHoursUtils.js +16 -16
  8. package/dist/components/StorefrontCartPanel/index.d.ts +2 -1
  9. package/dist/components/StorefrontCartPanel/index.d.ts.map +1 -1
  10. package/dist/components/StorefrontCartPanel/index.js +68 -63
  11. package/dist/i18n/en.d.ts +1 -0
  12. package/dist/i18n/en.d.ts.map +1 -1
  13. package/dist/i18n/en.js +1 -0
  14. package/dist/i18n/fr.d.ts +1 -0
  15. package/dist/i18n/fr.d.ts.map +1 -1
  16. package/dist/i18n/fr.js +1 -0
  17. package/dist/index.d.ts +78 -35
  18. package/dist/index.js +103 -100
  19. package/dist/lib/checkoutVerifyCoupon.d.ts +1 -0
  20. package/dist/lib/checkoutVerifyCoupon.d.ts.map +1 -1
  21. package/dist/lib/checkoutVerifyCoupon.js +1 -0
  22. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  23. package/dist/pages/CheckoutPage.js +56 -51
  24. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts +2 -2
  25. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts.map +1 -1
  26. package/dist/pages/checkout/components/CheckoutSummaryColumn.js +16 -14
  27. package/dist/storefront.css +1 -1
  28. package/dist/ui/button.d.ts +1 -1
  29. package/dist/ui/button.js +17 -17
  30. package/dist/ui/card.d.ts.map +1 -1
  31. package/dist/ui/card.js +8 -11
  32. package/dist/ui/form.d.ts +1 -1
  33. package/dist/ui/form.d.ts.map +1 -1
  34. package/dist/ui/form.js +52 -86
  35. package/dist/ui/radio-group.d.ts +10 -7
  36. package/dist/ui/radio-group.d.ts.map +1 -1
  37. package/dist/ui/radio-group.js +63 -45
  38. package/dist/ui/select.d.ts +29 -15
  39. package/dist/ui/select.d.ts.map +1 -1
  40. package/dist/ui/select.js +158 -232
  41. package/dist/ui/slot.d.ts +3 -7
  42. package/dist/ui/slot.d.ts.map +1 -1
  43. package/dist/ui/slot.js +47 -27
  44. package/dist/ui/theme.d.ts +9 -0
  45. package/dist/ui/theme.d.ts.map +1 -0
  46. package/dist/ui/theme.js +24 -0
  47. package/dist/ui/tooltip.d.ts +30 -13
  48. package/dist/ui/tooltip.d.ts.map +1 -1
  49. package/dist/ui/tooltip.js +89 -60
  50. package/package.json +1 -1
@@ -1,237 +1,389 @@
1
- import { useMemo as l, useState as O, useRef as q, useCallback as d, useEffect as P } from "react";
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
- locale: u,
9
- localeCode: n
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 (u)
12
- return u;
13
- const s = n?.toLowerCase() ?? "";
14
- return s.startsWith("fr") ? ke : s.startsWith("de") ? Fe : s.startsWith("es") ? xe : s.startsWith("it") ? He : Re;
15
- }, qe = (u) => {
16
- if (!u?.length)
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 n = u.map((t) => M(t.value)).filter((t) => typeof t == "number").sort((t, C) => t - C);
19
- if (n.length < 2)
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 s = n[1] - n[0];
22
- return !Number.isFinite(s) || s <= 0 ? null : s;
23
- }, Ne = (u) => {
24
- if (typeof u != "string")
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 n = u.match(/(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})/);
27
- return n ? M(n[2]) : null;
28
- }, ae = (u, n) => u.map((s) => {
29
- const t = M(s.value);
30
- if (t == null)
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 C = Ne(s.label) ?? t + n, o = typeof s.label == "string" ? s.label : s.value;
39
+ const K = vt(i.label) ?? n + r, m = typeof i.label == "string" ? i.label : i.value;
33
40
  return {
34
- value: s.value,
35
- label: o,
36
- startMinutes: t,
37
- endMinutes: C,
41
+ value: i.value,
42
+ label: m,
43
+ startMinutes: n,
44
+ endMinutes: K,
38
45
  isExtra: !1,
39
- isDisabled: !!s.disabled
46
+ isDisabled: !!i.disabled
40
47
  };
41
- }).filter((s) => !!s), Je = (u) => {
48
+ }).filter((i) => !!i), Ot = (T) => {
42
49
  const {
43
- startDate: n,
44
- onStartDateChange: s,
45
- startTime: t,
46
- onStartTimeChange: C,
47
- endDate: o,
48
- onEndDateChange: F,
49
- endTime: f,
50
- onEndTimeChange: c,
51
- onEndTimeCommit: x,
52
- errors: le = {},
53
- labels: ue,
54
- labelClassName: oe,
55
- inputClassName: fe,
56
- bookingPeriodConfig: a,
57
- currencyCode: ce = "EUR",
58
- disableAutomaticTimeCorrection: w = !1,
59
- openDatePickerOnFocus: de = !0,
60
- startTimeOptions: y = [],
61
- endTimeOptions: ee,
62
- locale: te,
63
- localeCode: N
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(() => {
65
- G(void 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,
68
- [n]
69
- ), B = l(
70
- () => !!o && _(o, /* @__PURE__ */ new Date()) === 0,
71
- [o]
72
- ), re = l(() => {
73
- if (!D && !B) return null;
74
- const e = /* @__PURE__ */ new Date(), i = a?.timing.minBufferMinutes ?? 10;
75
- return e.setMinutes(e.getMinutes() + i), `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}`;
76
- }, [a?.timing.minBufferMinutes, B, D]), p = l(() => M(re), [re]), Y = l(() => D ? p : null, [p, D]), se = l(() => {
77
- if (!a)
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
- const i = (n instanceof Date ? n : n ? new Date(n) : void 0) ?? /* @__PURE__ */ new Date();
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(
84
- (e, i) => {
85
- Me(i === "user"), C(e);
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
- [C]
88
- ), L = l(() => S.length ? S.find((e) => !(e.isDisabled || Y != null && e.startMinutes < Y)) ?? null : null, [Y, S]);
89
- P(() => {
90
- w || ne || L && t !== L.value && m(L.value, "auto");
91
- }, [w, L, ne, t, m]), P(() => {
92
- if (w || !S.length)
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 = t ? S.find((r) => r.value === t) : void 0, i = p ?? void 0, k = D ? i : null, h = (r) => {
95
- const E = typeof r == "number" ? r : null, W = S.find((ie) => !(ie.isDisabled || E != null && ie.startMinutes < E));
96
- W && W.value !== t ? m(W.value, "auto") : !W && t && m("", "auto");
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 (t && !e) {
99
- h(k);
194
+ if (n && !e) {
195
+ u(c);
100
196
  return;
101
197
  }
102
198
  if (e?.isDisabled) {
103
- h(k);
199
+ u(c);
104
200
  return;
105
201
  }
106
- if (!D || i == null)
202
+ if (!B || t == null)
107
203
  return;
108
- const v = M(t);
109
- if (v != null && v >= i && !e?.isDisabled)
204
+ const v = x(n);
205
+ if (v != null && v >= t && !e?.isDisabled)
110
206
  return;
111
- const T = S.find((r) => !r.isDisabled && r.startMinutes >= i);
112
- T && T.value !== t && m(T.value, "auto");
113
- }, [w, p, D, t, S, m]), P(() => {
114
- if (w || !g.length)
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
- const e = M(t), i = M(f), k = f ? g.find((r) => r.value === f) : void 0;
117
- if (U && e != null && i != null && i < e) {
118
- const r = [...g].reverse().find((E) => !E.isDisabled);
119
- r && r.value !== f ? c(r.value) : !r && f && c("");
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 h = [];
123
- B && p != null && h.push(p), U && e != null && h.push(e + b);
124
- const v = h.length ? Math.max(...h) : null;
125
- if (k?.isDisabled) {
126
- const r = g.find((E) => !(E.isDisabled || v != null && E.startMinutes < v));
127
- r && r.value !== f ? c(r.value) : !r && f && c("");
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 (v == null || i != null && i >= v)
236
+ if (c?.isDisabled) {
237
+ S(v);
131
238
  return;
132
- const T = g.find((r) => !r.isDisabled && r.startMinutes >= v);
133
- T && T.value !== f ? c(T.value) : !T && f && c("");
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
- g,
136
- w,
137
- p,
138
- f,
139
- B,
140
- U,
141
- c,
142
- b,
143
- t
144
- ]), P(() => (Te(!0), () => {
145
- I.current != null && clearTimeout(I.current);
146
- }), []), P(() => {
147
- $ && z && H(!1);
148
- }, [z, $]), P(() => {
149
- Z && V && R(!1);
150
- }, [V, Z]);
151
- const he = d((e) => {
152
- e && J.current && Date.now() < J.current || H(e);
153
- }, []), Ee = d((e) => {
154
- e && K.current && Date.now() < K.current || R(e);
155
- }, []), Oe = d((e) => {
156
- e && X.current && Date.now() < X.current || j(e);
157
- }, []), Ce = d(
158
- (e, { openTimePicker: i = !0 } = {}) => {
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
- H(!1);
278
+ u && j(!1);
161
279
  return;
162
280
  }
163
- s(e), J.current = Date.now() + 250, H(!1), o && e > o && F(e), i && Q(!0);
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
- [s, o, F]
166
- ), we = d(
285
+ [m, W, _, i, C]
286
+ ), je = h(
167
287
  (e) => {
168
- m(e, "user"), Q(!1), I.current != null && clearTimeout(I.current), e && n ? I.current = setTimeout(() => {
169
- R(!0);
170
- }, 100) : I.current = null;
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
- [n, m]
173
- ), ye = d(
292
+ [C, r, M]
293
+ ), Ge = h(
174
294
  (e) => {
175
- e && e !== t && m(e, "user");
295
+ e && e !== n && M(e, "user");
176
296
  },
177
- [t, m]
178
- ), Ie = d(
179
- (e, { openTimePicker: i = !0 } = {}) => {
180
- F(e), G(void 0), K.current = Date.now() + 250, R(!1), e && i && j(!0);
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
- [F]
183
- ), Pe = d((e) => {
184
- c(e);
185
- }, [c]), Be = d(
331
+ [p]
332
+ ), et = h(
186
333
  (e) => {
187
- c(e), X.current = Date.now() + 250, j(!1), x && (typeof window > "u" ? x() : requestAnimationFrame(() => {
188
- requestAnimationFrame(x);
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
- [c, x]
338
+ [V, p]
192
339
  );
193
340
  return {
194
- startDate: n,
195
- startTime: t,
196
- endDate: o,
197
- endTime: f,
198
- errors: le,
199
- labels: ue,
200
- labelClassName: oe,
201
- inputClassName: fe,
202
- currencyCode: ce,
203
- localeCode: De,
204
- slotIntervalMinutes: b,
205
- dateLocale: Se,
206
- numberOfMonths: me ? 1 : 2,
207
- isHydrated: ve,
208
- openDatePickerOnFocus: de,
209
- isStartDatePopoverOpen: z,
210
- setIsStartDatePopoverOpen: he,
211
- isStartTimeSelectOpen: $,
212
- setIsStartTimeSelectOpen: Q,
213
- isEndDatePopoverOpen: V,
214
- setIsEndDatePopoverOpen: Ee,
215
- isEndTimeSelectOpen: Z,
216
- setIsEndTimeSelectOpen: Oe,
217
- hoveredEndDate: pe,
218
- setHoveredEndDate: G,
219
- resetHoveredEndDate: be,
220
- startTimeSlots: S,
221
- availableEndTimeSlots: g,
222
- isStartToday: D,
223
- isEndToday: B,
224
- earliestMinutesForToday: p,
225
- startMinutesValue: ge,
226
- isSameDaySelection: U,
227
- updateStartTime: ye,
228
- selectStartDate: Ce,
229
- selectStartTime: we,
230
- selectEndDate: Ie,
231
- updateEndTime: Pe,
232
- selectEndTime: Be
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
- Je as useBookingPeriodController
388
+ Ot as useBookingPeriodController
237
389
  };
@@ -1 +1 @@
1
- {"version":3,"file":"businessHoursUtils.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/businessHoursUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAGvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAMD,eAAO,MAAM,uBAAuB,GAClC,OAAO,qBAAqB,EAAE,EAC9B,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,KACjE,wBAAwB,EA4C1B,CAAA"}
1
+ {"version":3,"file":"businessHoursUtils.d.ts","sourceRoot":"","sources":["../../../src/components/Footer/businessHoursUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAGvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAOD,eAAO,MAAM,uBAAuB,GAClC,OAAO,qBAAqB,EAAE,EAC9B,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,KACjE,wBAAwB,EA4C1B,CAAA"}
@@ -1,27 +1,27 @@
1
- const c = (s) => s === 0 ? 6 : s - 1, g = (s) => s >= 1 && s <= 5, h = (s) => s === 6 || s === 0, p = (s, r) => {
2
- const o = [...s].sort((e, d) => c(e.weekday) - c(d.weekday)), l = o.filter((e) => g(e.weekday)), u = o.filter((e) => h(e.weekday)), k = [];
1
+ const i = (s) => s <= 4, g = (s) => s === 5 || s === 6, h = (s, w) => {
2
+ const k = [...s].sort((e, n) => e.weekday - n.weekday), t = k.filter((e) => i(e.weekday)), c = k.filter((e) => g(e.weekday)), o = [];
3
3
  let a = 0;
4
- for (; a < l.length; ) {
5
- const e = l[a], d = e.value;
6
- let n = a;
7
- for (; n + 1 < l.length && l[n + 1].value === d; )
8
- n += 1;
9
- const t = l.slice(a, n + 1), y = t.length === 1 ? `${e.weekday}` : `${e.weekday}-${t[t.length - 1].weekday}`;
10
- k.push({
4
+ for (; a < t.length; ) {
5
+ const e = t[a], n = e.value;
6
+ let d = a;
7
+ for (; d + 1 < t.length && t[d + 1].value === n; )
8
+ d += 1;
9
+ const l = t.slice(a, d + 1), y = l.length === 1 ? `${e.weekday}` : `${e.weekday}-${l[l.length - 1].weekday}`;
10
+ o.push({
11
11
  id: `weekday-${y}`,
12
- weekdays: t.map((i) => i.weekday),
13
- label: t.length === 1 ? e.label : r(e.label, t[t.length - 1].label),
14
- value: d
15
- }), a = n + 1;
12
+ weekdays: l.map((r) => r.weekday),
13
+ label: l.length === 1 ? e.label : w(e.label, l[l.length - 1].label),
14
+ value: n
15
+ }), a = d + 1;
16
16
  }
17
- const w = u.map((e) => ({
17
+ const u = c.map((e) => ({
18
18
  id: `weekend-${e.weekday}`,
19
19
  weekdays: [e.weekday],
20
20
  label: e.label,
21
21
  value: e.value
22
22
  }));
23
- return [...k, ...w];
23
+ return [...o, ...u];
24
24
  };
25
25
  export {
26
- p as groupBusinessHoursItems
26
+ h as groupBusinessHoursItems
27
27
  };