@loczer/storefront-sdk 0.158.0 → 0.160.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.
@@ -1,391 +1,403 @@
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 nt, de as rt, es as it, it as st, enUS as at } from "date-fns/locale";
4
- import { useMediaQuery as ot } from "@rpcbase/client";
5
- import { createBookingPeriodConstants as lt, parseTimeToMinutes as x, dateToBusinessDateString as ut, instantToBusinessDateTimeParts as ct, businessDateStringToDate as ft, getWeekdayFromDateString as dt, minutesToTimeString as mt } from "../../lib/booking-period.js";
6
- import { getBookingPeriodTimeSlotsSync as St } from "../../lib/booking-period-time-slots.js";
7
- const Tt = (T) => T, Dt = {
1
+ import { useMemo as f, useState as w, useRef as N, useCallback as g, useEffect as F } from "react";
2
+ import { differenceInCalendarDays as De } from "date-fns";
3
+ import { fr as ot, de as lt, es as ut, it as ct, enUS as ft } from "date-fns/locale";
4
+ import { useMediaQuery as dt } from "@rpcbase/client";
5
+ import { createBookingPeriodConstants as mt, parseTimeToMinutes as R, dateToBusinessDateString as St, instantToBusinessDateTimeParts as Tt, businessDateStringToDate as Dt, getWeekdayFromDateString as pt, minutesToTimeString as vt } from "../../lib/booking-period.js";
6
+ import { getBookingPeriodTimeSlotsSync as pe } from "../../lib/booking-period-time-slots.js";
7
+ const gt = (s) => s, ht = {
8
8
  startDate: "Start date",
9
9
  pickStartDate: "Pick a date",
10
10
  startTime: "Start time",
11
11
  endDate: "End date",
12
12
  pickEndDate: "Pick a date",
13
13
  endTime: "End time"
14
- }, pt = ({
15
- locale: T,
16
- localeCode: r
14
+ }, Et = ({
15
+ locale: s,
16
+ localeCode: n
17
17
  }) => {
18
- if (T)
19
- return T;
20
- const i = r?.toLowerCase() ?? "";
21
- return i.startsWith("fr") ? nt : i.startsWith("de") ? rt : i.startsWith("es") ? it : i.startsWith("it") ? st : at;
22
- }, vt = (T) => {
23
- if (!T?.length)
18
+ if (s)
19
+ return s;
20
+ const a = n?.toLowerCase() ?? "";
21
+ return a.startsWith("fr") ? ot : a.startsWith("de") ? lt : a.startsWith("es") ? ut : a.startsWith("it") ? ct : ft;
22
+ }, bt = (s) => {
23
+ if (!s?.length)
24
24
  return null;
25
- const r = T.map((n) => x(n.value)).filter((n) => typeof n == "number").sort((n, K) => n - K);
26
- if (r.length < 2)
25
+ const n = s.map((r) => R(r.value)).filter((r) => typeof r == "number").sort((r, K) => r - K);
26
+ if (n.length < 2)
27
27
  return null;
28
- const i = r[1] - r[0];
29
- return !Number.isFinite(i) || i <= 0 ? null : i;
30
- }, ht = (T) => {
31
- if (typeof T != "string")
28
+ const a = n[1] - n[0];
29
+ return !Number.isFinite(a) || a <= 0 ? null : a;
30
+ }, Mt = (s) => {
31
+ if (typeof s != "string")
32
32
  return 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)
33
+ const n = s.match(/(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})/);
34
+ return n ? R(n[2]) : null;
35
+ }, Ae = (s, n) => s.map((a) => {
36
+ const r = R(a.value);
37
+ if (r == null)
38
38
  return null;
39
- const K = ht(i.label) ?? n + r, m = typeof i.label == "string" ? i.label : i.value;
39
+ const K = Mt(a.label) ?? r + n, T = typeof a.label == "string" ? a.label : a.value;
40
40
  return {
41
- value: i.value,
42
- label: m,
43
- startMinutes: n,
41
+ value: a.value,
42
+ label: T,
43
+ startMinutes: r,
44
44
  endMinutes: K,
45
45
  isExtra: !1,
46
- isDisabled: !!i.disabled
46
+ isDisabled: !!a.disabled
47
47
  };
48
- }).filter((i) => !!i), wt = (T) => {
48
+ }).filter((a) => !!a), ve = (s) => !s.isDisabled && !s.isExtra, Be = (s) => {
49
+ for (let n = s.length - 1; n >= 0; n -= 1)
50
+ if (ve(s[n]))
51
+ return s[n];
52
+ return null;
53
+ }, At = (s) => {
49
54
  const {
50
- startDate: r,
51
- onStartDateChange: i,
52
- startTime: n,
55
+ startDate: n,
56
+ onStartDateChange: a,
57
+ startTime: r,
53
58
  onStartTimeChange: K,
54
- endDate: m,
59
+ endDate: T,
55
60
  onEndDateChange: _,
56
- endTime: o,
57
- onEndTimeChange: De,
61
+ endTime: d,
62
+ onEndTimeChange: ge,
58
63
  onEndDateCommit: Q,
59
64
  onEndTimeCommit: V,
60
- errors: Pe = {},
61
- labels: Fe,
62
- t: ke = Tt,
63
- language: pe,
64
- labelClassName: Ae,
65
- inputClassName: Be,
66
- buttonClassName: Ie,
67
- bookingPeriodConfig: D,
68
- fetchTimeSlots: s,
69
- selectionFlow: C = "chained-times",
70
- withMobileDateDrawer: Le = !1,
71
- currencyCode: Re = "EUR",
65
+ errors: Ie = {},
66
+ labels: Le,
67
+ t: xe = gt,
68
+ language: he,
69
+ labelClassName: Re,
70
+ inputClassName: Ke,
71
+ buttonClassName: He,
72
+ bookingPeriodConfig: o,
73
+ fetchTimeSlots: i,
74
+ selectionFlow: E = "chained-times",
75
+ withMobileDateDrawer: Ue = !1,
76
+ currencyCode: We = "EUR",
72
77
  disableAutomaticTimeCorrection: H = !1,
73
- openDatePickerOnFocus: xe = !0,
78
+ openDatePickerOnFocus: ze = !0,
74
79
  startTimeOptions: U = [],
75
- endTimeOptions: ve,
76
- locale: he,
77
- localeCode: Ke
78
- } = T, W = ot("(max-width: 767px)"), Y = Ke ?? pe ?? "en-US", He = d(
79
- () => pt({ locale: he, localeCode: Y }),
80
- [he, Y]
81
- ), E = d(
82
- () => D ? lt(D) : null,
83
- [D]
84
- ), R = d(() => D?.timing.slotIntervalMinutes ? D.timing.slotIntervalMinutes : vt(U) ?? 30, [D?.timing.slotIntervalMinutes, U]), [ne, j] = y(!1), [re, ie] = y(!1), [se, z] = y(!1), [ae, oe] = y(!1), [Ue, le] = y(void 0), [We, ze] = y(!1), [ge, Ne] = y(!1), [Ee, qe] = 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), $e = h(() => {
80
+ endTimeOptions: Ee,
81
+ locale: be,
82
+ localeCode: Ne
83
+ } = s, W = dt("(max-width: 767px)"), Y = Ne ?? he ?? "en-US", qe = f(
84
+ () => Et({ locale: be, localeCode: Y }),
85
+ [be, Y]
86
+ ), b = f(
87
+ () => o ? mt(o) : null,
88
+ [o]
89
+ ), L = f(() => o?.timing.slotIntervalMinutes ? o.timing.slotIntervalMinutes : bt(U) ?? 30, [o?.timing.slotIntervalMinutes, U]), [ne, j] = w(!1), [re, ie] = w(!1), [se, z] = w(!1), [ae, oe] = w(!1), [$e, le] = w(void 0), [Ze, _e] = w(!1), [Me, Qe] = w(!1), [ue, Ve] = w([]), [ye, G] = w([]), [J, q] = w(void 0), M = N(null), ce = N(0), fe = N(0), de = N(0), Ce = N(void 0), $ = N(void 0), Ye = g(() => {
85
90
  le(void 0);
86
- }, []), X = d(() => !r || !m ? !1 : Te(m, r) === 0, [r, m]), Ze = d(() => x(n), [n]), k = h(
91
+ }, []), X = f(() => !n || !T ? !1 : De(T, n) === 0, [n, T]), je = f(() => R(r), [r]), A = g(
87
92
  (e) => {
88
- const c = (e instanceof Date ? e : e ? new Date(e) : void 0) ?? /* @__PURE__ */ new Date();
89
- if (E)
90
- return ut(c, E.timeZone) ?? void 0;
91
- const u = c.getFullYear(), v = String(c.getMonth() + 1).padStart(2, "0"), S = String(c.getDate()).padStart(2, "0");
92
- return `${u}-${v}-${S}`;
93
+ const m = (e instanceof Date ? e : e ? new Date(e) : void 0) ?? /* @__PURE__ */ new Date();
94
+ if (b)
95
+ return St(m, b.timeZone) ?? void 0;
96
+ const u = m.getFullYear(), v = String(m.getMonth() + 1).padStart(2, "0"), D = String(m.getDate()).padStart(2, "0");
97
+ return `${u}-${v}-${D}`;
93
98
  },
94
- [E]
95
- ), A = d(() => k(r), [r, k]), l = d(() => k(m ?? r), [m, r, k]), ye = E ? ct(/* @__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]), _e = d(() => {
96
- if (O)
97
- return ft(O);
99
+ [b]
100
+ ), y = f(() => A(n), [n, A]), l = f(() => A(T ?? n), [T, n, A]), Oe = b ? Tt(/* @__PURE__ */ new Date(), b.timeZone) : null, P = Oe?.dateString, me = Oe?.minutesFromMidnight, B = f(() => P ? !!(n && y && y === P) : !!n && De(n, /* @__PURE__ */ new Date()) === 0, [n, y, P]), Z = f(() => P ? !!(T && l && l === P) : !!T && De(T, /* @__PURE__ */ new Date()) === 0, [T, l, P]), Ge = f(() => {
101
+ if (P)
102
+ return Dt(P);
98
103
  const e = /* @__PURE__ */ new Date();
99
104
  return e.setHours(0, 0, 0, 0), e;
100
- }, [O]), me = D?.timing.minBufferMinutes ?? 10, I = d(() => {
105
+ }, [P]), Se = o?.timing.minBufferMinutes ?? 10, I = f(() => {
101
106
  if (!B && !Z)
102
107
  return null;
103
- if (de != null)
104
- return de + me;
108
+ if (me != null)
109
+ return me + Se;
105
110
  const e = /* @__PURE__ */ new Date();
106
- return e.setMinutes(e.getMinutes() + me), e.getHours() * 60 + e.getMinutes();
107
- }, [de, Z, B, me]), Se = d(
111
+ return e.setMinutes(e.getMinutes() + Se), e.getHours() * 60 + e.getMinutes();
112
+ }, [me, Z, B, Se]), Te = f(
108
113
  () => B ? I : null,
109
114
  [I, B]
110
- ), Ce = h(
115
+ ), we = g(
111
116
  (e) => {
112
- if (!E)
117
+ if (!b)
113
118
  return;
114
- const t = k(e);
119
+ const t = A(e);
115
120
  if (!t)
116
- return E.defaultEndTime;
117
- const c = dt(t), u = E.getLastStartMinutesForWeekday(c, {
121
+ return b.defaultEndTime;
122
+ const m = pt(t), u = b.getLastStartMinutesForWeekday(m, {
118
123
  dateString: t
119
124
  });
120
- return typeof u == "number" ? mt(u) : E.defaultEndTime;
125
+ return typeof u == "number" ? vt(u) : b.defaultEndTime;
121
126
  },
122
- [E, k]
127
+ [b, A]
123
128
  );
124
129
  F(() => {
125
- if (!s || !A)
130
+ if (!i || !y)
126
131
  return;
127
132
  let e = !0;
128
- return s(A, "start").then((t) => {
129
- e && t && qe(t);
133
+ return i(y, "start").then((t) => {
134
+ e && t && Ve(t);
130
135
  }).catch((t) => {
131
136
  console.error("Failed to fetch availability time slots", t);
132
137
  }), () => {
133
138
  e = !1;
134
139
  };
135
- }, [s, A]), F(() => {
136
- if (!s)
140
+ }, [i, y]), F(() => {
141
+ if (!i)
137
142
  return;
138
- const e = Me.current, t = e !== void 0 && e !== l;
139
- Me.current = l, t && l && ($.current = l);
140
- }, [l, s]), F(() => {
141
- if (!s)
143
+ const e = Ce.current, t = e !== void 0 && e !== l;
144
+ Ce.current = l, t && l && ($.current = l);
145
+ }, [l, i]), F(() => {
146
+ if (!i)
142
147
  return;
143
148
  if (!l) {
144
149
  G([]), q(void 0);
145
150
  return;
146
151
  }
147
152
  let e = !0;
148
- return q(void 0), s(l, "end").then((t) => {
153
+ return q(void 0), i(l, "end").then((t) => {
149
154
  e && (t ? (G(t), q(l)) : (G([]), q(void 0)));
150
155
  }).catch((t) => {
151
156
  console.error("Failed to fetch availability time slots", t), e && (G([]), q(void 0));
152
157
  }), () => {
153
158
  e = !1;
154
159
  };
155
- }, [l, s]);
156
- const ee = d(() => s || !D ? null : St(D, {
157
- date: A
158
- }), [D, s, A]), w = d(() => s ? Ee : D ? ee?.startTimeSlots ?? [] : we(U, R), [
159
- D,
160
+ }, [l, i]);
161
+ const ee = f(() => i || !o ? null : pe(o, {
162
+ date: y
163
+ }), [o, i, y]), Pe = f(() => !i || !o ? null : pe(o, {
164
+ date: y
165
+ }).startTimeSlots, [o, i, y]), ke = f(() => !i || !o ? null : pe(o, {
166
+ date: l
167
+ }).endTimeSlots, [o, l, i]), k = f(() => i ? ue.length ? ue : Pe ?? [] : o ? ee?.startTimeSlots ?? [] : Ae(U, L), [
168
+ o,
160
169
  ee?.startTimeSlots,
161
- s,
162
- Ee,
163
- R,
170
+ Pe,
171
+ i,
172
+ ue,
173
+ L,
164
174
  U
165
- ]), L = d(() => s ? J === l ? be : [] : D ? ee?.endTimeSlots ?? [] : we(ve ?? U, R), [
166
- D,
175
+ ]), C = f(() => i ? J === l ? ye : ke ?? [] : o ? ee?.endTimeSlots ?? [] : Ae(Ee ?? U, L), [
176
+ o,
167
177
  ee?.endTimeSlots,
168
178
  l,
169
- ve,
170
- s,
171
- be,
179
+ Ee,
180
+ ke,
181
+ i,
182
+ ye,
172
183
  J,
173
- R,
184
+ L,
174
185
  U
175
- ]), M = h(
186
+ ]), O = g(
176
187
  (e, t) => {
177
- e !== n && (Ne(t === "user"), K(e, { source: t }));
188
+ e !== r && (Qe(t === "user"), K(e, { source: t }));
178
189
  },
179
- [K, n]
180
- ), p = h(
190
+ [K, r]
191
+ ), p = g(
181
192
  (e, t = "auto") => {
182
- e !== o && De(e, { source: t });
193
+ e !== d && (t !== "user" && e && C.find((u) => u.value === e)?.isExtra || ge(e, { source: t }));
183
194
  },
184
- [o, De]
185
- ), te = d(() => w.length ? w.find((e) => !(e.isDisabled || Se != null && e.startMinutes < Se)) ?? null : null, [Se, w]);
195
+ [C, d, ge]
196
+ ), te = f(() => k.length ? k.find((e) => !(e.isDisabled || Te != null && e.startMinutes < Te)) ?? null : null, [Te, k]);
186
197
  F(() => {
187
- H || ge || te && n !== te.value && M(te.value, "auto");
188
- }, [H, te, ge, n, M]), F(() => {
189
- if (H || !w.length)
198
+ H || Me || te && r !== te.value && O(te.value, "auto");
199
+ }, [H, te, Me, r, O]), F(() => {
200
+ if (H || !k.length)
190
201
  return;
191
- const e = n ? w.find((f) => f.value === n) : void 0, t = I ?? void 0, c = B ? t : null, u = (f) => {
192
- const a = typeof f == "number" ? f : null, g = w.find((P) => !(P.isDisabled || a != null && P.startMinutes < a));
193
- g && g.value !== n ? M(g.value, "auto") : !g && n && M("", "auto");
202
+ const e = r ? k.find((S) => S.value === r) : void 0, t = I ?? void 0, m = B ? t : null, u = (S) => {
203
+ const c = typeof S == "number" ? S : null, h = k.find((x) => !(x.isDisabled || c != null && x.startMinutes < c));
204
+ h && h.value !== r ? O(h.value, "auto") : !h && r && O("", "auto");
194
205
  };
195
- if (n && !e) {
196
- u(c);
206
+ if (r && !e) {
207
+ u(m);
197
208
  return;
198
209
  }
199
210
  if (e?.isDisabled) {
200
- u(c);
211
+ u(m);
201
212
  return;
202
213
  }
203
214
  if (!B || t == null)
204
215
  return;
205
- const v = x(n);
216
+ const v = R(r);
206
217
  if (v != null && v >= t && !e?.isDisabled)
207
218
  return;
208
- const S = w.find((f) => !f.isDisabled && f.startMinutes >= t);
209
- S && S.value !== n && M(S.value, "auto");
210
- }, [H, I, B, n, w, M]), F(() => {
211
- if (H || !L.length)
219
+ const D = k.find((S) => !S.isDisabled && S.startMinutes >= t);
220
+ D && D.value !== r && O(D.value, "auto");
221
+ }, [H, I, B, r, k, O]), F(() => {
222
+ if (H || !C.length)
212
223
  return;
213
- if (s && $.current === l && J === l) {
224
+ if (i && $.current === l && J === l) {
214
225
  $.current = void 0;
215
- const g = [...L].reverse().find((P) => !P.isDisabled);
216
- if (g && g.value !== o) {
217
- p(g.value);
226
+ const h = Be(C);
227
+ if (h && h.value !== d) {
228
+ p(h.value);
218
229
  return;
219
230
  }
220
231
  }
221
- const e = x(n), t = x(o), c = o ? L.find((a) => a.value === o) : void 0;
232
+ const e = R(r), t = R(d), m = d ? C.find((c) => c.value === d) : void 0;
222
233
  if (X && e != null && t != null && t < e) {
223
- const a = [...L].reverse().find((g) => !g.isDisabled);
224
- a && a.value !== o ? p(a.value) : !a && o && p("");
234
+ const c = Be(C);
235
+ c && c.value !== d ? p(c.value) : !c && d && p("");
225
236
  return;
226
237
  }
227
238
  const u = [];
228
- Z && I != null && u.push(I), X && e != null && u.push(e + R);
229
- const v = u.length ? Math.max(...u) : null, S = (a) => {
230
- const g = typeof a == "number" ? a : null, P = L.find((Oe) => !(Oe.isDisabled || g != null && Oe.startMinutes < g));
231
- P && P.value !== o ? p(P.value) : !P && o && p("");
239
+ Z && I != null && u.push(I), X && e != null && u.push(e + L);
240
+ const v = u.length ? Math.max(...u) : null, D = (c) => {
241
+ const h = typeof c == "number" ? c : null, x = C.find((Fe) => !(!ve(Fe) || h != null && Fe.startMinutes < h));
242
+ x && x.value !== d ? p(x.value) : !x && d && p("");
232
243
  };
233
- if (s && o && !c) {
234
- S(v);
244
+ if (i && d && !m) {
245
+ D(v);
235
246
  return;
236
247
  }
237
- if (c?.isDisabled) {
238
- S(v);
248
+ if (m?.isDisabled) {
249
+ D(v);
239
250
  return;
240
251
  }
241
252
  if (v == null || t != null && t >= v)
242
253
  return;
243
- const f = L.find((a) => !a.isDisabled && a.startMinutes >= v);
244
- f && f.value !== o ? p(f.value) : !f && o && p("");
254
+ const S = C.find((c) => ve(c) && c.startMinutes >= v);
255
+ S && S.value !== d ? p(S.value) : !S && d && p("");
245
256
  }, [
246
- L,
257
+ C,
247
258
  H,
248
259
  I,
249
260
  l,
250
- o,
251
- s,
261
+ d,
262
+ i,
252
263
  J,
253
264
  Z,
254
265
  X,
255
- R,
256
- n,
266
+ L,
267
+ r,
257
268
  p
258
- ]), F(() => (ze(!0), () => {
259
- b.current != null && clearTimeout(b.current);
269
+ ]), F(() => (_e(!0), () => {
270
+ M.current != null && clearTimeout(M.current);
260
271
  }), []), F(() => {
261
272
  re && ne && j(!1);
262
273
  }, [ne, re]), F(() => {
263
274
  ae && se && z(!1);
264
275
  }, [se, ae]);
265
- const Qe = h((e) => {
266
- e && ue.current && Date.now() < ue.current || j(e);
267
- }, []), Ve = h((e) => {
268
- e && ce.current && Date.now() < ce.current || z(e);
269
- }, []), Ye = h((e) => {
270
- e && fe.current && Date.now() < fe.current || oe(e);
271
- }, []), je = h(
276
+ const Je = g((e) => {
277
+ e && ce.current && Date.now() < ce.current || j(e);
278
+ }, []), Xe = g((e) => {
279
+ e && fe.current && Date.now() < fe.current || z(e);
280
+ }, []), et = g((e) => {
281
+ e && de.current && Date.now() < de.current || oe(e);
282
+ }, []), tt = g(
272
283
  (e, {
273
284
  openTimePicker: t,
274
- openEndDatePicker: c,
285
+ openEndDatePicker: m,
275
286
  close: u = !0
276
287
  } = {}) => {
277
- const v = t ?? C === "chained-times", S = c ?? C === "dates-first";
288
+ const v = t ?? E === "chained-times", D = m ?? E === "dates-first";
278
289
  if (!e) {
279
290
  u && j(!1);
280
291
  return;
281
292
  }
282
- 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(() => {
293
+ a(e), (u || D) && (ce.current = Date.now() + 250, j(!1)), T && e > T && _(e), v && ie(!0), D && (M.current != null && clearTimeout(M.current), W ? (z(!0), M.current = null) : M.current = setTimeout(() => {
283
294
  z(!0);
284
295
  }, 100));
285
296
  },
286
- [m, W, _, i, C]
287
- ), Ge = h(
297
+ [T, W, _, a, E]
298
+ ), nt = g(
288
299
  (e) => {
289
- M(e, "user"), ie(!1), b.current != null && clearTimeout(b.current), C === "chained-times" && e && r ? b.current = setTimeout(() => {
300
+ O(e, "user"), ie(!1), M.current != null && clearTimeout(M.current), E === "chained-times" && e && n ? M.current = setTimeout(() => {
290
301
  z(!0);
291
- }, 100) : b.current = null;
302
+ }, 100) : M.current = null;
292
303
  },
293
- [C, r, M]
294
- ), Je = h(
304
+ [E, n, O]
305
+ ), rt = g(
295
306
  (e) => {
296
- e && e !== n && M(e, "user");
307
+ e && e !== r && O(e, "user");
297
308
  },
298
- [n, M]
299
- ), Xe = h(
309
+ [r, O]
310
+ ), it = g(
300
311
  (e, {
301
312
  openTimePicker: t,
302
- close: c = !0,
303
- commit: u = C === "dates-first" ? W : !1
313
+ close: m = !0,
314
+ commit: u = E === "dates-first" ? W : !1
304
315
  } = {}) => {
305
- const v = t ?? C === "chained-times";
306
- let S = o;
307
- if (e && C === "dates-first") {
308
- if (s) {
309
- const a = k(e);
310
- a && ($.current = a);
316
+ const v = t ?? E === "chained-times";
317
+ let D = d;
318
+ if (e && E === "dates-first") {
319
+ if (i) {
320
+ const c = A(e);
321
+ c && ($.current = c);
311
322
  }
312
- const f = Ce(e);
313
- f && (S = f, p(f));
323
+ const S = we(e);
324
+ S && (D = S, p(S));
314
325
  }
315
- _(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)));
326
+ _(e), le(void 0), m && (fe.current = Date.now() + 250, z(!1)), e && v && oe(!0), e && u && Q && (typeof window > "u" ? Q(e, D) : requestAnimationFrame(() => Q(e, D)));
316
327
  },
317
328
  [
318
- o,
319
- s,
320
- Ce,
329
+ d,
330
+ i,
331
+ we,
321
332
  W,
322
333
  _,
323
334
  Q,
324
- C,
325
- k,
335
+ E,
336
+ A,
326
337
  p
327
338
  ]
328
- ), et = h(
339
+ ), st = g(
329
340
  (e) => {
330
341
  p(e, "user");
331
342
  },
332
343
  [p]
333
- ), tt = h(
344
+ ), at = g(
334
345
  (e) => {
335
- $.current = void 0, p(e, "user"), fe.current = Date.now() + 250, oe(!1), V && (typeof window > "u" ? V() : requestAnimationFrame(() => {
346
+ $.current = void 0, p(e, "user"), de.current = Date.now() + 250, oe(!1), V && (typeof window > "u" ? V() : requestAnimationFrame(() => {
336
347
  requestAnimationFrame(V);
337
348
  }));
338
349
  },
339
350
  [V, p]
340
351
  );
341
352
  return {
342
- startDate: r,
343
- startTime: n,
344
- endDate: m,
345
- endTime: o,
346
- errors: Pe,
347
- labels: Fe ?? Dt,
348
- t: ke,
349
- language: pe ?? Y,
350
- labelClassName: Ae,
351
- inputClassName: Be,
352
- buttonClassName: Ie,
353
- currencyCode: Re,
353
+ startDate: n,
354
+ startTime: r,
355
+ endDate: T,
356
+ endTime: d,
357
+ errors: Ie,
358
+ labels: Le ?? ht,
359
+ t: xe,
360
+ language: he ?? Y,
361
+ labelClassName: Re,
362
+ inputClassName: Ke,
363
+ buttonClassName: He,
364
+ currencyCode: We,
354
365
  localeCode: Y,
355
- slotIntervalMinutes: R,
356
- dateLocale: He,
366
+ slotIntervalMinutes: L,
367
+ dateLocale: qe,
357
368
  numberOfMonths: W ? 1 : 2,
358
369
  isMobile: W,
359
- isHydrated: We,
360
- openDatePickerOnFocus: xe,
361
- withMobileDateDrawer: Le,
370
+ isHydrated: Ze,
371
+ openDatePickerOnFocus: ze,
372
+ withMobileDateDrawer: Ue,
373
+ selectionFlow: E,
362
374
  isStartDatePopoverOpen: ne,
363
- setIsStartDatePopoverOpen: Qe,
375
+ setIsStartDatePopoverOpen: Je,
364
376
  isStartTimeSelectOpen: re,
365
377
  setIsStartTimeSelectOpen: ie,
366
378
  isEndDatePopoverOpen: se,
367
- setIsEndDatePopoverOpen: Ve,
379
+ setIsEndDatePopoverOpen: Xe,
368
380
  isEndTimeSelectOpen: ae,
369
- setIsEndTimeSelectOpen: Ye,
370
- hoveredEndDate: Ue,
381
+ setIsEndTimeSelectOpen: et,
382
+ hoveredEndDate: $e,
371
383
  setHoveredEndDate: le,
372
- resetHoveredEndDate: $e,
373
- startTimeSlots: w,
374
- availableEndTimeSlots: L,
384
+ resetHoveredEndDate: Ye,
385
+ startTimeSlots: k,
386
+ availableEndTimeSlots: C,
375
387
  isStartToday: B,
376
388
  isEndToday: Z,
377
- minSelectableDate: _e,
389
+ minSelectableDate: Ge,
378
390
  earliestMinutesForToday: I,
379
- startMinutesValue: Ze,
391
+ startMinutesValue: je,
380
392
  isSameDaySelection: X,
381
- updateStartTime: Je,
382
- selectStartDate: je,
383
- selectStartTime: Ge,
384
- selectEndDate: Xe,
385
- updateEndTime: et,
386
- selectEndTime: tt
393
+ updateStartTime: rt,
394
+ selectStartDate: tt,
395
+ selectStartTime: nt,
396
+ selectEndDate: it,
397
+ updateEndTime: st,
398
+ selectEndTime: at
387
399
  };
388
400
  };
389
401
  export {
390
- wt as useBookingPeriodController
402
+ At as useBookingPeriodController
391
403
  };
package/dist/index.d.ts CHANGED
@@ -657,6 +657,7 @@ export declare interface BookingPeriodControllerValue {
657
657
  isHydrated: boolean;
658
658
  openDatePickerOnFocus: boolean;
659
659
  withMobileDateDrawer: boolean;
660
+ selectionFlow: BookingPeriodSelectionFlow;
660
661
  isStartDatePopoverOpen: boolean;
661
662
  setIsStartDatePopoverOpen: (open: boolean) => void;
662
663
  isStartTimeSelectOpen: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loczer/storefront-sdk",
3
- "version": "0.158.0",
3
+ "version": "0.160.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"