@loczer/storefront-sdk 0.188.0 → 0.189.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 (46) hide show
  1. package/dist/chunks/ui/dist/Map/{MapContent-QPkuTBvK.js → MapContent-PK-ptOx6.js} +126 -94
  2. package/dist/chunks/ui/dist/Map/mapboxError-oRn0l3EE.js +25 -0
  3. package/dist/chunks/ui/dist/{Map-BXmRf5Ep.js → Map-BwXj49kV.js} +1 -1
  4. package/dist/components/BookingBikeVariantDialog/index.d.ts +2 -1
  5. package/dist/components/BookingBikeVariantDialog/index.d.ts.map +1 -1
  6. package/dist/components/BookingBikeVariantDialog/index.js +39 -38
  7. package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.d.ts.map +1 -1
  8. package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +32 -30
  9. package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.d.ts.map +1 -1
  10. package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.js +127 -122
  11. package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.d.ts.map +1 -1
  12. package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +32 -30
  13. package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.d.ts +7 -0
  14. package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.d.ts.map +1 -0
  15. package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.js +29 -0
  16. package/dist/components/BookingPeriodSelector/index.d.ts +2 -1
  17. package/dist/components/BookingPeriodSelector/index.d.ts.map +1 -1
  18. package/dist/components/BookingPeriodSelector/index.js +15 -14
  19. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts +11 -0
  20. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
  21. package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +280 -216
  22. package/dist/components/ContactSection/index.d.ts.map +1 -1
  23. package/dist/components/ContactSection/index.js +120 -116
  24. package/dist/components/Header/index.d.ts.map +1 -1
  25. package/dist/components/Header/index.js +35 -35
  26. package/dist/components/Map/index.js +1 -1
  27. package/dist/i18n/en.d.ts +5 -0
  28. package/dist/i18n/en.d.ts.map +1 -1
  29. package/dist/i18n/en.js +5 -0
  30. package/dist/i18n/fr.d.ts +5 -0
  31. package/dist/i18n/fr.d.ts.map +1 -1
  32. package/dist/i18n/fr.js +5 -0
  33. package/dist/index.d.ts +29 -0
  34. package/dist/index.js +26 -25
  35. package/dist/lib/fetchStorefrontTimeSlots.d.ts.map +1 -1
  36. package/dist/lib/fetchStorefrontTimeSlots.js +2 -1
  37. package/dist/pages/BookingPage.d.ts.map +1 -1
  38. package/dist/pages/BookingPage.js +109 -95
  39. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  40. package/dist/pages/CheckoutPage.js +229 -231
  41. package/dist/pages/HomePage.d.ts.map +1 -1
  42. package/dist/pages/HomePage.js +304 -275
  43. package/dist/pages/ProductPage.d.ts.map +1 -1
  44. package/dist/pages/ProductPage.js +60 -52
  45. package/dist/storefront.css +1 -1
  46. package/package.json +1 -1
