@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.
- package/dist/components/BookingPeriodSelector/components/BookingEndDateField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +89 -90
- 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 +236 -224
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BookingEndDateField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingEndDateField.tsx"],"names":[],"mappings":"AAqJA,eAAO,MAAM,mBAAmB,+
|
|
1
|
+
{"version":3,"file":"BookingEndDateField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingEndDateField.tsx"],"names":[],"mappings":"AAqJA,eAAO,MAAM,mBAAmB,+CAkiB/B,CAAA"}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { differenceInCalendarDays as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { cn as k, DayPickerField as
|
|
5
|
-
import { useMorphingModalWizardOverlayLayer as
|
|
6
|
-
import { DayPicker as
|
|
7
|
-
import { Label as
|
|
8
|
-
import { Provider as
|
|
9
|
-
import { useBookingPeriod as
|
|
10
|
-
import { BookingPeriodFieldErrorMessage as
|
|
11
|
-
import { ModalDayPickerField as
|
|
12
|
-
const
|
|
1
|
+
import { jsxs as ne, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { differenceInCalendarDays as me } from "date-fns";
|
|
3
|
+
import { createContext as pe, useRef as F, useState as X, useEffect as v, useContext as ye } from "react";
|
|
4
|
+
import { cn as k, DayPickerField as De } from "@rpcbase/ui";
|
|
5
|
+
import { useMorphingModalWizardOverlayLayer as Ee } from "../../../chunks/ui/dist/MorphingModalWizard-D7hc-dDP.js";
|
|
6
|
+
import { DayPicker as he } from "../../../ui/day-picker.js";
|
|
7
|
+
import { Label as ve } from "../../../ui/label.js";
|
|
8
|
+
import { Provider as be, Root as ge, TooltipTrigger as Me, Content as ke } from "../../../ui/tooltip.js";
|
|
9
|
+
import { useBookingPeriod as Te } from "../BookingPeriodContext.js";
|
|
10
|
+
import { BookingPeriodFieldErrorMessage as Pe } from "./BookingPeriodFieldErrorMessage.js";
|
|
11
|
+
import { ModalDayPickerField as we } from "./internal/ModalDayPickerField.js";
|
|
12
|
+
const Z = (t) => String(t).padStart(2, "0"), $ = (t) => `${t.getFullYear()}-${Z(t.getMonth() + 1)}-${Z(t.getDate())}`, z = (t) => t.getFullYear() * 12 + t.getMonth(), oe = (t) => new Date(Math.floor(t / 12), t % 12, 1), N = (t) => oe(z(t)), ee = (t, i, r) => {
|
|
13
13
|
const c = z(t), d = z(i), f = Math.max(0, r - 1), b = c + f;
|
|
14
14
|
if (d < c)
|
|
15
|
-
return
|
|
15
|
+
return N(i);
|
|
16
16
|
if (d > b) {
|
|
17
17
|
const m = d - f;
|
|
18
|
-
return m === c ? t :
|
|
18
|
+
return m === c ? t : oe(m);
|
|
19
19
|
}
|
|
20
20
|
return t;
|
|
21
|
-
},
|
|
21
|
+
}, Ce = (t) => {
|
|
22
22
|
if (typeof PointerEvent == "function") {
|
|
23
23
|
t.dispatchEvent(new PointerEvent("pointermove", { bubbles: !0, pointerType: "mouse" }));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
t.dispatchEvent(new MouseEvent("mousemove", { bubbles: !0 }));
|
|
27
|
-
},
|
|
27
|
+
}, te = (t) => {
|
|
28
28
|
if (typeof PointerEvent == "function") {
|
|
29
29
|
t.dispatchEvent(new PointerEvent("pointerout", { bubbles: !0, pointerType: "mouse" })), t.dispatchEvent(new PointerEvent("pointerleave", { bubbles: !0, pointerType: "mouse" }));
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
t.dispatchEvent(new MouseEvent("mouseout", { bubbles: !0 })), t.dispatchEvent(new MouseEvent("mouseleave", { bubbles: !0 }));
|
|
33
|
-
},
|
|
34
|
-
const i =
|
|
35
|
-
|
|
33
|
+
}, re = pe(null), ae = (t) => {
|
|
34
|
+
const i = ye(re), { day: r, modifiers: c, className: d, ...f } = t, b = c.disabled ? "cursor-not-allowed" : "cursor-pointer", m = F(null);
|
|
35
|
+
v(() => {
|
|
36
36
|
c.focused && m.current?.focus();
|
|
37
37
|
}, [c.focused]);
|
|
38
38
|
const p = /* @__PURE__ */ s(
|
|
@@ -48,14 +48,14 @@ const X = (t) => String(t).padStart(2, "0"), $ = (t) => `${t.getFullYear()}-${X(
|
|
|
48
48
|
const { labels: y, startDate: L, hoveredEndDate: T, keyboardTooltipDay: P, numberOfMonths: g, overlayLayer: M } = i;
|
|
49
49
|
if (!L || c.disabled || g === 1)
|
|
50
50
|
return p;
|
|
51
|
-
const l =
|
|
51
|
+
const l = me(r.date, L);
|
|
52
52
|
if (l < 0)
|
|
53
53
|
return p;
|
|
54
54
|
const B = $(r.date), I = P === B || (!P && T ? $(T) === B : !1), O = y.selectedDaysTooltip?.({ count: l + 1 });
|
|
55
|
-
return O ? /* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */ s(
|
|
55
|
+
return O ? /* @__PURE__ */ ne(ge, { open: I, children: [
|
|
56
|
+
/* @__PURE__ */ s(Me, { asChild: !0, children: p }),
|
|
57
57
|
/* @__PURE__ */ s(
|
|
58
|
-
|
|
58
|
+
ke,
|
|
59
59
|
{
|
|
60
60
|
container: M ?? void 0,
|
|
61
61
|
side: "top",
|
|
@@ -71,8 +71,8 @@ const X = (t) => String(t).padStart(2, "0"), $ = (t) => `${t.getFullYear()}-${X(
|
|
|
71
71
|
)
|
|
72
72
|
] }) : p;
|
|
73
73
|
};
|
|
74
|
-
|
|
75
|
-
const
|
|
74
|
+
ae.displayName = "BookingEndDateDayButton";
|
|
75
|
+
const qe = () => {
|
|
76
76
|
const {
|
|
77
77
|
labels: t,
|
|
78
78
|
startDate: i,
|
|
@@ -93,36 +93,35 @@ const Re = () => {
|
|
|
93
93
|
isMobile: B,
|
|
94
94
|
isHydrated: I,
|
|
95
95
|
openDatePickerOnFocus: O,
|
|
96
|
-
withMobileDateDrawer:
|
|
96
|
+
withMobileDateDrawer: ie,
|
|
97
|
+
selectionFlow: x,
|
|
97
98
|
minSelectableDate: U
|
|
98
|
-
} =
|
|
99
|
-
() =>
|
|
100
|
-
),
|
|
101
|
-
|
|
102
|
-
de(!0);
|
|
103
|
-
}, []), h(() => {
|
|
99
|
+
} = Te(), D = ie && B, E = F(null), h = F(!1), [V, A] = X(null), [j, K] = X(
|
|
100
|
+
() => N(i ?? r ?? /* @__PURE__ */ new Date())
|
|
101
|
+
), S = Ee(), de = !!S;
|
|
102
|
+
v(() => {
|
|
104
103
|
if (typeof document > "u")
|
|
105
104
|
return;
|
|
106
105
|
const e = document.getElementById("end-date-picker");
|
|
107
106
|
if (!(e instanceof HTMLInputElement))
|
|
108
107
|
return;
|
|
109
108
|
const n = (o) => {
|
|
110
|
-
|
|
109
|
+
h.current = o.key === "ArrowUp" || o.key === "ArrowDown";
|
|
111
110
|
};
|
|
112
111
|
return e.addEventListener("keydown", n, !0), () => {
|
|
113
112
|
e.removeEventListener("keydown", n, !0);
|
|
114
113
|
};
|
|
115
|
-
}, []),
|
|
114
|
+
}, []), v(() => {
|
|
116
115
|
if (!d || D)
|
|
117
116
|
return;
|
|
118
|
-
const e =
|
|
119
|
-
|
|
120
|
-
}, [r, d, l, i]),
|
|
117
|
+
const e = N(i ?? r ?? /* @__PURE__ */ new Date()), n = r ?? i;
|
|
118
|
+
K(n ? ee(e, n, l) : e);
|
|
119
|
+
}, [r, d, l, i]), v(() => {
|
|
121
120
|
if (!d)
|
|
122
121
|
return;
|
|
123
122
|
const e = m ?? r;
|
|
124
|
-
e &&
|
|
125
|
-
}, [r, m, d, l]),
|
|
123
|
+
e && K((n) => ee(n, e, l));
|
|
124
|
+
}, [r, m, d, l]), v(() => {
|
|
126
125
|
if (!d || typeof document > "u" || (y(), D))
|
|
127
126
|
return;
|
|
128
127
|
const e = document.getElementById("end-date-picker");
|
|
@@ -131,13 +130,13 @@ const Re = () => {
|
|
|
131
130
|
return;
|
|
132
131
|
}
|
|
133
132
|
document.activeElement !== e && requestAnimationFrame(() => {
|
|
134
|
-
e.focus({ preventScroll: !0 }), e.click();
|
|
133
|
+
e.focus({ preventScroll: !0 }), x === "chained-times" && e.click();
|
|
135
134
|
});
|
|
136
|
-
}, [d, y, f]),
|
|
135
|
+
}, [d, y, x, f]), v(() => {
|
|
137
136
|
if (typeof document > "u")
|
|
138
137
|
return;
|
|
139
138
|
const e = document.getElementById("end-date-picker");
|
|
140
|
-
if (!(e instanceof HTMLInputElement))
|
|
139
|
+
if (!(e instanceof HTMLInputElement) || x !== "chained-times")
|
|
141
140
|
return;
|
|
142
141
|
const n = () => {
|
|
143
142
|
b(!1);
|
|
@@ -145,14 +144,14 @@ const Re = () => {
|
|
|
145
144
|
return e.addEventListener("focus", n, !0), () => {
|
|
146
145
|
e.removeEventListener("focus", n, !0);
|
|
147
146
|
};
|
|
148
|
-
}, [b]),
|
|
147
|
+
}, [x, b]), v(() => {
|
|
149
148
|
if (d || typeof document > "u")
|
|
150
149
|
return;
|
|
151
150
|
const e = E.current;
|
|
152
151
|
if (!e)
|
|
153
152
|
return;
|
|
154
153
|
const o = document.getElementById("end-date-calendar")?.querySelector(`[data-day="${e}"] button`);
|
|
155
|
-
o instanceof HTMLElement &&
|
|
154
|
+
o instanceof HTMLElement && te(o), E.current = null, A(null);
|
|
156
155
|
}, [d]);
|
|
157
156
|
const W = F({
|
|
158
157
|
labels: t,
|
|
@@ -161,7 +160,7 @@ const Re = () => {
|
|
|
161
160
|
hoveredEndDate: m,
|
|
162
161
|
keyboardTooltipDay: V,
|
|
163
162
|
numberOfMonths: l,
|
|
164
|
-
overlayLayer:
|
|
163
|
+
overlayLayer: S,
|
|
165
164
|
calendarMonth: j,
|
|
166
165
|
resetHoveredEndDate: y,
|
|
167
166
|
setHoveredEndDate: p
|
|
@@ -173,41 +172,41 @@ const Re = () => {
|
|
|
173
172
|
hoveredEndDate: m,
|
|
174
173
|
keyboardTooltipDay: V,
|
|
175
174
|
numberOfMonths: l,
|
|
176
|
-
overlayLayer:
|
|
175
|
+
overlayLayer: S,
|
|
177
176
|
calendarMonth: j,
|
|
178
177
|
resetHoveredEndDate: y,
|
|
179
178
|
setHoveredEndDate: p
|
|
180
179
|
};
|
|
181
|
-
const
|
|
182
|
-
if (!
|
|
180
|
+
const q = F(null);
|
|
181
|
+
if (!q.current) {
|
|
183
182
|
const e = (n) => {
|
|
184
183
|
const {
|
|
185
184
|
labels: o,
|
|
186
185
|
startDate: a,
|
|
187
186
|
endDate: u,
|
|
188
187
|
hoveredEndDate: w,
|
|
189
|
-
keyboardTooltipDay:
|
|
188
|
+
keyboardTooltipDay: H,
|
|
190
189
|
numberOfMonths: Q,
|
|
191
|
-
overlayLayer:
|
|
192
|
-
calendarMonth:
|
|
193
|
-
resetHoveredEndDate:
|
|
194
|
-
setHoveredEndDate:
|
|
195
|
-
} = W.current,
|
|
190
|
+
overlayLayer: se,
|
|
191
|
+
calendarMonth: ce,
|
|
192
|
+
resetHoveredEndDate: le,
|
|
193
|
+
setHoveredEndDate: ue
|
|
194
|
+
} = W.current, fe = {
|
|
196
195
|
labels: o,
|
|
197
196
|
startDate: a,
|
|
198
197
|
hoveredEndDate: w,
|
|
199
|
-
keyboardTooltipDay:
|
|
198
|
+
keyboardTooltipDay: H,
|
|
200
199
|
numberOfMonths: Q,
|
|
201
|
-
overlayLayer:
|
|
200
|
+
overlayLayer: se
|
|
202
201
|
};
|
|
203
|
-
return /* @__PURE__ */ s(
|
|
204
|
-
|
|
202
|
+
return /* @__PURE__ */ s(re.Provider, { value: fe, children: /* @__PURE__ */ s(be, { delayDuration: 0, children: /* @__PURE__ */ s("div", { onMouseLeave: le, children: /* @__PURE__ */ s(
|
|
203
|
+
he,
|
|
205
204
|
{
|
|
206
205
|
...n,
|
|
207
206
|
mode: "range",
|
|
208
|
-
month:
|
|
207
|
+
month: ce,
|
|
209
208
|
onMonthChange: (C) => {
|
|
210
|
-
|
|
209
|
+
K(N(C));
|
|
211
210
|
},
|
|
212
211
|
selected: {
|
|
213
212
|
from: a,
|
|
@@ -215,20 +214,20 @@ const Re = () => {
|
|
|
215
214
|
},
|
|
216
215
|
components: {
|
|
217
216
|
...n.components,
|
|
218
|
-
DayButton:
|
|
217
|
+
DayButton: ae
|
|
219
218
|
},
|
|
220
|
-
onSelect: (C,
|
|
221
|
-
n.onSelect?.(
|
|
219
|
+
onSelect: (C, Y) => {
|
|
220
|
+
n.onSelect?.(Y);
|
|
222
221
|
},
|
|
223
|
-
onDayMouseEnter: (C,
|
|
224
|
-
Q !== 1 && a && !
|
|
222
|
+
onDayMouseEnter: (C, Y) => {
|
|
223
|
+
Q !== 1 && a && !Y.disabled && C >= a && ue(C);
|
|
225
224
|
}
|
|
226
225
|
}
|
|
227
226
|
) }) }) });
|
|
228
227
|
};
|
|
229
|
-
e.displayName = "BookingEndDateDayPicker",
|
|
228
|
+
e.displayName = "BookingEndDateDayPicker", q.current = e;
|
|
230
229
|
}
|
|
231
|
-
const _ =
|
|
230
|
+
const _ = q.current, R = () => {
|
|
232
231
|
if (typeof document > "u") {
|
|
233
232
|
E.current = null;
|
|
234
233
|
return;
|
|
@@ -237,14 +236,14 @@ const Re = () => {
|
|
|
237
236
|
if (!e)
|
|
238
237
|
return;
|
|
239
238
|
const o = document.getElementById("end-date-calendar")?.querySelector(`[data-day="${e}"] button`);
|
|
240
|
-
o instanceof HTMLElement &&
|
|
239
|
+
o instanceof HTMLElement && te(o), E.current = null, A(null);
|
|
241
240
|
}, G = (e) => {
|
|
242
241
|
if (typeof document > "u")
|
|
243
242
|
return;
|
|
244
243
|
const n = $(e);
|
|
245
244
|
if (E.current === n)
|
|
246
245
|
return;
|
|
247
|
-
|
|
246
|
+
R(), E.current = n, A(n);
|
|
248
247
|
let o = 0;
|
|
249
248
|
const a = 6, u = () => {
|
|
250
249
|
if (E.current !== n)
|
|
@@ -254,9 +253,9 @@ const Re = () => {
|
|
|
254
253
|
o += 1, o <= a && requestAnimationFrame(u);
|
|
255
254
|
return;
|
|
256
255
|
}
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
|
|
256
|
+
const H = w.querySelector(`[data-day="${n}"] button:not([disabled])`);
|
|
257
|
+
if (H instanceof HTMLElement) {
|
|
258
|
+
Ce(H);
|
|
260
259
|
return;
|
|
261
260
|
}
|
|
262
261
|
o += 1, o <= a && requestAnimationFrame(u);
|
|
@@ -265,7 +264,7 @@ const Re = () => {
|
|
|
265
264
|
}, J = () => {
|
|
266
265
|
D && f(!0);
|
|
267
266
|
};
|
|
268
|
-
return /* @__PURE__ */
|
|
267
|
+
return /* @__PURE__ */ ne(
|
|
269
268
|
"div",
|
|
270
269
|
{
|
|
271
270
|
className: k("group/form-item relative flex-grow", D && "cursor-pointer rounded-md"),
|
|
@@ -273,15 +272,15 @@ const Re = () => {
|
|
|
273
272
|
onClick: J,
|
|
274
273
|
children: [
|
|
275
274
|
/* @__PURE__ */ s(
|
|
276
|
-
|
|
275
|
+
ve,
|
|
277
276
|
{
|
|
278
277
|
htmlFor: "end-date-picker",
|
|
279
278
|
className: k("mb-1 block text-sm font-medium", D && "cursor-pointer", L),
|
|
280
279
|
children: /* @__PURE__ */ s("span", { children: t.endDate })
|
|
281
280
|
}
|
|
282
281
|
),
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
de ? /* @__PURE__ */ s(
|
|
283
|
+
we,
|
|
285
284
|
{
|
|
286
285
|
id: "end-date-picker",
|
|
287
286
|
value: r ?? null,
|
|
@@ -300,7 +299,7 @@ const Re = () => {
|
|
|
300
299
|
return o instanceof HTMLElement && o.id === "end-date-picker";
|
|
301
300
|
})();
|
|
302
301
|
if (!i || !e || e < i) {
|
|
303
|
-
y(), n &&
|
|
302
|
+
y(), n && R();
|
|
304
303
|
return;
|
|
305
304
|
}
|
|
306
305
|
p(e), n && G(e);
|
|
@@ -308,9 +307,9 @@ const Re = () => {
|
|
|
308
307
|
onChange: (e) => {
|
|
309
308
|
if (y(), (() => {
|
|
310
309
|
if (typeof document > "u")
|
|
311
|
-
return
|
|
312
|
-
const a = document.activeElement, u =
|
|
313
|
-
return
|
|
310
|
+
return h.current = !1, !1;
|
|
311
|
+
const a = document.activeElement, u = h.current && a instanceof HTMLElement && a.id === "end-date-picker";
|
|
312
|
+
return h.current = !1, u;
|
|
314
313
|
})() || e && r && e.getFullYear() === r.getFullYear() && e.getMonth() === r.getMonth() && e.getDate() === r.getDate())
|
|
315
314
|
return;
|
|
316
315
|
const o = (() => {
|
|
@@ -319,7 +318,7 @@ const Re = () => {
|
|
|
319
318
|
const a = document.activeElement;
|
|
320
319
|
return a instanceof HTMLElement ? !!(document.getElementById("end-date-calendar")?.contains(a) || a.id === "end-date-picker") : !1;
|
|
321
320
|
})();
|
|
322
|
-
c(e ?? void 0, { openTimePicker: o });
|
|
321
|
+
c(e ?? void 0, { openTimePicker: o ? void 0 : !1 });
|
|
323
322
|
},
|
|
324
323
|
inputClassName: k(g.endDate && "border-destructive", T, P),
|
|
325
324
|
dayPickerComponent: _,
|
|
@@ -332,10 +331,10 @@ const Re = () => {
|
|
|
332
331
|
initialFocus: !0,
|
|
333
332
|
"data-testid": "end-date-calendar"
|
|
334
333
|
},
|
|
335
|
-
portalContainer:
|
|
334
|
+
portalContainer: S
|
|
336
335
|
}
|
|
337
336
|
) : /* @__PURE__ */ s(
|
|
338
|
-
|
|
337
|
+
De,
|
|
339
338
|
{
|
|
340
339
|
id: "end-date-picker",
|
|
341
340
|
value: r ?? null,
|
|
@@ -353,7 +352,7 @@ const Re = () => {
|
|
|
353
352
|
return o instanceof HTMLElement && o.id === "end-date-picker";
|
|
354
353
|
})();
|
|
355
354
|
if (!i || !e || e < i) {
|
|
356
|
-
y(), n &&
|
|
355
|
+
y(), n && R();
|
|
357
356
|
return;
|
|
358
357
|
}
|
|
359
358
|
p(e), n && G(e);
|
|
@@ -361,9 +360,9 @@ const Re = () => {
|
|
|
361
360
|
onChange: (e) => {
|
|
362
361
|
if (y(), (() => {
|
|
363
362
|
if (typeof document > "u")
|
|
364
|
-
return
|
|
365
|
-
const a = document.activeElement, u =
|
|
366
|
-
return
|
|
363
|
+
return h.current = !1, !1;
|
|
364
|
+
const a = document.activeElement, u = h.current && a instanceof HTMLElement && a.id === "end-date-picker";
|
|
365
|
+
return h.current = !1, u;
|
|
367
366
|
})() || e && r && e.getFullYear() === r.getFullYear() && e.getMonth() === r.getMonth() && e.getDate() === r.getDate())
|
|
368
367
|
return;
|
|
369
368
|
const o = (() => {
|
|
@@ -372,7 +371,7 @@ const Re = () => {
|
|
|
372
371
|
const a = document.activeElement;
|
|
373
372
|
return a instanceof HTMLElement ? !!(document.getElementById("end-date-calendar")?.contains(a) || a.id === "end-date-picker") : !1;
|
|
374
373
|
})();
|
|
375
|
-
c(e ?? void 0, { openTimePicker: o });
|
|
374
|
+
c(e ?? void 0, { openTimePicker: o ? void 0 : !1 });
|
|
376
375
|
},
|
|
377
376
|
inputClassName: k(g.endDate && "border-destructive", T, P),
|
|
378
377
|
dayPickerComponent: _,
|
|
@@ -387,11 +386,11 @@ const Re = () => {
|
|
|
387
386
|
}
|
|
388
387
|
}
|
|
389
388
|
),
|
|
390
|
-
g.endDate && /* @__PURE__ */ s(
|
|
389
|
+
g.endDate && /* @__PURE__ */ s(Pe, { children: g.endDate })
|
|
391
390
|
]
|
|
392
391
|
}
|
|
393
392
|
);
|
|
394
393
|
};
|
|
395
394
|
export {
|
|
396
|
-
|
|
395
|
+
qe as BookingEndDateField
|
|
397
396
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BookingEndTimeField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingEndTimeField.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,mBAAmB,+
|
|
1
|
+
{"version":3,"file":"BookingEndTimeField.d.ts","sourceRoot":"","sources":["../../../../src/components/BookingPeriodSelector/components/BookingEndTimeField.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,mBAAmB,+CA8J/B,CAAA"}
|
|
@@ -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"}
|