@loczer/storefront-sdk 0.187.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.
- package/dist/chunks/booking-engine/dist/models/{Product.shared-CTuk4fiR.js → Product.shared-IYOeC3N7.js} +12 -10
- package/dist/chunks/booking-engine/dist/schemas/{base-asset-B_Dm8_Vk.js → base-asset-zsUj5_3O.js} +1 -1
- package/dist/chunks/booking-engine/dist/schemas/{base-booking-DW8AEPKo.js → base-booking-TzCge_mR.js} +2 -2
- package/dist/chunks/booking-engine/dist/schemas/{base-product-1H8l2aUv.js → base-product-DvFFzAcg.js} +1 -1
- package/dist/chunks/booking-engine/dist/schemas/{booking-engine-configuration-D02MRF9U.js → booking-engine-configuration-LnrhShqm.js} +4 -1
- package/dist/chunks/booking-engine/dist/schemas/{cart-inputs-j1yWfJxO.js → cart-inputs-B0HpcFe5.js} +1 -1
- package/dist/chunks/booking-engine/dist/schemas/{public-booking-engine-configuration-BnJ_H-p1.js → public-booking-engine-configuration-CEM9mexX.js} +1 -1
- package/dist/chunks/booking-engine/dist/schemas-BNUzqsci.js +13 -0
- package/dist/chunks/ui/dist/Map/{MapContent-QPkuTBvK.js → MapContent-PK-ptOx6.js} +126 -94
- package/dist/chunks/ui/dist/Map/mapboxError-oRn0l3EE.js +25 -0
- package/dist/chunks/ui/dist/{Map-BXmRf5Ep.js → Map-BwXj49kV.js} +1 -1
- package/dist/components/BookingBikeVariantDialog/index.d.ts +2 -1
- package/dist/components/BookingBikeVariantDialog/index.d.ts.map +1 -1
- package/dist/components/BookingBikeVariantDialog/index.js +39 -38
- package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +32 -30
- package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.js +127 -122
- package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +32 -30
- package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.d.ts +7 -0
- package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.d.ts.map +1 -0
- package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.js +29 -0
- package/dist/components/BookingPeriodSelector/index.d.ts +2 -1
- package/dist/components/BookingPeriodSelector/index.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/index.js +15 -14
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts +11 -0
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +280 -216
- package/dist/components/ContactSection/index.d.ts.map +1 -1
- package/dist/components/ContactSection/index.js +120 -116
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +35 -35
- package/dist/components/Map/index.js +1 -1
- package/dist/components/StorefrontCancellationPolicyNotice/index.d.ts.map +1 -1
- package/dist/components/StorefrontCancellationPolicyNotice/index.js +51 -48
- package/dist/components/StorefrontInsuranceNotice/index.d.ts +9 -0
- package/dist/components/StorefrontInsuranceNotice/index.d.ts.map +1 -0
- package/dist/components/StorefrontInsuranceNotice/index.js +191 -0
- package/dist/i18n/en.d.ts +24 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +26 -2
- package/dist/i18n/fr.d.ts +24 -0
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +26 -2
- package/dist/index.d.ts +91 -0
- package/dist/index.js +69 -68
- package/dist/lib/booking.js +2 -2
- package/dist/lib/checkoutSubmit.js +3 -3
- package/dist/lib/fetchStorefrontTimeSlots.d.ts.map +1 -1
- package/dist/lib/fetchStorefrontTimeSlots.js +2 -1
- package/dist/lib/storefrontProducts.d.ts +16 -0
- package/dist/lib/storefrontProducts.d.ts.map +1 -1
- package/dist/lib/storefrontProducts.js +27 -22
- package/dist/pages/BookingPage.d.ts.map +1 -1
- package/dist/pages/BookingPage.js +109 -95
- package/dist/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/pages/CheckoutPage.js +229 -231
- package/dist/pages/HomePage.d.ts.map +1 -1
- package/dist/pages/HomePage.js +339 -314
- package/dist/pages/ProductPage.d.ts.map +1 -1
- package/dist/pages/ProductPage.js +60 -52
- package/dist/storefront.css +1 -1
- package/dist/storefrontSchemas.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/booking-engine/dist/schemas-DftrSnTE.js +0 -13
|
@@ -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 {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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
|
|
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:
|
|
18
|
-
button_next:
|
|
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
|
-
},
|
|
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
|
-
},
|
|
29
|
-
if (!(!e || !
|
|
30
|
-
},
|
|
31
|
-
let { labels: t, startDate:
|
|
32
|
-
if (
|
|
33
|
-
!
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
]),
|
|
39
|
-
!
|
|
36
|
+
B,
|
|
37
|
+
z,
|
|
38
|
+
V
|
|
39
|
+
]), m(() => {
|
|
40
|
+
!z || B !== "end" || K(E(H));
|
|
40
41
|
}, [
|
|
41
|
-
R,
|
|
42
42
|
B,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
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,
|
|
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
|
-
}, [
|
|
56
|
-
let
|
|
56
|
+
}, [z]), !I || !F) return null;
|
|
57
|
+
let Z = (e) => {
|
|
57
58
|
if (e === "end") {
|
|
58
|
-
let e =
|
|
59
|
-
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
|
-
})) :
|
|
63
|
+
})) : K(E(H));
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
|
|
65
|
+
A(e === "start"), M(e === "end");
|
|
66
|
+
}, Q = () => {
|
|
67
|
+
A(!1), M(!1), N();
|
|
67
68
|
};
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
open:
|
|
69
|
+
return /* @__PURE__ */ _(i, {
|
|
70
|
+
open: z,
|
|
70
71
|
lockScroll: !1,
|
|
71
72
|
onOpenChange: (e) => {
|
|
72
|
-
e ||
|
|
73
|
+
e || Q();
|
|
73
74
|
},
|
|
74
|
-
children: /* @__PURE__ */
|
|
75
|
+
children: /* @__PURE__ */ v(a, {
|
|
75
76
|
className: "overflow-hidden",
|
|
76
77
|
closeLabel: t.closeDrawer,
|
|
77
78
|
showCloseButton: !0,
|
|
78
|
-
children: [/* @__PURE__ */
|
|
79
|
+
children: [/* @__PURE__ */ v(o, {
|
|
79
80
|
className: "border-b px-16 pb-3 pt-4 text-left",
|
|
80
|
-
children: [/* @__PURE__ */
|
|
81
|
+
children: [/* @__PURE__ */ _(s, {
|
|
81
82
|
className: "sr-only",
|
|
82
|
-
children:
|
|
83
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
88
|
+
/* @__PURE__ */ _("span", {
|
|
88
89
|
"aria-hidden": "true",
|
|
89
|
-
className:
|
|
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__ */
|
|
92
|
+
/* @__PURE__ */ _("button", {
|
|
92
93
|
type: "button",
|
|
93
|
-
"aria-pressed":
|
|
94
|
-
className:
|
|
95
|
-
onClick: () =>
|
|
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__ */
|
|
99
|
+
/* @__PURE__ */ _("button", {
|
|
99
100
|
type: "button",
|
|
100
|
-
"aria-pressed":
|
|
101
|
-
className:
|
|
102
|
-
onClick: () =>
|
|
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__ */
|
|
108
|
+
}), /* @__PURE__ */ _("div", {
|
|
108
109
|
className: "overflow-hidden px-4 py-4",
|
|
109
|
-
children: /* @__PURE__ */
|
|
110
|
-
className:
|
|
111
|
-
children: [/* @__PURE__ */
|
|
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__ */
|
|
114
|
+
children: /* @__PURE__ */ v("div", {
|
|
114
115
|
className: "flex flex-col gap-4",
|
|
115
|
-
children: [/* @__PURE__ */
|
|
116
|
+
children: [/* @__PURE__ */ _(r, {
|
|
116
117
|
id: "start-date-calendar",
|
|
117
118
|
mode: "single",
|
|
118
|
-
locale:
|
|
119
|
+
locale: P,
|
|
119
120
|
showOutsideDays: !1,
|
|
120
|
-
numberOfMonths:
|
|
121
|
+
numberOfMonths: S,
|
|
121
122
|
required: !0,
|
|
122
|
-
selected:
|
|
123
|
-
month:
|
|
124
|
-
onMonthChange: (e) =>
|
|
125
|
-
disabled: (e) => e <
|
|
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 && (
|
|
128
|
-
n && (
|
|
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 &&
|
|
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:
|
|
140
|
-
}), /* @__PURE__ */
|
|
140
|
+
classNames: w
|
|
141
|
+
}), /* @__PURE__ */ _(e, {
|
|
141
142
|
type: "button",
|
|
142
143
|
className: "h-12 w-full text-base font-semibold",
|
|
143
|
-
disabled: !
|
|
144
|
+
disabled: !l,
|
|
144
145
|
"data-testid": "start-date-drawer-next",
|
|
145
146
|
onClick: () => {
|
|
146
|
-
|
|
147
|
+
l && Z("end");
|
|
147
148
|
},
|
|
148
149
|
children: t.dateDrawerNext
|
|
149
150
|
})]
|
|
150
151
|
})
|
|
151
|
-
}), /* @__PURE__ */
|
|
152
|
+
}), /* @__PURE__ */ _("section", {
|
|
152
153
|
className: "max-h-[calc(95dvh-9rem)] w-1/2 shrink-0 overflow-y-auto pl-4",
|
|
153
|
-
children: /* @__PURE__ */
|
|
154
|
+
children: /* @__PURE__ */ v("div", {
|
|
154
155
|
className: "flex flex-col gap-4",
|
|
155
|
-
children: [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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 {
|
|
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,+
|
|
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,
|
|
17
|
-
let t =
|
|
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 =
|
|
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
|
-
|
|
32
|
+
b || (P.current = g ?? N ?? null);
|
|
33
33
|
}, [
|
|
34
|
-
|
|
35
|
-
|
|
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" || !
|
|
42
|
+
if (e.key !== "Enter" || !b) return;
|
|
43
43
|
e.preventDefault(), e.stopPropagation();
|
|
44
|
-
let t =
|
|
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
|
-
|
|
52
|
-
|
|
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",
|
|
60
|
+
className: d("mb-1 block text-sm font-medium", S),
|
|
61
61
|
children: /* @__PURE__ */ c("span", { children: p.startTime })
|
|
62
62
|
}),
|
|
63
|
-
|
|
63
|
+
I ? /* @__PURE__ */ c(i, {
|
|
64
64
|
id: "start-time-picker",
|
|
65
|
-
placeholder:
|
|
65
|
+
placeholder: M,
|
|
66
66
|
value: g ?? null,
|
|
67
67
|
onValueUpdate: (e) => {
|
|
68
|
-
e && (
|
|
68
|
+
e && (P.current = e);
|
|
69
69
|
},
|
|
70
70
|
onChange: (e) => {
|
|
71
|
-
e && (
|
|
71
|
+
e && (P.current = e, _(e));
|
|
72
72
|
},
|
|
73
|
-
options:
|
|
74
|
-
|
|
75
|
-
|
|
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:
|
|
79
|
-
inputClassName: d(
|
|
80
|
-
portalContainer:
|
|
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:
|
|
84
|
+
placeholder: M,
|
|
84
85
|
value: g ?? null,
|
|
85
86
|
onValueUpdate: (e) => {
|
|
86
|
-
e && (
|
|
87
|
+
e && (P.current = e);
|
|
87
88
|
},
|
|
88
89
|
onChange: (e) => {
|
|
89
|
-
e && (
|
|
90
|
+
e && (P.current = e, _(e));
|
|
90
91
|
},
|
|
91
|
-
options:
|
|
92
|
-
|
|
93
|
-
|
|
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:
|
|
97
|
-
inputClassName: d(
|
|
98
|
+
isHydrated: E,
|
|
99
|
+
inputClassName: d(T.startTime && "border-destructive", C, w)
|
|
98
100
|
}),
|
|
99
|
-
|
|
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 };
|
|
@@ -4,10 +4,11 @@ type BookingPeriodSelectorProps = BookingPeriodControllerOptions & {
|
|
|
4
4
|
};
|
|
5
5
|
export declare const BookingPeriodSelector: ({ className, ...options }: BookingPeriodSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export { BookingPeriodProvider, useBookingPeriod } from './BookingPeriodContext';
|
|
7
|
-
export type { BookingPeriodChangeMeta, BookingPeriodControllerOptions, BookingPeriodControllerValue, BookingPeriodLabels, BookingPeriodSelectionFlow, BookingPeriodTimeSlotsFetcher, BookingPeriodTranslator, } from './useBookingPeriodController';
|
|
7
|
+
export type { BookingPeriodChangeMeta, BookingPeriodControllerOptions, BookingPeriodControllerValue, BookingPeriodLabels, BookingPeriodSelectionFlow, BookingPeriodTimeSlotsFetcher, BookingPeriodTimeSlotsStatus, BookingPeriodTranslator, } from './useBookingPeriodController';
|
|
8
8
|
export { BookingStartDateField } from './components/BookingStartDateField';
|
|
9
9
|
export { BookingStartTimeField } from './components/BookingStartTimeField';
|
|
10
10
|
export { BookingEndDateField } from './components/BookingEndDateField';
|
|
11
11
|
export { BookingEndTimeField } from './components/BookingEndTimeField';
|
|
12
12
|
export { BookingMobileDateDrawer } from './components/BookingMobileDateDrawer';
|
|
13
|
+
export { BookingTimeSlotsStatus } from './components/BookingTimeSlotsStatus';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/BookingPeriodSelector/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/BookingPeriodSelector/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,8BAA8B,CAAA;AASlF,KAAK,0BAA0B,GAAG,8BAA8B,GAAG;IACjE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,2BAA2B,0BAA0B,4CAiB1F,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAChF,YAAY,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,4BAA4B,EAC5B,mBAAmB,EACnB,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA"}
|
|
@@ -3,26 +3,27 @@ import { BookingStartDateField as n } from "./components/BookingStartDateField.j
|
|
|
3
3
|
import { BookingStartTimeField as r } from "./components/BookingStartTimeField.js";
|
|
4
4
|
import { BookingEndDateField as i } from "./components/BookingEndDateField.js";
|
|
5
5
|
import { BookingEndTimeField as a } from "./components/BookingEndTimeField.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { BookingTimeSlotsStatus as o } from "./components/BookingTimeSlotsStatus.js";
|
|
7
|
+
import { BookingMobileDateDrawer as s } from "./components/BookingMobileDateDrawer.js";
|
|
8
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
+
import { cn as d } from "@rpcbase/ui";
|
|
9
10
|
//#region src/components/BookingPeriodSelector/index.tsx
|
|
10
|
-
var
|
|
11
|
-
...
|
|
12
|
-
children: /* @__PURE__ */ c("div", {
|
|
13
|
-
className:
|
|
11
|
+
var f = ({ className: t, ...f }) => /* @__PURE__ */ l(e, {
|
|
12
|
+
...f,
|
|
13
|
+
children: /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
|
|
14
|
+
className: d("grid grid-cols-1 gap-x-6 gap-y-4 md:grid-cols-2", t),
|
|
14
15
|
children: [
|
|
15
|
-
/* @__PURE__ */
|
|
16
|
+
/* @__PURE__ */ u("div", {
|
|
16
17
|
className: "flex items-start space-x-4",
|
|
17
|
-
children: [/* @__PURE__ */
|
|
18
|
+
children: [/* @__PURE__ */ l(n, {}), /* @__PURE__ */ l(r, {})]
|
|
18
19
|
}),
|
|
19
|
-
/* @__PURE__ */
|
|
20
|
+
/* @__PURE__ */ u("div", {
|
|
20
21
|
className: "flex items-start space-x-4",
|
|
21
|
-
children: [/* @__PURE__ */
|
|
22
|
+
children: [/* @__PURE__ */ l(i, {}), /* @__PURE__ */ l(a, {})]
|
|
22
23
|
}),
|
|
23
|
-
/* @__PURE__ */ s
|
|
24
|
+
/* @__PURE__ */ l(s, {})
|
|
24
25
|
]
|
|
25
|
-
})
|
|
26
|
+
}), /* @__PURE__ */ l(o, { className: "mt-2" })] })
|
|
26
27
|
});
|
|
27
28
|
//#endregion
|
|
28
|
-
export { i as BookingEndDateField, a as BookingEndTimeField,
|
|
29
|
+
export { i as BookingEndDateField, a as BookingEndTimeField, s as BookingMobileDateDrawer, e as BookingPeriodProvider, f as BookingPeriodSelector, n as BookingStartDateField, r as BookingStartTimeField, o as BookingTimeSlotsStatus, t as useBookingPeriod };
|
|
@@ -7,6 +7,7 @@ export type BookingPeriodChangeMeta = {
|
|
|
7
7
|
};
|
|
8
8
|
export type BookingPeriodTranslator = (key: string, options?: Record<string, unknown>) => string;
|
|
9
9
|
export type BookingPeriodTimeSlotsFetcher = (date: string, journey: JourneyType) => Promise<TimeSlot[] | null>;
|
|
10
|
+
export type BookingPeriodTimeSlotsStatus = "local" | "loading" | "ready" | "error";
|
|
10
11
|
export type BookingPeriodLabels = {
|
|
11
12
|
startDate: string;
|
|
12
13
|
pickStartDate: string;
|
|
@@ -24,6 +25,10 @@ export type BookingPeriodLabels = {
|
|
|
24
25
|
rentalPeriod?: string;
|
|
25
26
|
dateDrawerNext?: string;
|
|
26
27
|
closeDrawer?: string;
|
|
28
|
+
timeSlotsLoading?: string;
|
|
29
|
+
timeSlotsUnavailable?: string;
|
|
30
|
+
timeSlotsLoadError?: string;
|
|
31
|
+
retryTimeSlots?: string;
|
|
27
32
|
};
|
|
28
33
|
export type BookingPeriodSelectionFlow = "chained-times" | "dates-first";
|
|
29
34
|
export interface BookingPeriodControllerOptions {
|
|
@@ -51,6 +56,7 @@ export interface BookingPeriodControllerOptions {
|
|
|
51
56
|
buttonClassName?: string;
|
|
52
57
|
bookingPeriodConfig?: BookingPeriodConfig;
|
|
53
58
|
fetchTimeSlots?: BookingPeriodTimeSlotsFetcher;
|
|
59
|
+
onTimeSlotsAvailabilityChange?: (isAvailable: boolean) => void;
|
|
54
60
|
selectionFlow?: BookingPeriodSelectionFlow;
|
|
55
61
|
withMobileDateDrawer?: boolean;
|
|
56
62
|
currencyCode?: string;
|
|
@@ -96,6 +102,11 @@ export interface BookingPeriodControllerValue {
|
|
|
96
102
|
resetHoveredEndDate: () => void;
|
|
97
103
|
startTimeSlots: TimeSlot[];
|
|
98
104
|
availableEndTimeSlots: TimeSlot[];
|
|
105
|
+
startTimeSlotsStatus: BookingPeriodTimeSlotsStatus;
|
|
106
|
+
endTimeSlotsStatus: BookingPeriodTimeSlotsStatus;
|
|
107
|
+
retryStartTimeSlots: () => void;
|
|
108
|
+
retryEndTimeSlots: () => void;
|
|
109
|
+
canCommitTimeSlots: boolean;
|
|
99
110
|
isStartToday: boolean;
|
|
100
111
|
isEndToday: boolean;
|
|
101
112
|
minSelectableDate: Date;
|