@@ -13,8 +13,8 @@ var f = (e, t, n) => new Intl.NumberFormat(t, {
13
13
  minimumFractionDigits: 0,
14
14
  maximumFractionDigits: 0
15
15
  }).format(e / 100), p = () => {
16
- let { labels: p, localeCode: m, currencyCode: h, endTime: g, selectEndTime: _, availableEndTimeSlots: v, isEndTimeSelectOpen: y, setIsEndTimeSelectOpen: b, labelClassName: x, inputClassName: S, buttonClassName: C, errors: w, isHydrated: T, startMinutesValue: E, isSameDaySelection: D, isEndToday: O, earliestMinutesForToday: k } = e(), A = v.map((e) => {
17
- let t = !!D && E != null && e.startMinutes <= E, n = O && k != null && e.startMinutes < k, r = e.isDisabled || t || n, i = e.disabledReason === "closed" ? p.timeSlotClosedLabel ?? "Closed" : e.disabledReason, a = e.isExtra && e.extraAmount != null ? p.timeSlotExtraFee?.({ amount: f(e.extraAmount, m, h) }) ?? `Extra fee: ${f(e.extraAmount, m, h)}` : null, o = e.isDisabled && i ? i : null, u = a && o ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
16
+ let { labels: p, localeCode: m, currencyCode: h, endTime: g, selectEndTime: _, availableEndTimeSlots: v, endTimeSlotsStatus: y, isEndTimeSelectOpen: b, setIsEndTimeSelectOpen: x, labelClassName: S, inputClassName: C, buttonClassName: w, errors: T, isHydrated: E, startMinutesValue: D, isSameDaySelection: O, isEndToday: k, earliestMinutesForToday: A } = e(), j = v.map((e) => {
17
+ let t = !!O && D != null && e.startMinutes <= D, n = k && A != null && e.startMinutes < A, r = e.isDisabled || t || n, i = e.disabledReason === "closed" ? p.timeSlotClosedLabel ?? "Closed" : e.disabledReason, a = e.isExtra && e.extraAmount != null ? p.timeSlotExtraFee?.({ amount: f(e.extraAmount, m, h) }) ?? `Extra fee: ${f(e.extraAmount, m, h)}` : null, o = e.isDisabled && i ? i : null, u = a && o ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
18
18
  className: "block",
19
19
  children: a
20
20
  }), /* @__PURE__ */ c("span", {
@@ -27,20 +27,20 @@ var f = (e, t, n) => new Intl.NumberFormat(t, {
27
27
  disabled: r,
28
28
  description: u
29
29
  };
30
- }), j = A.find((e) => !e.disabled)?.value, M = o(g ?? j ?? null), N = t(), P = !!N;
30
+ }), M = j.some((e) => !e.disabled), N = y !== "local" && (y !== "ready" || !M), P = y === "loading" ? p.timeSlotsLoading : y === "error" ? p.timeSlotsLoadError : y === "ready" && !M ? p.timeSlotsUnavailable : p.endTime, F = j.find((e) => !e.disabled)?.value, I = o(g ?? F ?? null), L = t(), R = !!L;
31
31
  return a(() => {
32
- y || (M.current = g ?? j ?? null);
32
+ b || (I.current = g ?? F ?? null);
33
33
  }, [
34
34
  g,
35
- j,
36
- y
35
+ F,
36
+ b
37
37
  ]), a(() => {
38
38
  let e = document.getElementById("end-time-picker");
39
39
  if (!(e instanceof HTMLInputElement)) return;
40
40
  let t = (e) => {
41
- if (e.key !== "Enter" || !y) return;
41
+ if (e.key !== "Enter" || !b) return;
42
42
  e.preventDefault(), e.stopPropagation();
43
- let t = M.current ?? g ?? j;
43
+ let t = I.current ?? g ?? F;
44
44
  t && _(t);
45
45
  };
46
46
  return e.addEventListener("keydown", t, !0), () => {
@@ -48,54 +48,56 @@ var f = (e, t, n) => new Intl.NumberFormat(t, {
48
48
  };
49
49
  }, [
50
50
  g,
51
- j,
52
- y,
51
+ F,
52
+ b,
53
53
  _
54
54
  ]), /* @__PURE__ */ l("div", {
55
55
  className: "group/form-item relative w-[150px]",
56
56
  children: [
57
57
  /* @__PURE__ */ c(n, {
58
58
  htmlFor: "end-time-picker",
59
- className: d("mb-1 block text-sm font-medium", x),
59
+ className: d("mb-1 block text-sm font-medium", S),
60
60
  children: /* @__PURE__ */ c("span", { children: p.endTime })
61
61
  }),
62
- P ? /* @__PURE__ */ c(i, {
62
+ R ? /* @__PURE__ */ c(i, {
63
63
  id: "end-time-picker",
64
- placeholder: p.endTime,
64
+ placeholder: P,
65
65
  value: g ?? null,
66
66
  onValueUpdate: (e) => {
67
- e && (M.current = e);
67
+ e && (I.current = e);
68
68
  },
69
69
  onChange: (e) => {
70
- e && (M.current = e, _(e));
70
+ e && (I.current = e, _(e));
71
71
  },
72
- options: A,
73
- open: y,
74
- onOpenChange: b,
72
+ options: j,
73
+ disabled: N,
74
+ open: b,
75
+ onOpenChange: x,
75
76
  triggerTestId: "end-time-trigger",
76
77
  contentTestId: "end-time-select-content",
77
- isHydrated: T,
78
- inputClassName: d(w.endTime && "border-destructive", S, C),
79
- portalContainer: N
78
+ isHydrated: E,
79
+ inputClassName: d(T.endTime && "border-destructive", C, w),
80
+ portalContainer: L
80
81
  }) : /* @__PURE__ */ c(u, {
81
82
  id: "end-time-picker",
82
- placeholder: p.endTime,
83
+ placeholder: P,
83
84
  value: g ?? null,
84
85
  onValueUpdate: (e) => {
85
- e && (M.current = e);
86
+ e && (I.current = e);
86
87
  },
87
88
  onChange: (e) => {
88
- e && (M.current = e, _(e));
89
+ e && (I.current = e, _(e));
89
90
  },
90
- options: A,
91
- open: y,
92
- onOpenChange: b,
91
+ options: j,
92
+ disabled: N,
93
+ open: b,
94
+ onOpenChange: x,
93
95
  triggerTestId: "end-time-trigger",
94
96
  contentTestId: "end-time-select-content",
95
- isHydrated: T,
96
- inputClassName: d(w.endTime && "border-destructive", S, C)
97
+ isHydrated: E,
98
+ inputClassName: d(T.endTime && "border-destructive", C, w)
97
99
  }),
98
- w.endTime && /* @__PURE__ */ c(r, { children: w.endTime })
100
+ T.endTime && /* @__PURE__ */ c(r, { children: T.endTime })
99
101
  ]
100
102
  });
101
103
  };
@@ -1 +1 @@
1
- {"version":3,"file":"BookingMobileDateDrawer.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingMobileDateDrawer.tsx"],"names":[],"mappings":"AAuFA,eAAO,MAAM,uBAAuB,sDAuTnC,CAAA"}
1
+ {"version":3,"file":"BookingMobileDateDrawer.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingMobileDateDrawer.tsx"],"names":[],"mappings":"AAwFA,eAAO,MAAM,uBAAuB,sDAyTnC,CAAA"}
@@ -2,133 +2,134 @@ import { Button as e, buttonVariants as t } from "../../../ui/button.js";
2
2
  import { useBookingPeriod as n } from "../BookingPeriodContext.js";
3
3
  import { DayPicker as r } from "../../../ui/day-picker.js";
4
4
  import { Drawer as i, DrawerContent as a, DrawerHeader as o, DrawerTitle as s } from "../../../ui/drawer.js";
5
- import { addMonths as c, differenceInCalendarDays as l, endOfMonth as u, isSameDay as d, startOfMonth as f } from "date-fns";
6
- import { useEffect as p, useRef as m, useState as h } from "react";
7
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
8
- import { cn as v } from "@rpcbase/ui";
9
- import { DayButton as y } from "react-day-picker";
5
+ import { BookingTimeSlotsStatus as c } from "./BookingTimeSlotsStatus.js";
6
+ import { addMonths as l, differenceInCalendarDays as u, endOfMonth as d, isSameDay as f, startOfMonth as p } from "date-fns";
7
+ import { useEffect as m, useRef as h, useState as g } from "react";
8
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
9
+ import { cn as y } from "@rpcbase/ui";
10
+ import { DayButton as b } from "react-day-picker";
10
11
  //#region src/components/BookingPeriodSelector/components/BookingMobileDateDrawer.tsx
11
- var b = y, x = 1, S = v(t({ variant: "outline" }), "z-10 h-11 w-11 bg-background p-0 opacity-100 shadow-sm [&_svg]:size-5"), C = {
12
+ var x = b, S = 1, C = y(t({ variant: "outline" }), "z-10 h-11 w-11 bg-background p-0 opacity-100 shadow-sm [&_svg]:size-5"), w = {
12
13
  months: "relative flex w-full flex-col",
13
14
  month: "mobile-date-calendar-month w-full space-y-3",
14
15
  month_caption: "flex h-11 items-center justify-center pt-0 relative",
15
16
  caption_label: "mobile-date-calendar-caption text-base font-semibold",
16
17
  nav: "absolute inset-x-0 top-0 flex items-center justify-between",
17
- button_previous: S,
18
- button_next: S,
18
+ button_previous: C,
19
+ button_next: C,
19
20
  month_grid: "w-full border-collapse space-y-1",
20
21
  weekdays: "grid grid-cols-7",
21
22
  weekday: "w-full rounded-md text-muted-foreground font-normal text-xs",
22
23
  week: "grid w-full grid-cols-7 gap-y-2",
23
24
  day: "h-11 w-full overflow-visible p-0 font-normal aria-selected:opacity-100 rounded-md first:aria-selected:rounded-l-md last:aria-selected:rounded-r-md",
24
25
  day_button: "relative inline-flex h-11 w-full items-center justify-center overflow-visible rounded-md p-0 text-base font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
25
- }, w = (e) => `${e.getFullYear()}-${e.getMonth()}`, T = (e) => {
26
+ }, T = (e) => `${e.getFullYear()}-${e.getMonth()}`, E = (e) => {
26
27
  let [t = "0", n = "0"] = e.split("-");
27
28
  return new Date(Number(t), Number(n), 1);
28
- }, E = (e, t, n) => e ? d(e, u(e)) ? c(f(e), 1) : f(e) : f(t ?? n), D = (e) => {
29
- if (!(!e || !d(e, u(e)))) return c(f(e), 1);
30
- }, O = () => {
31
- let { labels: t, startDate: c, endDate: u, selectStartDate: y, selectEndDate: S, isStartDatePopoverOpen: O, setIsStartDatePopoverOpen: k, isEndDatePopoverOpen: A, setIsEndDatePopoverOpen: j, resetHoveredEndDate: M, dateLocale: N, isMobile: P, withMobileDateDrawer: F, minSelectableDate: I } = n(), L = F && P && (O || A), R = A && !O ? "end" : "start", z = w(I), B = w(E(c, u, I)), [V, H] = h(() => f(I)), [U, W] = h(() => T(B)), G = m(!0), K = m(!1), q = c && (u ?? c) >= c ? l(u ?? c, c) + 1 : null, J = u ?? c;
32
- if (p(() => {
33
- !L || R !== "start" || H(f(I));
29
+ }, D = (e, t, n) => e ? f(e, d(e)) ? l(p(e), 1) : p(e) : p(t ?? n), O = (e) => {
30
+ if (!(!e || !f(e, d(e)))) return l(p(e), 1);
31
+ }, k = () => {
32
+ let { labels: t, startDate: l, endDate: d, selectStartDate: b, selectEndDate: C, isStartDatePopoverOpen: k, setIsStartDatePopoverOpen: A, isEndDatePopoverOpen: j, setIsEndDatePopoverOpen: M, resetHoveredEndDate: N, dateLocale: P, isMobile: F, withMobileDateDrawer: I, minSelectableDate: L, canCommitTimeSlots: R } = n(), z = I && F && (k || j), B = j && !k ? "end" : "start", V = T(L), H = T(D(l, d, L)), [U, W] = g(() => p(L)), [G, K] = g(() => E(H)), q = h(!0), J = h(!1), Y = l && (d ?? l) >= l ? u(d ?? l, l) + 1 : null, X = d ?? l;
33
+ if (m(() => {
34
+ !z || B !== "start" || W(p(L));
34
35
  }, [
35
- R,
36
- L,
37
- z
38
- ]), p(() => {
39
- !L || R !== "end" || W(T(B));
36
+ B,
37
+ z,
38
+ V
39
+ ]), m(() => {
40
+ !z || B !== "end" || K(E(H));
40
41
  }, [
41
- R,
42
42
  B,
43
- L
44
- ]), p(() => {
45
- if (!L || typeof document > "u") return;
43
+ H,
44
+ z
45
+ ]), m(() => {
46
+ if (!z || typeof document > "u") return;
46
47
  let e = window.scrollY, { body: t, documentElement: n } = document, r = {
47
48
  overflow: t.style.overflow,
48
49
  position: t.style.position,
49
50
  top: t.style.top,
50
51
  width: t.style.width
51
52
  }, i = n.style.overscrollBehavior;
52
- return G.current = !0, t.style.overflow = "hidden", t.style.position = "fixed", t.style.top = `-${e}px`, t.style.width = "100%", n.style.overscrollBehavior = "none", () => {
53
- t.style.overflow = r.overflow, t.style.position = r.position, t.style.top = r.top, t.style.width = r.width, n.style.overscrollBehavior = i, G.current && window.scrollTo(0, e);
53
+ return q.current = !0, t.style.overflow = "hidden", t.style.position = "fixed", t.style.top = `-${e}px`, t.style.width = "100%", n.style.overscrollBehavior = "none", () => {
54
+ t.style.overflow = r.overflow, t.style.position = r.position, t.style.top = r.top, t.style.width = r.width, n.style.overscrollBehavior = i, q.current && window.scrollTo(0, e);
54
55
  };
55
- }, [L]), !F || !P) return null;
56
- let Y = (e) => {
56
+ }, [z]), !I || !F) return null;
57
+ let Z = (e) => {
57
58
  if (e === "end") {
58
- let e = D(c);
59
- e && !u && !K.current ? (W(f(e)), S(e, {
59
+ let e = O(l);
60
+ e && !d && !J.current ? (K(p(e)), C(e, {
60
61
  close: !1,
61
62
  commit: !1
62
- })) : W(T(B));
63
+ })) : K(E(H));
63
64
  }
64
- k(e === "start"), j(e === "end");
65
- }, X = () => {
66
- k(!1), j(!1), M();
65
+ A(e === "start"), M(e === "end");
66
+ }, Q = () => {
67
+ A(!1), M(!1), N();
67
68
  };
68
- return /* @__PURE__ */ g(i, {
69
- open: L,
69
+ return /* @__PURE__ */ _(i, {
70
+ open: z,
70
71
  lockScroll: !1,
71
72
  onOpenChange: (e) => {
72
- e || X();
73
+ e || Q();
73
74
  },
74
- children: /* @__PURE__ */ _(a, {
75
+ children: /* @__PURE__ */ v(a, {
75
76
  className: "overflow-hidden",
76
77
  closeLabel: t.closeDrawer,
77
78
  showCloseButton: !0,
78
- children: [/* @__PURE__ */ _(o, {
79
+ children: [/* @__PURE__ */ v(o, {
79
80
  className: "border-b px-16 pb-3 pt-4 text-left",
80
- children: [/* @__PURE__ */ g(s, {
81
+ children: [/* @__PURE__ */ _(s, {
81
82
  className: "sr-only",
82
- children: R === "start" ? t.startDate : t.endDate
83
- }), /* @__PURE__ */ _("div", {
83
+ children: B === "start" ? t.startDate : t.endDate
84
+ }), /* @__PURE__ */ v("div", {
84
85
  className: "relative grid grid-cols-2 rounded-md bg-muted p-1",
85
86
  "aria-label": t.rentalPeriod,
86
87
  children: [
87
- /* @__PURE__ */ g("span", {
88
+ /* @__PURE__ */ _("span", {
88
89
  "aria-hidden": "true",
89
- className: v("absolute inset-y-1 left-1 w-[calc(50%-0.25rem)] rounded bg-background shadow-sm transition-transform duration-300 ease-out", R === "end" && "translate-x-full")
90
+ className: y("absolute inset-y-1 left-1 w-[calc(50%-0.25rem)] rounded bg-background shadow-sm transition-transform duration-300 ease-out", B === "end" && "translate-x-full")
90
91
  }),
91
- /* @__PURE__ */ g("button", {
92
+ /* @__PURE__ */ _("button", {
92
93
  type: "button",
93
- "aria-pressed": R === "start",
94
- className: v("relative z-10 h-9 rounded px-3 text-sm font-medium transition-colors", R === "start" ? "text-foreground" : "text-muted-foreground"),
95
- onClick: () => Y("start"),
94
+ "aria-pressed": B === "start",
95
+ className: y("relative z-10 h-9 rounded px-3 text-sm font-medium transition-colors", B === "start" ? "text-foreground" : "text-muted-foreground"),
96
+ onClick: () => Z("start"),
96
97
  children: t.startDate
97
98
  }),
98
- /* @__PURE__ */ g("button", {
99
+ /* @__PURE__ */ _("button", {
99
100
  type: "button",
100
- "aria-pressed": R === "end",
101
- className: v("relative z-10 h-9 rounded px-3 text-sm font-medium transition-colors", R === "end" ? "text-foreground" : "text-muted-foreground"),
102
- onClick: () => Y("end"),
101
+ "aria-pressed": B === "end",
102
+ className: y("relative z-10 h-9 rounded px-3 text-sm font-medium transition-colors", B === "end" ? "text-foreground" : "text-muted-foreground"),
103
+ onClick: () => Z("end"),
103
104
  children: t.endDate
104
105
  })
105
106
  ]
106
107
  })]
107
- }), /* @__PURE__ */ g("div", {
108
+ }), /* @__PURE__ */ _("div", {
108
109
  className: "overflow-hidden px-4 py-4",
109
- children: /* @__PURE__ */ _("div", {
110
- className: v("flex w-[200%] transition-transform duration-300 ease-out", R === "end" && "-translate-x-1/2"),
111
- children: [/* @__PURE__ */ g("section", {
110
+ children: /* @__PURE__ */ v("div", {
111
+ className: y("flex w-[200%] transition-transform duration-300 ease-out", B === "end" && "-translate-x-1/2"),
112
+ children: [/* @__PURE__ */ _("section", {
112
113
  className: "max-h-[calc(95dvh-9rem)] w-1/2 shrink-0 overflow-y-auto pr-4",
113
- children: /* @__PURE__ */ _("div", {
114
+ children: /* @__PURE__ */ v("div", {
114
115
  className: "flex flex-col gap-4",
115
- children: [/* @__PURE__ */ g(r, {
116
+ children: [/* @__PURE__ */ _(r, {
116
117
  id: "start-date-calendar",
117
118
  mode: "single",
118
- locale: N,
119
+ locale: P,
119
120
  showOutsideDays: !1,
120
- numberOfMonths: x,
121
+ numberOfMonths: S,
121
122
  required: !0,
122
- selected: c,
123
- month: V,
124
- onMonthChange: (e) => H(f(e)),
125
- disabled: (e) => e < I,
123
+ selected: l,
124
+ month: U,
125
+ onMonthChange: (e) => W(p(e)),
126
+ disabled: (e) => e < L,
126
127
  onSelect: (e) => {
127
- let t = e ?? void 0, n = t != null && (c == null || !d(t, c)), r = D(t);
128
- n && (K.current = !1), W(E(t, u, I)), y(t, {
128
+ let t = e ?? void 0, n = t != null && (l == null || !f(t, l)), r = O(t);
129
+ n && (J.current = !1), K(D(t, d, L)), b(t, {
129
130
  close: !1,
130
131
  openEndDatePicker: !1
131
- }), n && S(r, {
132
+ }), n && C(r, {
132
133
  close: !1,
133
134
  commit: !1
134
135
  });
@@ -136,70 +137,74 @@ var b = y, x = 1, S = v(t({ variant: "outline" }), "z-10 h-11 w-11 bg-background
136
137
  autoFocus: !0,
137
138
  "data-testid": "start-date-calendar",
138
139
  className: "w-full p-0",
139
- classNames: C
140
- }), /* @__PURE__ */ g(e, {
140
+ classNames: w
141
+ }), /* @__PURE__ */ _(e, {
141
142
  type: "button",
142
143
  className: "h-12 w-full text-base font-semibold",
143
- disabled: !c,
144
+ disabled: !l,
144
145
  "data-testid": "start-date-drawer-next",
145
146
  onClick: () => {
146
- c && Y("end");
147
+ l && Z("end");
147
148
  },
148
149
  children: t.dateDrawerNext
149
150
  })]
150
151
  })
151
- }), /* @__PURE__ */ g("section", {
152
+ }), /* @__PURE__ */ _("section", {
152
153
  className: "max-h-[calc(95dvh-9rem)] w-1/2 shrink-0 overflow-y-auto pl-4",
153
- children: /* @__PURE__ */ _("div", {
154
+ children: /* @__PURE__ */ v("div", {
154
155
  className: "flex flex-col gap-4",
155
- children: [/* @__PURE__ */ g(r, {
156
- id: "end-date-calendar",
157
- mode: "range",
158
- locale: N,
159
- showOutsideDays: !1,
160
- numberOfMonths: x,
161
- selected: {
162
- from: c,
163
- to: u
164
- },
165
- month: U,
166
- onMonthChange: (e) => W(f(e)),
167
- disabled: (e) => c && e < c || e < I,
168
- onSelect: (e, t) => {
169
- K.current = !0, S(t ?? void 0, {
170
- close: !1,
171
- commit: !1
172
- });
173
- },
174
- autoFocus: !0,
175
- "data-testid": "end-date-calendar",
176
- className: "w-full p-0",
177
- classNames: C,
178
- components: { DayButton: (e) => {
179
- let n = q != null && J != null && !e.modifiers.disabled && d(e.day.date, J);
180
- return /* @__PURE__ */ _(b, {
181
- ...e,
182
- className: v(e.className, "overflow-visible"),
183
- children: [e.children, n ? /* @__PURE__ */ g("span", {
184
- className: "pointer-events-none absolute left-1/2 top-0 z-[70] -translate-x-1/2 -translate-y-[calc(100%+4px)] whitespace-nowrap rounded-md border bg-popover px-2 py-1 text-xs font-semibold text-primary shadow-md",
185
- "data-testid": "mobile-end-date-duration-tooltip",
186
- children: t.selectedDaysTooltip?.({ count: q })
187
- }) : null]
188
- });
189
- } }
190
- }, B), /* @__PURE__ */ g(e, {
191
- type: "button",
192
- className: "h-12 w-full text-base font-semibold",
193
- disabled: !u,
194
- "data-testid": "date-drawer-next",
195
- onClick: () => {
196
- u && (G.current = !1, S(u, {
197
- close: !0,
198
- commit: !0
199
- }));
200
- },
201
- children: t.dateDrawerNext
202
- })]
156
+ children: [
157
+ /* @__PURE__ */ _(r, {
158
+ id: "end-date-calendar",
159
+ mode: "range",
160
+ locale: P,
161
+ showOutsideDays: !1,
162
+ numberOfMonths: S,
163
+ selected: {
164
+ from: l,
165
+ to: d
166
+ },
167
+ month: G,
168
+ onMonthChange: (e) => K(p(e)),
169
+ disabled: (e) => l && e < l || e < L,
170
+ onSelect: (e, t) => {
171
+ J.current = !0, C(t ?? void 0, {
172
+ close: !1,
173
+ commit: !1
174
+ });
175
+ },
176
+ autoFocus: !0,
177
+ "data-testid": "end-date-calendar",
178
+ className: "w-full p-0",
179
+ classNames: w,
180
+ components: { DayButton: (e) => {
181
+ let n = Y != null && X != null && !e.modifiers.disabled && f(e.day.date, X);
182
+ return /* @__PURE__ */ v(x, {
183
+ ...e,
184
+ className: y(e.className, "overflow-visible"),
185
+ children: [e.children, n ? /* @__PURE__ */ _("span", {
186
+ className: "pointer-events-none absolute left-1/2 top-0 z-[70] -translate-x-1/2 -translate-y-[calc(100%+4px)] whitespace-nowrap rounded-md border bg-popover px-2 py-1 text-xs font-semibold text-primary shadow-md",
187
+ "data-testid": "mobile-end-date-duration-tooltip",
188
+ children: t.selectedDaysTooltip?.({ count: Y })
189
+ }) : null]
190
+ });
191
+ } }
192
+ }, H),
193
+ /* @__PURE__ */ _(e, {
194
+ type: "button",
195
+ className: "h-12 w-full text-base font-semibold",
196
+ disabled: !d || !R,
197
+ "data-testid": "date-drawer-next",
198
+ onClick: () => {
199
+ d && (q.current = !1, C(d, {
200
+ close: !0,
201
+ commit: !0
202
+ }));
203
+ },
204
+ children: t.dateDrawerNext
205
+ }),
206
+ /* @__PURE__ */ _(c, { testId: "booking-mobile-time-slots-status" })
207
+ ]
203
208
  })
204
209
  })]
205
210
  })
@@ -208,4 +213,4 @@ var b = y, x = 1, S = v(t({ variant: "outline" }), "z-10 h-11 w-11 bg-background
208
213
  });
209
214
  };
210
215
  //#endregion
211
- export { O as BookingMobileDateDrawer };
216
+ export { k as BookingMobileDateDrawer };
@@ -1 +1 @@
1
- {"version":3,"file":"BookingStartTimeField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingStartTimeField.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,qBAAqB,+CAwJjC,CAAA"}
1
+ {"version":3,"file":"BookingStartTimeField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingStartTimeField.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,qBAAqB,+CAuKjC,CAAA"}
@@ -13,8 +13,8 @@ var f = (e, t, n) => new Intl.NumberFormat(t, {
13
13
  minimumFractionDigits: 0,
14
14
  maximumFractionDigits: 0
15
15
  }).format(e / 100), p = () => {
16
- let { labels: p, localeCode: m, currencyCode: h, startTime: g, selectStartTime: _, startTimeSlots: v, isStartTimeSelectOpen: y, setIsStartTimeSelectOpen: b, labelClassName: x, inputClassName: S, buttonClassName: C, errors: w, isHydrated: T, isStartToday: E, earliestMinutesForToday: D } = e(), O = v.map((e) => {
17
- let t = E && D != null && e.startMinutes < D, n = e.isDisabled || t, r = e.disabledReason === "closed" ? p.timeSlotClosedLabel ?? "Closed" : e.disabledReason, i = e.isExtra && e.extraAmount != null ? p.timeSlotExtraFee?.({ amount: f(e.extraAmount, m, h) }) ?? `Extra fee: ${f(e.extraAmount, m, h)}` : null, a = e.isDisabled && r ? r : null, o = i && a ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
16
+ let { labels: p, localeCode: m, currencyCode: h, startTime: g, selectStartTime: _, startTimeSlots: v, startTimeSlotsStatus: y, isStartTimeSelectOpen: b, setIsStartTimeSelectOpen: x, labelClassName: S, inputClassName: C, buttonClassName: w, errors: T, isHydrated: E, isStartToday: D, earliestMinutesForToday: O } = e(), k = v.map((e) => {
17
+ let t = D && O != null && e.startMinutes < O, n = e.isDisabled || t, r = e.disabledReason === "closed" ? p.timeSlotClosedLabel ?? "Closed" : e.disabledReason, i = e.isExtra && e.extraAmount != null ? p.timeSlotExtraFee?.({ amount: f(e.extraAmount, m, h) }) ?? `Extra fee: ${f(e.extraAmount, m, h)}` : null, a = e.isDisabled && r ? r : null, o = i && a ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
18
18
  className: "block",
19
19
  children: i
20
20
  }), /* @__PURE__ */ c("span", {
@@ -27,29 +27,29 @@ var f = (e, t, n) => new Intl.NumberFormat(t, {
27
27
  disabled: n,
28
28
  description: o
29
29
  };
30
- }), k = O.find((e) => !e.disabled)?.value, A = o(g ?? k ?? null), j = t(), M = !!j;
30
+ }), A = k.some((e) => !e.disabled), j = y !== "local" && (y !== "ready" || !A), M = y === "loading" ? p.timeSlotsLoading : y === "error" ? p.timeSlotsLoadError : y === "ready" && !A ? p.timeSlotsUnavailable : p.startTime, N = k.find((e) => !e.disabled)?.value, P = o(g ?? N ?? null), F = t(), I = !!F;
31
31
  return a(() => {
32
- y || (A.current = g ?? k ?? null);
32
+ b || (P.current = g ?? N ?? null);
33
33
  }, [
34
- k,
35
- y,
34
+ N,
35
+ b,
36
36
  g
37
37
  ]), a(() => {
38
38
  if (typeof document > "u") return;
39
39
  let e = document.getElementById("start-time-picker");
40
40
  if (!(e instanceof HTMLInputElement)) return;
41
41
  let t = (e) => {
42
- if (e.key !== "Enter" || !y) return;
42
+ if (e.key !== "Enter" || !b) return;
43
43
  e.preventDefault(), e.stopPropagation();
44
- let t = A.current ?? g ?? k;
44
+ let t = P.current ?? g ?? N;
45
45
  t && _(t);
46
46
  };
47
47
  return e.addEventListener("keydown", t, !0), () => {
48
48
  e.removeEventListener("keydown", t, !0);
49
49
  };
50
50
  }, [
51
- k,
52
- y,
51
+ N,
52
+ b,
53
53
  _,
54
54
  g
55
55
  ]), /* @__PURE__ */ l("div", {
@@ -57,46 +57,48 @@ var f = (e, t, n) => new Intl.NumberFormat(t, {
57
57
  children: [
58
58
  /* @__PURE__ */ c(n, {
59
59
  htmlFor: "start-time-picker",
60
- className: d("mb-1 block text-sm font-medium", x),
60
+ className: d("mb-1 block text-sm font-medium", S),
61
61
  children: /* @__PURE__ */ c("span", { children: p.startTime })
62
62
  }),
63
- M ? /* @__PURE__ */ c(i, {
63
+ I ? /* @__PURE__ */ c(i, {
64
64
  id: "start-time-picker",
65
- placeholder: p.startTime,
65
+ placeholder: M,
66
66
  value: g ?? null,
67
67
  onValueUpdate: (e) => {
68
- e && (A.current = e);
68
+ e && (P.current = e);
69
69
  },
70
70
  onChange: (e) => {
71
- e && (A.current = e, _(e));
71
+ e && (P.current = e, _(e));
72
72
  },
73
- options: O,
74
- open: y,
75
- onOpenChange: b,
73
+ options: k,
74
+ disabled: j,
75
+ open: b,
76
+ onOpenChange: x,
76
77
  triggerTestId: "start-time-trigger",
77
78
  contentTestId: "start-time-select-content",
78
- isHydrated: T,
79
- inputClassName: d(w.startTime && "border-destructive", S, C),
80
- portalContainer: j
79
+ isHydrated: E,
80
+ inputClassName: d(T.startTime && "border-destructive", C, w),
81
+ portalContainer: F
81
82
  }) : /* @__PURE__ */ c(u, {
82
83
  id: "start-time-picker",
83
- placeholder: p.startTime,
84
+ placeholder: M,
84
85
  value: g ?? null,
85
86
  onValueUpdate: (e) => {
86
- e && (A.current = e);
87
+ e && (P.current = e);
87
88
  },
88
89
  onChange: (e) => {
89
- e && (A.current = e, _(e));
90
+ e && (P.current = e, _(e));
90
91
  },
91
- options: O,
92
- open: y,
93
- onOpenChange: b,
92
+ options: k,
93
+ disabled: j,
94
+ open: b,
95
+ onOpenChange: x,
94
96
  triggerTestId: "start-time-trigger",
95
97
  contentTestId: "start-time-select-content",
96
- isHydrated: T,
97
- inputClassName: d(w.startTime && "border-destructive", S, C)
98
+ isHydrated: E,
99
+ inputClassName: d(T.startTime && "border-destructive", C, w)
98
100
  }),
99
- w.startTime && /* @__PURE__ */ c(r, { children: w.startTime })
101
+ T.startTime && /* @__PURE__ */ c(r, { children: T.startTime })
100
102
  ]
101
103
  });
102
104
  };
@@ -0,0 +1,7 @@
1
+ type BookingTimeSlotsStatusProps = {
2
+ className?: string;
3
+ testId?: string;
4
+ };
5
+ export declare const BookingTimeSlotsStatus: ({ className, testId, }: BookingTimeSlotsStatusProps) => import("react/jsx-runtime").JSX.Element | null;
6
+ export {};
7
+ //# sourceMappingURL=BookingTimeSlotsStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BookingTimeSlotsStatus.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.tsx"],"names":[],"mappings":"AAMA,KAAK,2BAA2B,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,wBAGpC,2BAA2B,mDA4D7B,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { Button as e } from "../../../ui/button.js";
2
+ import { useBookingPeriod as t } from "../BookingPeriodContext.js";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ import { cn as i } from "@rpcbase/ui";
5
+ //#region src/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.tsx
6
+ var a = ({ className: a, testId: o = "booking-time-slots-status" }) => {
7
+ let { labels: s, startTimeSlotsStatus: c, endTimeSlotsStatus: l, retryStartTimeSlots: u, retryEndTimeSlots: d, canCommitTimeSlots: f } = t();
8
+ if (c === "local" && l === "local") return null;
9
+ let p = c === "error" || l === "error", m = c === "loading" || l === "loading";
10
+ if (!p && !m && f) return null;
11
+ let h = p ? s.timeSlotsLoadError : m ? s.timeSlotsLoading : s.timeSlotsUnavailable;
12
+ return /* @__PURE__ */ r("div", {
13
+ role: p ? "alert" : "status",
14
+ "data-testid": o,
15
+ className: i("flex flex-wrap items-center gap-2 rounded-md border px-3 py-2 text-sm", p ? "border-destructive/40 bg-destructive/5 text-destructive" : "border-border bg-muted/40 text-muted-foreground", a),
16
+ children: [/* @__PURE__ */ n("span", { children: h }), p ? /* @__PURE__ */ n(e, {
17
+ type: "button",
18
+ variant: "outline",
19
+ size: "sm",
20
+ className: "h-7",
21
+ onClick: () => {
22
+ c === "error" && u(), l === "error" && d();
23
+ },
24
+ children: /* @__PURE__ */ n("span", { children: s.retryTimeSlots })
25
+ }) : null]
26
+ });
27
+ };
28
+ //#endregion
29
+ export { a as BookingTimeSlotsStatus };