@loczer/storefront-sdk 0.157.0 → 0.159.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/components/BookingPeriodSelector/components/BookingEndDateField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +267 -227
- package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +51 -53
- package/dist/components/BookingPeriodSelector/components/BookingStartDateField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +70 -66
- package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +69 -89
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts +1 -0
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +33 -32
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,113 +1,111 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { useMorphingModalWizardOverlayLayer as
|
|
5
|
-
import { Label as
|
|
6
|
-
import { useBookingPeriod as
|
|
7
|
-
import { BookingPeriodFieldErrorMessage as
|
|
8
|
-
import { ModalHourPickerField as
|
|
9
|
-
const v = (
|
|
1
|
+
import { jsxs as M, Fragment as w, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as P, useEffect as N } from "react";
|
|
3
|
+
import { cn as T, HourPickerField as V } from "@rpcbase/ui";
|
|
4
|
+
import { useMorphingModalWizardOverlayLayer as H } from "../../../chunks/ui/dist/MorphingModalWizard-D7hc-dDP.js";
|
|
5
|
+
import { Label as U } from "../../../ui/label.js";
|
|
6
|
+
import { useBookingPeriod as A } from "../BookingPeriodContext.js";
|
|
7
|
+
import { BookingPeriodFieldErrorMessage as j } from "./BookingPeriodFieldErrorMessage.js";
|
|
8
|
+
import { ModalHourPickerField as z } from "./internal/ModalHourPickerField.js";
|
|
9
|
+
const v = (n, o, d) => new Intl.NumberFormat(o, {
|
|
10
10
|
style: "currency",
|
|
11
11
|
currency: d,
|
|
12
12
|
minimumFractionDigits: 0,
|
|
13
13
|
maximumFractionDigits: 0
|
|
14
|
-
}).format(
|
|
14
|
+
}).format(n / 100), Y = () => {
|
|
15
15
|
const {
|
|
16
|
-
labels:
|
|
16
|
+
labels: n,
|
|
17
17
|
localeCode: o,
|
|
18
18
|
currencyCode: d,
|
|
19
|
-
endTime:
|
|
19
|
+
endTime: t,
|
|
20
20
|
selectEndTime: m,
|
|
21
21
|
availableEndTimeSlots: I,
|
|
22
22
|
isEndTimeSelectOpen: i,
|
|
23
|
-
setIsEndTimeSelectOpen:
|
|
24
|
-
labelClassName:
|
|
25
|
-
inputClassName:
|
|
26
|
-
buttonClassName:
|
|
23
|
+
setIsEndTimeSelectOpen: h,
|
|
24
|
+
labelClassName: L,
|
|
25
|
+
inputClassName: y,
|
|
26
|
+
buttonClassName: E,
|
|
27
27
|
errors: c,
|
|
28
|
-
isHydrated:
|
|
29
|
-
startMinutesValue:
|
|
30
|
-
isSameDaySelection:
|
|
28
|
+
isHydrated: k,
|
|
29
|
+
startMinutesValue: C,
|
|
30
|
+
isSameDaySelection: S,
|
|
31
31
|
isEndToday: O,
|
|
32
|
-
earliestMinutesForToday:
|
|
33
|
-
} =
|
|
34
|
-
const u = !!
|
|
32
|
+
earliestMinutesForToday: F
|
|
33
|
+
} = A(), f = I.map((e) => {
|
|
34
|
+
const u = !!S && C != null && e.startMinutes <= C, l = O && F != null && e.startMinutes < F, p = e.isDisabled || u || l, D = e.disabledReason === "closed" ? n.timeSlotClosedLabel ?? "Closed" : e.disabledReason, b = e.isExtra && e.extraAmount != null ? n.timeSlotExtraFee?.({
|
|
35
35
|
amount: v(e.extraAmount, o, d)
|
|
36
|
-
}) ?? `Extra fee: ${v(e.extraAmount, o, d)}` : null, g = e.isDisabled &&
|
|
36
|
+
}) ?? `Extra fee: ${v(e.extraAmount, o, d)}` : null, g = e.isDisabled && D ? D : null, R = b && g ? /* @__PURE__ */ M(w, { children: [
|
|
37
37
|
/* @__PURE__ */ r("span", { className: "block", children: b }),
|
|
38
38
|
/* @__PURE__ */ r("span", { className: "block", children: g })
|
|
39
39
|
] }) : b ?? g ?? void 0;
|
|
40
40
|
return {
|
|
41
41
|
value: e.value,
|
|
42
42
|
label: e.label,
|
|
43
|
-
disabled:
|
|
44
|
-
description:
|
|
43
|
+
disabled: p,
|
|
44
|
+
description: R
|
|
45
45
|
};
|
|
46
|
-
}), a =
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
}, []),
|
|
50
|
-
i || (s.current = n ?? a ?? null);
|
|
51
|
-
}, [n, a, i]), T(() => {
|
|
46
|
+
}), a = f.find((e) => !e.disabled)?.value, s = P(t ?? a ?? null), x = H(), B = !!x;
|
|
47
|
+
return N(() => {
|
|
48
|
+
i || (s.current = t ?? a ?? null);
|
|
49
|
+
}, [t, a, i]), N(() => {
|
|
52
50
|
const e = document.getElementById("end-time-picker");
|
|
53
51
|
if (!(e instanceof HTMLInputElement))
|
|
54
52
|
return;
|
|
55
53
|
const u = (l) => {
|
|
56
54
|
if (l.key !== "Enter" || !i) return;
|
|
57
55
|
l.preventDefault(), l.stopPropagation();
|
|
58
|
-
const
|
|
59
|
-
|
|
56
|
+
const p = s.current ?? t ?? a;
|
|
57
|
+
p && m(p);
|
|
60
58
|
};
|
|
61
59
|
return e.addEventListener("keydown", u, !0), () => {
|
|
62
60
|
e.removeEventListener("keydown", u, !0);
|
|
63
61
|
};
|
|
64
|
-
}, [
|
|
65
|
-
/* @__PURE__ */ r(
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
}, [t, a, i, m]), /* @__PURE__ */ M("div", { className: "group/form-item relative w-[150px]", children: [
|
|
63
|
+
/* @__PURE__ */ r(U, { htmlFor: "end-time-picker", className: T("mb-1 block text-sm font-medium", L), children: /* @__PURE__ */ r("span", { children: n.endTime }) }),
|
|
64
|
+
B ? /* @__PURE__ */ r(
|
|
65
|
+
z,
|
|
68
66
|
{
|
|
69
67
|
id: "end-time-picker",
|
|
70
|
-
placeholder:
|
|
71
|
-
value:
|
|
68
|
+
placeholder: n.endTime,
|
|
69
|
+
value: t ?? null,
|
|
72
70
|
onValueUpdate: (e) => {
|
|
73
71
|
e && (s.current = e);
|
|
74
72
|
},
|
|
75
73
|
onChange: (e) => {
|
|
76
74
|
e && (s.current = e, m(e));
|
|
77
75
|
},
|
|
78
|
-
options:
|
|
76
|
+
options: f,
|
|
79
77
|
open: i,
|
|
80
|
-
onOpenChange:
|
|
78
|
+
onOpenChange: h,
|
|
81
79
|
triggerTestId: "end-time-trigger",
|
|
82
80
|
contentTestId: "end-time-select-content",
|
|
83
|
-
isHydrated:
|
|
84
|
-
inputClassName:
|
|
85
|
-
portalContainer:
|
|
81
|
+
isHydrated: k,
|
|
82
|
+
inputClassName: T(c.endTime && "border-destructive", y, E),
|
|
83
|
+
portalContainer: x
|
|
86
84
|
}
|
|
87
85
|
) : /* @__PURE__ */ r(
|
|
88
|
-
|
|
86
|
+
V,
|
|
89
87
|
{
|
|
90
88
|
id: "end-time-picker",
|
|
91
|
-
placeholder:
|
|
92
|
-
value:
|
|
89
|
+
placeholder: n.endTime,
|
|
90
|
+
value: t ?? null,
|
|
93
91
|
onValueUpdate: (e) => {
|
|
94
92
|
e && (s.current = e);
|
|
95
93
|
},
|
|
96
94
|
onChange: (e) => {
|
|
97
95
|
e && (s.current = e, m(e));
|
|
98
96
|
},
|
|
99
|
-
options:
|
|
97
|
+
options: f,
|
|
100
98
|
open: i,
|
|
101
|
-
onOpenChange:
|
|
99
|
+
onOpenChange: h,
|
|
102
100
|
triggerTestId: "end-time-trigger",
|
|
103
101
|
contentTestId: "end-time-select-content",
|
|
104
|
-
isHydrated:
|
|
105
|
-
inputClassName:
|
|
102
|
+
isHydrated: k,
|
|
103
|
+
inputClassName: T(c.endTime && "border-destructive", y, E)
|
|
106
104
|
}
|
|
107
105
|
),
|
|
108
|
-
c.endTime && /* @__PURE__ */ r(
|
|
106
|
+
c.endTime && /* @__PURE__ */ r(j, { children: c.endTime })
|
|
109
107
|
] });
|
|
110
108
|
};
|
|
111
109
|
export {
|
|
112
|
-
|
|
110
|
+
Y as BookingEndTimeField
|
|
113
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BookingStartDateField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingStartDateField.tsx"],"names":[],"mappings":"AA4HA,eAAO,MAAM,qBAAqB,+
|
|
1
|
+
{"version":3,"file":"BookingStartDateField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingStartDateField.tsx"],"names":[],"mappings":"AA4HA,eAAO,MAAM,qBAAqB,+CA0KjC,CAAA"}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { DayButton as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { useMorphingModalWizardOverlayLayer as
|
|
1
|
+
import { jsxs as I, jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as L, useState as A, useEffect as H } from "react";
|
|
3
|
+
import { DayButton as U } from "react-day-picker";
|
|
4
|
+
import { cn as f, DayPickerField as K } from "@rpcbase/ui";
|
|
5
|
+
import { useMorphingModalWizardOverlayLayer as R } from "../../../chunks/ui/dist/MorphingModalWizard-D7hc-dDP.js";
|
|
6
6
|
import { DayPicker as v } from "../../../ui/day-picker.js";
|
|
7
|
-
import { Label as
|
|
8
|
-
import { useBookingPeriod as
|
|
9
|
-
import { BookingPeriodFieldErrorMessage as
|
|
10
|
-
import { ModalDayPickerField as
|
|
11
|
-
const
|
|
7
|
+
import { Label as _ } from "../../../ui/label.js";
|
|
8
|
+
import { useBookingPeriod as $ } from "../BookingPeriodContext.js";
|
|
9
|
+
import { BookingPeriodFieldErrorMessage as j } from "./BookingPeriodFieldErrorMessage.js";
|
|
10
|
+
import { ModalDayPickerField as q } from "./internal/ModalDayPickerField.js";
|
|
11
|
+
const k = (e) => {
|
|
12
12
|
const t = e.modifiers.disabled ? "cursor-not-allowed" : "cursor-pointer";
|
|
13
|
-
return /* @__PURE__ */ u(
|
|
13
|
+
return /* @__PURE__ */ u(U, { ...e, className: f(e.className, t) });
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
const
|
|
15
|
+
k.displayName = "BookingStartDateDayButton";
|
|
16
|
+
const y = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), z = (e) => {
|
|
17
17
|
const t = e.trim();
|
|
18
18
|
if (!t)
|
|
19
19
|
return null;
|
|
20
20
|
const i = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(t);
|
|
21
21
|
if (i) {
|
|
22
22
|
const s = Number(i[1]), n = Number(i[2]), o = Number(i[3]), r = new Date(o, n - 1, s);
|
|
23
|
-
return Number.isNaN(r.getTime()) || r.getFullYear() !== o || r.getMonth() !== n - 1 || r.getDate() !== s ? null :
|
|
23
|
+
return Number.isNaN(r.getTime()) || r.getFullYear() !== o || r.getMonth() !== n - 1 || r.getDate() !== s ? null : y(r);
|
|
24
24
|
}
|
|
25
25
|
const l = /^(\d{2})\/(\d{2})\/(\d{2})$/.exec(t);
|
|
26
26
|
if (l) {
|
|
27
27
|
const s = Number(l[1]), n = Number(l[2]), o = 2e3 + Number(l[3]), r = new Date(o, n - 1, s);
|
|
28
|
-
return Number.isNaN(r.getTime()) || r.getFullYear() !== o || r.getMonth() !== n - 1 || r.getDate() !== s ? null :
|
|
28
|
+
return Number.isNaN(r.getTime()) || r.getFullYear() !== o || r.getMonth() !== n - 1 || r.getDate() !== s ? null : y(r);
|
|
29
29
|
}
|
|
30
30
|
const d = /^(\d{2})\/(\d{2})$/.exec(t);
|
|
31
31
|
if (d) {
|
|
32
32
|
const s = Number(d[1]), n = Number(d[2]), o = (/* @__PURE__ */ new Date()).getFullYear(), r = new Date(o, n - 1, s);
|
|
33
|
-
return Number.isNaN(r.getTime()) || r.getFullYear() !== o || r.getMonth() !== n - 1 || r.getDate() !== s ? null :
|
|
33
|
+
return Number.isNaN(r.getTime()) || r.getFullYear() !== o || r.getMonth() !== n - 1 || r.getDate() !== s ? null : y(r);
|
|
34
34
|
}
|
|
35
35
|
return null;
|
|
36
|
-
},
|
|
36
|
+
}, V = (e, t) => e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate(), W = (e) => {
|
|
37
37
|
if (typeof document > "u")
|
|
38
38
|
return e.current = !1, !1;
|
|
39
39
|
const t = document.activeElement, i = e.current && t instanceof HTMLElement && t.id === "start-date-picker";
|
|
40
40
|
return e.current = !1, i;
|
|
41
|
-
},
|
|
41
|
+
}, G = () => {
|
|
42
42
|
if (typeof document > "u")
|
|
43
43
|
return !1;
|
|
44
44
|
const e = document.activeElement;
|
|
45
45
|
return e instanceof HTMLElement ? !!(document.getElementById("start-date-calendar")?.contains(e) || e.id === "start-date-picker") : !1;
|
|
46
|
-
},
|
|
46
|
+
}, J = "You cannot select date in the past", ie = () => {
|
|
47
47
|
const {
|
|
48
48
|
labels: e,
|
|
49
49
|
startDate: t,
|
|
@@ -54,59 +54,63 @@ const D = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), W = (e) =
|
|
|
54
54
|
inputClassName: n,
|
|
55
55
|
buttonClassName: o,
|
|
56
56
|
errors: r,
|
|
57
|
-
dateLocale:
|
|
58
|
-
numberOfMonths:
|
|
59
|
-
isMobile:
|
|
57
|
+
dateLocale: b,
|
|
58
|
+
numberOfMonths: N,
|
|
59
|
+
isMobile: S,
|
|
60
60
|
isHydrated: M,
|
|
61
|
-
openDatePickerOnFocus:
|
|
62
|
-
withMobileDateDrawer:
|
|
63
|
-
minSelectableDate:
|
|
64
|
-
} =
|
|
65
|
-
|
|
66
|
-
L(!0);
|
|
67
|
-
}, []), O(() => {
|
|
61
|
+
openDatePickerOnFocus: O,
|
|
62
|
+
withMobileDateDrawer: B,
|
|
63
|
+
minSelectableDate: w
|
|
64
|
+
} = $(), c = B && S, g = L(!1), [T, m] = A(null), E = R(), x = !!E;
|
|
65
|
+
H(() => {
|
|
68
66
|
if (typeof document > "u")
|
|
69
67
|
return;
|
|
70
68
|
const a = document.getElementById("start-date-picker");
|
|
71
69
|
if (!(a instanceof HTMLInputElement))
|
|
72
70
|
return;
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
|
|
71
|
+
const p = (h) => {
|
|
72
|
+
if (h.key === "ArrowUp" || h.key === "ArrowDown") {
|
|
73
|
+
g.current = !0;
|
|
76
74
|
return;
|
|
77
75
|
}
|
|
78
|
-
if (
|
|
79
|
-
const P =
|
|
76
|
+
if (g.current = !1, h.key !== "Enter") return;
|
|
77
|
+
const P = z(a.value);
|
|
80
78
|
if (!P) return;
|
|
81
|
-
const
|
|
82
|
-
P <
|
|
79
|
+
const Y = y(/* @__PURE__ */ new Date());
|
|
80
|
+
P < Y ? m(J) : m(null);
|
|
83
81
|
};
|
|
84
|
-
return a.addEventListener("keydown",
|
|
85
|
-
a.removeEventListener("keydown",
|
|
82
|
+
return a.addEventListener("keydown", p, !0), () => {
|
|
83
|
+
a.removeEventListener("keydown", p, !0);
|
|
86
84
|
};
|
|
87
85
|
}, []);
|
|
88
|
-
const
|
|
89
|
-
a
|
|
90
|
-
|
|
86
|
+
const C = (a) => {
|
|
87
|
+
if (!a || (m(null), W(g)) || t && V(a, t))
|
|
88
|
+
return;
|
|
89
|
+
const p = G();
|
|
90
|
+
i(a, {
|
|
91
|
+
openTimePicker: p ? void 0 : !1,
|
|
92
|
+
openEndDatePicker: p ? void 0 : !1
|
|
93
|
+
});
|
|
94
|
+
}, D = r.startDate ?? T, F = () => {
|
|
91
95
|
c && d(!0);
|
|
92
96
|
};
|
|
93
|
-
return /* @__PURE__ */
|
|
97
|
+
return /* @__PURE__ */ I(
|
|
94
98
|
"div",
|
|
95
99
|
{
|
|
96
|
-
className:
|
|
97
|
-
onPointerDownCapture:
|
|
98
|
-
onClick:
|
|
100
|
+
className: f("group/form-item relative flex-grow", c && "cursor-pointer rounded-md"),
|
|
101
|
+
onPointerDownCapture: F,
|
|
102
|
+
onClick: F,
|
|
99
103
|
children: [
|
|
100
104
|
/* @__PURE__ */ u(
|
|
101
|
-
|
|
105
|
+
_,
|
|
102
106
|
{
|
|
103
107
|
htmlFor: "start-date-picker",
|
|
104
|
-
className:
|
|
108
|
+
className: f("mb-1 block text-sm font-medium", c && "cursor-pointer", s),
|
|
105
109
|
children: /* @__PURE__ */ u("span", { children: e.startDate })
|
|
106
110
|
}
|
|
107
111
|
),
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
x ? /* @__PURE__ */ u(
|
|
113
|
+
q,
|
|
110
114
|
{
|
|
111
115
|
id: "start-date-picker",
|
|
112
116
|
value: t ?? null,
|
|
@@ -116,30 +120,30 @@ const D = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), W = (e) =
|
|
|
116
120
|
open: c ? !1 : l,
|
|
117
121
|
onOpenChange: d,
|
|
118
122
|
readOnly: c,
|
|
119
|
-
openOnFocus:
|
|
123
|
+
openOnFocus: O,
|
|
120
124
|
onValueUpdate: () => {
|
|
121
125
|
m(null);
|
|
122
126
|
},
|
|
123
|
-
onChange:
|
|
124
|
-
inputClassName:
|
|
127
|
+
onChange: C,
|
|
128
|
+
inputClassName: f(D && "border-destructive", n, o),
|
|
125
129
|
dayPickerComponent: v,
|
|
126
130
|
dayPickerProps: {
|
|
127
131
|
id: "start-date-calendar",
|
|
128
|
-
locale:
|
|
132
|
+
locale: b,
|
|
129
133
|
showOutsideDays: !1,
|
|
130
|
-
numberOfMonths:
|
|
134
|
+
numberOfMonths: N,
|
|
131
135
|
required: !0,
|
|
132
136
|
components: {
|
|
133
|
-
DayButton:
|
|
137
|
+
DayButton: k
|
|
134
138
|
},
|
|
135
|
-
disabled: (a) => a <
|
|
139
|
+
disabled: (a) => a < w,
|
|
136
140
|
initialFocus: !0,
|
|
137
141
|
"data-testid": "start-date-calendar"
|
|
138
142
|
},
|
|
139
|
-
portalContainer:
|
|
143
|
+
portalContainer: E
|
|
140
144
|
}
|
|
141
145
|
) : /* @__PURE__ */ u(
|
|
142
|
-
|
|
146
|
+
K,
|
|
143
147
|
{
|
|
144
148
|
id: "start-date-picker",
|
|
145
149
|
value: t ?? null,
|
|
@@ -152,29 +156,29 @@ const D = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), W = (e) =
|
|
|
152
156
|
onValueUpdate: () => {
|
|
153
157
|
m(null);
|
|
154
158
|
},
|
|
155
|
-
onChange:
|
|
156
|
-
inputClassName:
|
|
159
|
+
onChange: C,
|
|
160
|
+
inputClassName: f(D && "border-destructive", n, o),
|
|
157
161
|
dayPickerComponent: v,
|
|
158
162
|
dayPickerProps: {
|
|
159
163
|
id: "start-date-calendar",
|
|
160
|
-
locale:
|
|
164
|
+
locale: b,
|
|
161
165
|
showOutsideDays: !1,
|
|
162
|
-
numberOfMonths:
|
|
166
|
+
numberOfMonths: N,
|
|
163
167
|
required: !0,
|
|
164
168
|
components: {
|
|
165
|
-
DayButton:
|
|
169
|
+
DayButton: k
|
|
166
170
|
},
|
|
167
|
-
disabled: (a) => a <
|
|
171
|
+
disabled: (a) => a < w,
|
|
168
172
|
initialFocus: !0,
|
|
169
173
|
"data-testid": "start-date-calendar"
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
176
|
),
|
|
173
|
-
|
|
177
|
+
D && /* @__PURE__ */ u(j, { children: D })
|
|
174
178
|
]
|
|
175
179
|
}
|
|
176
180
|
);
|
|
177
181
|
};
|
|
178
182
|
export {
|
|
179
|
-
|
|
183
|
+
ie as BookingStartDateField
|
|
180
184
|
};
|
|
@@ -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,+CAwJjC,CAAA"}
|
|
@@ -1,131 +1,111 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { useMorphingModalWizardOverlayLayer as
|
|
5
|
-
import { Label as
|
|
6
|
-
import { useBookingPeriod as
|
|
7
|
-
import { BookingPeriodFieldErrorMessage as
|
|
8
|
-
import { ModalHourPickerField as
|
|
9
|
-
const
|
|
1
|
+
import { jsxs as E, Fragment as B, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as O, useEffect as S } from "react";
|
|
3
|
+
import { cn as T, HourPickerField as R } from "@rpcbase/ui";
|
|
4
|
+
import { useMorphingModalWizardOverlayLayer as w } from "../../../chunks/ui/dist/MorphingModalWizard-D7hc-dDP.js";
|
|
5
|
+
import { Label as P } from "../../../ui/label.js";
|
|
6
|
+
import { useBookingPeriod as H } from "../BookingPeriodContext.js";
|
|
7
|
+
import { BookingPeriodFieldErrorMessage as U } from "./BookingPeriodFieldErrorMessage.js";
|
|
8
|
+
import { ModalHourPickerField as V } from "./internal/ModalHourPickerField.js";
|
|
9
|
+
const N = (t, m, d) => new Intl.NumberFormat(m, {
|
|
10
10
|
style: "currency",
|
|
11
11
|
currency: d,
|
|
12
12
|
minimumFractionDigits: 0,
|
|
13
13
|
maximumFractionDigits: 0
|
|
14
|
-
}).format(
|
|
14
|
+
}).format(t / 100), J = () => {
|
|
15
15
|
const {
|
|
16
|
-
labels:
|
|
17
|
-
localeCode:
|
|
16
|
+
labels: t,
|
|
17
|
+
localeCode: m,
|
|
18
18
|
currencyCode: d,
|
|
19
|
-
startTime:
|
|
20
|
-
selectStartTime:
|
|
21
|
-
startTimeSlots:
|
|
22
|
-
isStartTimeSelectOpen:
|
|
23
|
-
setIsStartTimeSelectOpen:
|
|
24
|
-
labelClassName:
|
|
25
|
-
inputClassName:
|
|
19
|
+
startTime: r,
|
|
20
|
+
selectStartTime: c,
|
|
21
|
+
startTimeSlots: D,
|
|
22
|
+
isStartTimeSelectOpen: s,
|
|
23
|
+
setIsStartTimeSelectOpen: h,
|
|
24
|
+
labelClassName: v,
|
|
25
|
+
inputClassName: y,
|
|
26
26
|
buttonClassName: k,
|
|
27
|
-
errors:
|
|
28
|
-
isHydrated:
|
|
27
|
+
errors: u,
|
|
28
|
+
isHydrated: C,
|
|
29
29
|
isStartToday: I,
|
|
30
|
-
earliestMinutesForToday:
|
|
31
|
-
} =
|
|
32
|
-
const
|
|
33
|
-
amount:
|
|
34
|
-
}) ?? `Extra fee: ${
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
] }) :
|
|
30
|
+
earliestMinutesForToday: F
|
|
31
|
+
} = H(), p = D.map((e) => {
|
|
32
|
+
const f = I && F != null && e.startMinutes < F, o = e.isDisabled || f, l = e.disabledReason === "closed" ? t.timeSlotClosedLabel ?? "Closed" : e.disabledReason, b = e.isExtra && e.extraAmount != null ? t.timeSlotExtraFee?.({
|
|
33
|
+
amount: N(e.extraAmount, m, d)
|
|
34
|
+
}) ?? `Extra fee: ${N(e.extraAmount, m, d)}` : null, g = e.isDisabled && l ? l : null, M = b && g ? /* @__PURE__ */ E(B, { children: [
|
|
35
|
+
/* @__PURE__ */ n("span", { className: "block", children: b }),
|
|
36
|
+
/* @__PURE__ */ n("span", { className: "block", children: g })
|
|
37
|
+
] }) : b ?? g ?? void 0;
|
|
38
38
|
return {
|
|
39
39
|
value: e.value,
|
|
40
40
|
label: e.label,
|
|
41
|
-
disabled:
|
|
42
|
-
description:
|
|
41
|
+
disabled: o,
|
|
42
|
+
description: M
|
|
43
43
|
};
|
|
44
|
-
}),
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
}, []),
|
|
48
|
-
o || (l.current = s ?? m ?? null);
|
|
49
|
-
}, [m, o, s]), b(() => {
|
|
44
|
+
}), a = p.find((e) => !e.disabled)?.value, i = O(r ?? a ?? null), x = w(), L = !!x;
|
|
45
|
+
return S(() => {
|
|
46
|
+
s || (i.current = r ?? a ?? null);
|
|
47
|
+
}, [a, s, r]), S(() => {
|
|
50
48
|
if (typeof document > "u")
|
|
51
49
|
return;
|
|
52
50
|
const e = document.getElementById("start-time-picker");
|
|
53
51
|
if (!(e instanceof HTMLInputElement))
|
|
54
52
|
return;
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
53
|
+
const f = (o) => {
|
|
54
|
+
if (o.key !== "Enter" || !s) return;
|
|
55
|
+
o.preventDefault(), o.stopPropagation();
|
|
56
|
+
const l = i.current ?? r ?? a;
|
|
57
|
+
l && c(l);
|
|
60
58
|
};
|
|
61
|
-
return e.addEventListener("keydown",
|
|
62
|
-
e.removeEventListener("keydown",
|
|
59
|
+
return e.addEventListener("keydown", f, !0), () => {
|
|
60
|
+
e.removeEventListener("keydown", f, !0);
|
|
63
61
|
};
|
|
64
|
-
}, [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (!(e instanceof HTMLInputElement))
|
|
69
|
-
return;
|
|
70
|
-
const i = () => {
|
|
71
|
-
requestAnimationFrame(() => {
|
|
72
|
-
const t = document.activeElement;
|
|
73
|
-
if (t instanceof HTMLElement && t.id === "start-time-picker")
|
|
74
|
-
return;
|
|
75
|
-
const r = document.querySelector("[data-testid='start-time-select-content']");
|
|
76
|
-
r instanceof HTMLElement && t instanceof Node && r.contains(t) || f(!1);
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
return e.addEventListener("blur", i, !0), () => {
|
|
80
|
-
e.removeEventListener("blur", i, !0);
|
|
81
|
-
};
|
|
82
|
-
}, [f]), /* @__PURE__ */ x("div", { className: "group/form-item relative w-[150px]", children: [
|
|
83
|
-
/* @__PURE__ */ a(U, { htmlFor: "start-time-picker", className: y("mb-1 block text-sm font-medium", S), children: /* @__PURE__ */ a("span", { children: n.startTime }) }),
|
|
84
|
-
B ? /* @__PURE__ */ a(
|
|
85
|
-
q,
|
|
62
|
+
}, [a, s, c, r]), /* @__PURE__ */ E("div", { className: "group/form-item relative w-[150px]", children: [
|
|
63
|
+
/* @__PURE__ */ n(P, { htmlFor: "start-time-picker", className: T("mb-1 block text-sm font-medium", v), children: /* @__PURE__ */ n("span", { children: t.startTime }) }),
|
|
64
|
+
L ? /* @__PURE__ */ n(
|
|
65
|
+
V,
|
|
86
66
|
{
|
|
87
67
|
id: "start-time-picker",
|
|
88
|
-
placeholder:
|
|
89
|
-
value:
|
|
68
|
+
placeholder: t.startTime,
|
|
69
|
+
value: r ?? null,
|
|
90
70
|
onValueUpdate: (e) => {
|
|
91
|
-
e && (
|
|
71
|
+
e && (i.current = e);
|
|
92
72
|
},
|
|
93
73
|
onChange: (e) => {
|
|
94
|
-
e && (
|
|
74
|
+
e && (i.current = e, c(e));
|
|
95
75
|
},
|
|
96
|
-
options:
|
|
97
|
-
open:
|
|
98
|
-
onOpenChange:
|
|
76
|
+
options: p,
|
|
77
|
+
open: s,
|
|
78
|
+
onOpenChange: h,
|
|
99
79
|
triggerTestId: "start-time-trigger",
|
|
100
80
|
contentTestId: "start-time-select-content",
|
|
101
|
-
isHydrated:
|
|
102
|
-
inputClassName:
|
|
103
|
-
portalContainer:
|
|
81
|
+
isHydrated: C,
|
|
82
|
+
inputClassName: T(u.startTime && "border-destructive", y, k),
|
|
83
|
+
portalContainer: x
|
|
104
84
|
}
|
|
105
|
-
) : /* @__PURE__ */
|
|
106
|
-
|
|
85
|
+
) : /* @__PURE__ */ n(
|
|
86
|
+
R,
|
|
107
87
|
{
|
|
108
88
|
id: "start-time-picker",
|
|
109
|
-
placeholder:
|
|
110
|
-
value:
|
|
89
|
+
placeholder: t.startTime,
|
|
90
|
+
value: r ?? null,
|
|
111
91
|
onValueUpdate: (e) => {
|
|
112
|
-
e && (
|
|
92
|
+
e && (i.current = e);
|
|
113
93
|
},
|
|
114
94
|
onChange: (e) => {
|
|
115
|
-
e && (
|
|
95
|
+
e && (i.current = e, c(e));
|
|
116
96
|
},
|
|
117
|
-
options:
|
|
118
|
-
open:
|
|
119
|
-
onOpenChange:
|
|
97
|
+
options: p,
|
|
98
|
+
open: s,
|
|
99
|
+
onOpenChange: h,
|
|
120
100
|
triggerTestId: "start-time-trigger",
|
|
121
101
|
contentTestId: "start-time-select-content",
|
|
122
|
-
isHydrated:
|
|
123
|
-
inputClassName:
|
|
102
|
+
isHydrated: C,
|
|
103
|
+
inputClassName: T(u.startTime && "border-destructive", y, k)
|
|
124
104
|
}
|
|
125
105
|
),
|
|
126
|
-
|
|
106
|
+
u.startTime && /* @__PURE__ */ n(U, { children: u.startTime })
|
|
127
107
|
] });
|
|
128
108
|
};
|
|
129
109
|
export {
|
|
130
|
-
|
|
110
|
+
J as BookingStartTimeField
|
|
131
111
|
};
|
|
@@ -81,6 +81,7 @@ export interface BookingPeriodControllerValue {
|
|
|
81
81
|
isHydrated: boolean;
|
|
82
82
|
openDatePickerOnFocus: boolean;
|
|
83
83
|
withMobileDateDrawer: boolean;
|
|
84
|
+
selectionFlow: BookingPeriodSelectionFlow;
|
|
84
85
|
isStartDatePopoverOpen: boolean;
|
|
85
86
|
setIsStartDatePopoverOpen: (open: boolean) => void;
|
|
86
87
|
isStartTimeSelectOpen: boolean;
|