@loczer/storefront-sdk 0.193.0 → 0.195.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 (82) hide show
  1. package/dist/chunks/pkg/booking-engine/dist/models/{Product.shared-cjcvMCMa.js → Product.shared-iVSHRdn4.js} +21 -21
  2. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-asset-CsOe0vXi.js → base-asset-BRQVuIes.js} +1 -1
  3. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-booking-Sjsqh31e.js → base-booking-Bhy2Kww1.js} +2 -2
  4. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-product-C_ATjuc6.js → base-product-BJHQLX8t.js} +1 -1
  5. package/dist/chunks/pkg/booking-engine/dist/schemas/{insurance-B01h642r.js → insurance-CPeHsTss.js} +1 -1
  6. package/dist/chunks/pkg/booking-engine/dist/schemas-BfXM1Dgb.js +14 -0
  7. package/dist/chunks/pkg/ui/dist/{Button-CxG2fSpA.js → Button-Cr_u8vnh.js} +1 -1
  8. package/dist/chunks/pkg/ui/dist/{Dialog-4leTWiev.js → Dialog-CczmPDwY.js} +1 -1
  9. package/dist/chunks/pkg/ui/dist/Drawer/{index-DA5V7R_q.js → index-CSvSVP_J.js} +1 -1
  10. package/dist/chunks/pkg/ui/dist/Map/{MapContent-BmKjdWmq.js → MapContent-CDeWtwKa.js} +1 -1
  11. package/dist/chunks/pkg/ui/dist/{Map-CsOTdTtL.js → Map-Cs7wgtH9.js} +2 -2
  12. package/dist/chunks/pkg/ui/dist/{MorphingModalWizard-CfEqkJ0y.js → MorphingModalWizard-j1CgFGLe.js} +4 -3
  13. package/dist/chunks/pkg/ui/dist/{ResponsiveDialog-C6IWYoIg.js → ResponsiveDialog-BVwhTZQo.js} +3 -3
  14. package/dist/chunks/pkg/ui/dist/{ScrollArea-Bjwo84cv.js → ScrollArea-BqLd0xZj.js} +1 -1
  15. package/dist/chunks/pkg/ui/dist/Spinner/{index-DzMEU0iA.js → index-Cgi70z_E.js} +1 -1
  16. package/dist/chunks/pkg/ui/dist/lib/utils-DXB19bzk.js +8 -0
  17. package/dist/components/BikeProductCard/index.js +6 -6
  18. package/dist/components/BookingBikeVariantDialog/index.js +7 -7
  19. package/dist/components/BookingFlowSteps/index.js +11 -11
  20. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +1 -1
  21. package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.d.ts.map +1 -1
  22. package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +36 -54
  23. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +1 -1
  24. package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.d.ts.map +1 -1
  25. package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +36 -54
  26. package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.js +1 -1
  27. package/dist/components/BookingPeriodSelector/components/internal/BookingHourPickerField.d.ts +7 -0
  28. package/dist/components/BookingPeriodSelector/components/internal/BookingHourPickerField.d.ts.map +1 -0
  29. package/dist/components/BookingPeriodSelector/components/internal/BookingHourPickerField.js +27 -0
  30. package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.d.ts +36 -0
  31. package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.d.ts.map +1 -0
  32. package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.js +830 -0
  33. package/dist/components/BookingPeriodSelector/components/internal/useIsTouchDevice.d.ts +2 -0
  34. package/dist/components/BookingPeriodSelector/components/internal/useIsTouchDevice.d.ts.map +1 -0
  35. package/dist/components/BookingPeriodSelector/components/internal/useIsTouchDevice.js +21 -0
  36. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts +4 -1
  37. package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
  38. package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +114 -110
  39. package/dist/components/ContactSection/index.js +35 -35
  40. package/dist/components/ContractSaleDocument/DocumentAcceptanceSection.js +4 -4
  41. package/dist/components/ContractSaleDocument/ThumbnailSidebar.js +1 -1
  42. package/dist/components/DeliveryAddressSelector/index.js +5 -5
  43. package/dist/components/Footer/index.js +11 -11
  44. package/dist/components/FulfillmentSection/index.js +9 -9
  45. package/dist/components/Header/index.js +61 -61
  46. package/dist/components/Map/index.js +1 -1
  47. package/dist/components/PoweredByLoczerBadge/index.js +5 -5
  48. package/dist/components/ProductPriceBadge/index.js +73 -73
  49. package/dist/components/StorefrontCancellationPolicyNotice/index.js +6 -6
  50. package/dist/components/StorefrontCartPanel/index.js +8 -8
  51. package/dist/components/StorefrontInsuranceNotice/index.js +6 -6
  52. package/dist/components/StorefrontPopupMessages/index.js +8 -8
  53. package/dist/components/payment/MollieCardFieldsForm.js +1 -1
  54. package/dist/components/payment/StripeCardFieldsForm.js +1 -1
  55. package/dist/index.d.ts +15 -3
  56. package/dist/index.js +70 -70
  57. package/dist/lib/booking.js +1 -1
  58. package/dist/lib/checkoutSubmit.js +2 -2
  59. package/dist/lib/utils.d.ts +3 -1
  60. package/dist/lib/utils.d.ts.map +1 -1
  61. package/dist/lib/utils.js +9 -5
  62. package/dist/pages/BookingPage.d.ts.map +1 -1
  63. package/dist/pages/BookingPage.js +187 -159
  64. package/dist/pages/CheckoutPaymentPage.js +1 -1
  65. package/dist/pages/ContractSaleDocumentPage.js +15 -15
  66. package/dist/pages/HomePage.d.ts.map +1 -1
  67. package/dist/pages/HomePage.js +263 -257
  68. package/dist/pages/PaymentLinkPage.js +1 -1
  69. package/dist/pages/PaymentLinkSuccessPage.js +1 -1
  70. package/dist/pages/ProductPage.js +143 -143
  71. package/dist/pages/checkout/components/CheckoutCouponCard.js +5 -5
  72. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.js +1 -1
  73. package/dist/storefront.css +1 -1
  74. package/dist/storefrontSchemas.js +1 -1
  75. package/package.json +5 -1
  76. package/dist/chunks/node_modules/clsx/dist/clsx-CdyIqUTr.js +0 -16
  77. package/dist/chunks/node_modules/tailwind-merge/dist/bundle-mjs-CF4QheV5.js +0 -1608
  78. package/dist/chunks/pkg/booking-engine/dist/schemas-D_yUBLa0.js +0 -14
  79. package/dist/chunks/pkg/ui/dist/lib/utils-BN5KOMSm.js +0 -8
  80. package/dist/components/BookingPeriodSelector/components/internal/ModalHourPickerField.d.ts +0 -22
  81. package/dist/components/BookingPeriodSelector/components/internal/ModalHourPickerField.d.ts.map +0 -1
  82. package/dist/components/BookingPeriodSelector/components/internal/ModalHourPickerField.js +0 -333
@@ -1,14 +0,0 @@
1
- import { createLocalizedStringEntry as e, getLocalizedStringValue as t, localizedStringArraySchema as n, localizedStringEntrySchema as r, localizedStringSchema as i } from "./models/LocalizedString-D_TRgAdr.js";
2
- import { currencyCodeSchema as a, currencyMinorUnitDigits as o, majorToMinor as s, minorToMajor as c, moneyMinorSchema as l, signedMoneyMinorSchema as u } from "./schemas/money-CVoCY4of.js";
3
- import { priceSchema as d, priceUnitSchema as f } from "./models/Price-DCAgqkKh.js";
4
- import { PRODUCT_VARIANT_CODE_IDENTIFIER_KIND as p, PRODUCT_VARIANT_CODE_MAX_LENGTH as m, accessoryProductSchema as h, bikeProductSchema as g, eBikeProductSchema as _, isProductVariantCodeIdentifierKind as v, productInsuranceSchema as y, productKindSchema as b, productSchema as x, productStorefrontDisplayModeSchema as S, productVariantAttributeSchema as C, productVariantCodeSchema as w, productVariantIdentifierSchema as T, productVariantSchema as E } from "./models/Product.shared-cjcvMCMa.js";
5
- import { richTextJsonDocSchema as D, richTextSchema as O, richTextVersionSchema as k } from "./schemas/rich-text-DTRh7U3z.js";
6
- import { isoDateSchema as A, shopConfigurationSchema as j, shopExtraTimeSlotRuleSchema as M, shopOpeningDayIndexSchema as N, shopOpeningDaySchema as P, shopOpeningHoursOverrideSchema as F, shopOpeningHoursPeriodSchema as I, shopOpeningSlotSchema as L, timeOfDaySchema as R } from "./schemas/shop-opening-hours-BlLD1gfz.js";
7
- import { DEFAULT_CANCELLATION_POLICY as z, DEFAULT_PAYMENT_POLICIES as B, cancellationPolicySchema as V, cancellationPolicyTierSchema as H, paymentPoliciesSchema as U } from "./schemas/booking-engine-configuration-LnrhShqm.js";
8
- import { fulfillmentModeSchema as W, publicBookingEngineConfigurationSchema as G, publicCheckoutConfigurationSchema as K, publicCheckoutDynamicOptionsSchema as q } from "./schemas/public-booking-engine-configuration-CEM9mexX.js";
9
- import { DEFAULT_BOOKING_DELIVERY_OPTION as J, bookingCustomerInputSchema as Y, bookingDeliveryOptionSchema as X, bookingScheduleInputSchema as Z, cartItemInputSchema as Q, createBookingInputBaseSchema as $, createBookingInputSchema as ee, resolveBookingDeliveryOption as te, validateBookingDeliveryAddress as ne } from "./schemas/cart-inputs-D1_Wmkca.js";
10
- import { bookingInsuranceConsentSourceSchema as re, bookingInsuranceItemSnapshotSchema as ie, bookingInsuranceSnapshotSchema as ae, buildBookingInsuranceSnapshot as oe, calculateInsuranceCalendarDays as se, insuranceProviderSchema as ce } from "./schemas/insurance-B01h642r.js";
11
- import "./schemas/base-product-C_ATjuc6.js";
12
- import { baseAssetSchema as le, baseAssetStatusSchema as ue } from "./schemas/base-asset-CsOe0vXi.js";
13
- import { baseBookingItemSchema as de, baseBookingSchema as fe, baseBookingStateSchema as pe } from "./schemas/base-booking-Sjsqh31e.js";
14
- export { J as DEFAULT_BOOKING_DELIVERY_OPTION, z as DEFAULT_CANCELLATION_POLICY, B as DEFAULT_PAYMENT_POLICIES, p as PRODUCT_VARIANT_CODE_IDENTIFIER_KIND, m as PRODUCT_VARIANT_CODE_MAX_LENGTH, h as accessoryProductSchema, le as baseAssetSchema, ue as baseAssetStatusSchema, de as baseBookingItemSchema, fe as baseBookingSchema, pe as baseBookingStateSchema, g as bikeProductSchema, Y as bookingCustomerInputSchema, X as bookingDeliveryOptionSchema, re as bookingInsuranceConsentSourceSchema, ie as bookingInsuranceItemSnapshotSchema, ae as bookingInsuranceSnapshotSchema, Z as bookingScheduleInputSchema, oe as buildBookingInsuranceSnapshot, se as calculateInsuranceCalendarDays, V as cancellationPolicySchema, H as cancellationPolicyTierSchema, Q as cartItemInputSchema, $ as createBookingInputBaseSchema, ee as createBookingInputSchema, e as createLocalizedStringEntry, a as currencyCodeSchema, o as currencyMinorUnitDigits, _ as eBikeProductSchema, W as fulfillmentModeSchema, t as getLocalizedStringValue, ce as insuranceProviderSchema, v as isProductVariantCodeIdentifierKind, A as isoDateSchema, n as localizedStringArraySchema, r as localizedStringEntrySchema, i as localizedStringSchema, s as majorToMinor, c as minorToMajor, l as moneyMinorSchema, U as paymentPoliciesSchema, d as priceSchema, f as priceUnitSchema, y as productInsuranceSchema, b as productKindSchema, x as productSchema, S as productStorefrontDisplayModeSchema, C as productVariantAttributeSchema, w as productVariantCodeSchema, T as productVariantIdentifierSchema, E as productVariantSchema, G as publicBookingEngineConfigurationSchema, K as publicCheckoutConfigurationSchema, q as publicCheckoutDynamicOptionsSchema, te as resolveBookingDeliveryOption, D as richTextJsonDocSchema, O as richTextSchema, k as richTextVersionSchema, j as shopConfigurationSchema, M as shopExtraTimeSlotRuleSchema, N as shopOpeningDayIndexSchema, P as shopOpeningDaySchema, F as shopOpeningHoursOverrideSchema, I as shopOpeningHoursPeriodSchema, L as shopOpeningSlotSchema, u as signedMoneyMinorSchema, R as timeOfDaySchema, ne as validateBookingDeliveryAddress };
@@ -1,8 +0,0 @@
1
- import { clsx as e } from "../../../../node_modules/clsx/dist/clsx-CdyIqUTr.js";
2
- import { twMerge as t } from "../../../../node_modules/tailwind-merge/dist/bundle-mjs-CF4QheV5.js";
3
- //#region ../ui/dist/lib/utils.js
4
- function n(...n) {
5
- return t(e(n));
6
- }
7
- //#endregion
8
- export { n as cn };
@@ -1,22 +0,0 @@
1
- import { HourPickerOption } from '@rpcbase/ui';
2
- type ModalHourPickerFieldProps = {
3
- id?: string;
4
- value: string | null;
5
- onChange: (value: string | null) => void;
6
- onValueUpdate?: (value: string | null) => void;
7
- options: HourPickerOption[];
8
- placeholder?: string;
9
- className?: string;
10
- inputClassName?: string;
11
- disabled?: boolean;
12
- readOnly?: boolean;
13
- open?: boolean;
14
- onOpenChange?: (open: boolean) => void;
15
- triggerTestId?: string;
16
- contentTestId?: string;
17
- isHydrated?: boolean;
18
- portalContainer: HTMLElement | null;
19
- };
20
- export declare function ModalHourPickerField({ id, value, onChange, onValueUpdate, options, placeholder, className, inputClassName, disabled, readOnly, open: openProp, onOpenChange, triggerTestId, contentTestId, isHydrated, portalContainer, }: ModalHourPickerFieldProps): import("react/jsx-runtime").JSX.Element;
21
- export {};
22
- //# sourceMappingURL=ModalHourPickerField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModalHourPickerField.d.ts","sourceRoot":"","sources":["../../../../../src/components/BookingPeriodSelector/components/internal/ModalHourPickerField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAM,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGvD,KAAK,yBAAyB,GAAG;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC9C,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,eAAe,EAAE,WAAW,GAAG,IAAI,CAAA;CACpC,CAAA;AAmKD,wBAAgB,oBAAoB,CAAC,EACnC,EAAE,EACF,KAAK,EACL,QAAQ,EACR,aAAa,EACb,OAAO,EACP,WAA2B,EAC3B,SAAS,EACT,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,IAAI,EAAE,QAAQ,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,eAAe,GAChB,EAAE,yBAAyB,2CA6c3B"}
@@ -1,333 +0,0 @@
1
- import { useEffect as e, useLayoutEffect as t, useRef as n, useState as r } from "react";
2
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
3
- import { cn as o } from "@rpcbase/ui";
4
- import { Check as s, ChevronDown as c } from "lucide-react";
5
- import { createPortal as l } from "react-dom";
6
- //#region src/components/BookingPeriodSelector/components/internal/ModalHourPickerField.tsx
7
- function u(e) {
8
- return e != null && !e.disabled;
9
- }
10
- function d(e) {
11
- let t = /^(\d{1,2}):(\d{2})$/.exec(e.trim());
12
- if (!t) return null;
13
- let n = Number(t[1]), r = Number(t[2]);
14
- return !Number.isFinite(n) || !Number.isFinite(r) || n < 0 || n > 23 || r < 0 || r > 59 ? null : n * 60 + r;
15
- }
16
- function f(e) {
17
- let t = /^(\d{1,2}):(\d{2})$/.exec(e.trim());
18
- if (!t) return null;
19
- let n = Number(t[1]), r = Number(t[2]);
20
- return !Number.isFinite(n) || !Number.isFinite(r) || n < 0 || n > 23 || r < 0 || r > 59 ? null : `${String(n).padStart(2, "0")}:${String(r).padStart(2, "0")}`;
21
- }
22
- function p(e) {
23
- let t = e.replace(/\D/g, "").slice(0, 4);
24
- return t.length <= 2 ? t : `${t.slice(0, t.length - 2)}:${t.slice(-2)}`;
25
- }
26
- function m(e, t) {
27
- if (!e) return null;
28
- let n = f(e);
29
- return n && u(t.find((e) => e.value === n)) ? n : null;
30
- }
31
- function h(e) {
32
- return e.find((e) => u(e)) ?? null;
33
- }
34
- function g(e, t) {
35
- let n = d(e);
36
- if (n == null) return null;
37
- let r = null, i = Infinity, a = -Infinity;
38
- for (let e of t) {
39
- if (!u(e)) continue;
40
- let t = d(e.value);
41
- if (t == null) continue;
42
- let o = Math.abs(t - n);
43
- (o < i || o === i && t > a) && (r = e, i = o, a = t);
44
- }
45
- return r;
46
- }
47
- function _(e, t, n) {
48
- let r = e ? n.findIndex((t) => t.value === e) : -1;
49
- r === -1 && (r = t === 1 ? -1 : n.length);
50
- for (let e = r + t; e >= 0 && e < n.length; e += t) {
51
- let t = n[e];
52
- if (u(t)) return t.value;
53
- }
54
- return null;
55
- }
56
- function v(e, t, n) {
57
- let r = e.getBoundingClientRect(), i = t.offsetHeight, a = n.getBoundingClientRect(), o = window.innerWidth, s = window.innerHeight, c = r.width, l = r.left;
58
- l + c > o - 8 && (l = Math.max(8, o - c - 8)), l < 8 && (l = 8);
59
- let u = r.bottom + 8, d = u + i > s - 8, f = r.top - i - 8;
60
- return d && f >= 8 && (u = f), u < 8 && (u = 8), u + i > s - 8 && (u = Math.max(8, s - i - 8)), {
61
- left: l - a.left,
62
- top: u - a.top,
63
- width: c,
64
- strategy: "absolute"
65
- };
66
- }
67
- function y({ id: u, value: d, onChange: y, onValueUpdate: b, options: x, placeholder: S = "Select time", className: C, inputClassName: w, disabled: T, readOnly: E, open: D, onOpenChange: O, triggerTestId: k, contentTestId: A, isHydrated: j, portalContainer: M }) {
68
- let N = n(null), P = n(null), F = n(null), I = n(null), [L, R] = r(!1), [z, B] = r(() => d ?? ""), [V, H] = r(d ?? h(x)?.value ?? null), [U, W] = r({
69
- left: 0,
70
- top: 0,
71
- width: 0,
72
- strategy: "absolute"
73
- }), G = n(!1), K = n(!1), q = D ?? L;
74
- e(() => {
75
- G.current || B(d ?? "");
76
- }, [d]), e(() => {
77
- if (!q) {
78
- H(d ?? h(x)?.value ?? null);
79
- return;
80
- }
81
- let e = m(d, x);
82
- H(e ?? h(x)?.value ?? null);
83
- }, [
84
- q,
85
- x,
86
- d
87
- ]), e(() => {
88
- if (!q || T || E) return;
89
- let e = P.current;
90
- e instanceof HTMLInputElement && document.activeElement !== e && e.focus({ preventScroll: !0 });
91
- }, [
92
- T,
93
- q,
94
- E
95
- ]), e(() => {
96
- if (!q) return;
97
- let e = (e) => {
98
- let t = e.target;
99
- t instanceof Node && (N.current?.contains(t) || F.current?.contains(t) || (O?.(!1), R(!1)));
100
- }, t = (e) => {
101
- if (e.key !== "Escape") return;
102
- let t = e.target;
103
- t instanceof Node && (!N.current?.contains(t) && !F.current?.contains(t) || (e.preventDefault(), e.stopPropagation(), O?.(!1), R(!1)));
104
- };
105
- return document.addEventListener("pointerdown", e, !0), window.addEventListener("keydown", t, !0), () => {
106
- document.removeEventListener("pointerdown", e, !0), window.removeEventListener("keydown", t, !0);
107
- };
108
- }, [q, O]), e(() => {
109
- if (!q || typeof window > "u" || !("IntersectionObserver" in window)) return;
110
- let e = N.current;
111
- if (!e) return;
112
- let t = !0, n = new IntersectionObserver((e) => {
113
- if (!t) return;
114
- let n = e[0];
115
- n && !n.isIntersecting && J(!1);
116
- });
117
- return n.observe(e), () => {
118
- t = !1, n.disconnect();
119
- };
120
- }, [q]), t(() => {
121
- if (!q || T || !M) return;
122
- let e = () => {
123
- !P.current || !F.current || W(v(P.current, F.current, M));
124
- };
125
- e();
126
- let t = window.requestAnimationFrame(e);
127
- return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
128
- window.cancelAnimationFrame(t), window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
129
- };
130
- }, [
131
- T,
132
- q,
133
- M
134
- ]), e(() => {
135
- if (!q || !I.current || !V) return;
136
- let e = I.current.querySelector(`[role="option"][data-value="${V}"]`);
137
- if (!e) return;
138
- let t = e.offsetTop - 8, n = e.offsetTop + e.offsetHeight + 8;
139
- if (t < I.current.scrollTop) {
140
- I.current.scrollTop = Math.max(0, t);
141
- return;
142
- }
143
- n > I.current.scrollTop + I.current.clientHeight && (I.current.scrollTop = Math.max(0, n - I.current.clientHeight));
144
- }, [V, q]);
145
- let J = (e) => {
146
- O?.(e), R(e);
147
- }, Y = (e) => {
148
- b?.(e), y(e);
149
- };
150
- return /* @__PURE__ */ i("div", {
151
- "data-slot": "hours-picker-input",
152
- className: o("w-[150px]", C),
153
- ref: N,
154
- children: /* @__PURE__ */ a("div", {
155
- className: "relative group",
156
- children: [
157
- /* @__PURE__ */ i("input", {
158
- ref: P,
159
- id: u,
160
- type: "text",
161
- "data-testid": k,
162
- "data-hydrated": j ? "true" : void 0,
163
- autoComplete: "off",
164
- disabled: T,
165
- readOnly: E,
166
- placeholder: S,
167
- value: z,
168
- className: o("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "transition-colors group-hover:bg-accent group-hover:text-accent-foreground", !z && "text-muted-foreground", q && "ring-2 ring-primary ring-offset-2", w),
169
- onChange: (e) => {
170
- let t = p(e.currentTarget.value);
171
- if (B(t), !t) {
172
- b?.(null);
173
- return;
174
- }
175
- let n = m(t, x);
176
- if (n) {
177
- H(n), b?.(n);
178
- return;
179
- }
180
- let r = f(t);
181
- if (!r) return;
182
- let i = g(r, x);
183
- i && H(i.value);
184
- },
185
- onFocus: (e) => {
186
- G.current = !0;
187
- let t = e.currentTarget;
188
- requestAnimationFrame(() => {
189
- t.select();
190
- }), T || J(!0);
191
- },
192
- onClick: () => {
193
- T || J(!0);
194
- },
195
- onKeyDown: (e) => {
196
- if (!T) {
197
- if (e.key === "Tab") {
198
- J(!1);
199
- return;
200
- }
201
- if (e.key === "Escape") {
202
- if (!q) return;
203
- e.preventDefault(), J(!1);
204
- return;
205
- }
206
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
207
- if (e.preventDefault(), !q) {
208
- J(!0);
209
- return;
210
- }
211
- let t = _(V ?? d, e.key === "ArrowDown" ? 1 : -1, x);
212
- if (!t) return;
213
- H(t), B(t), b?.(t);
214
- return;
215
- }
216
- if (e.key === "Enter") {
217
- let t = V ?? m(z, x) ?? g(z, x)?.value ?? h(x)?.value ?? null;
218
- if (!t) return;
219
- e.preventDefault(), B(t), H(t), Y(t), J(!1);
220
- return;
221
- }
222
- !q && (e.key.length === 1 || e.key === "Backspace" || e.key === "Delete") && !e.ctrlKey && !e.metaKey && !e.altKey && J(!0);
223
- }
224
- },
225
- onBlur: (e) => {
226
- if (G.current = !1, K.current) {
227
- K.current = !1;
228
- return;
229
- }
230
- let t = e.relatedTarget;
231
- if (t instanceof Node && (N.current?.contains(t) || F.current?.contains(t))) return;
232
- if (requestAnimationFrame(() => {
233
- let e = document.activeElement;
234
- e instanceof Node && (N.current?.contains(e) || F.current?.contains(e)) || J(!1);
235
- }), !z.trim()) {
236
- B(d ?? "");
237
- return;
238
- }
239
- let n = m(z, x);
240
- if (n) {
241
- B(n), H(n), d !== n && Y(n);
242
- return;
243
- }
244
- B(d ?? "");
245
- }
246
- }),
247
- /* @__PURE__ */ i("button", {
248
- type: "button",
249
- tabIndex: -1,
250
- disabled: T,
251
- "data-slot": "hours-picker-input-toggle",
252
- className: "absolute right-1 top-1/2 inline-flex size-8 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
253
- "aria-label": q ? "Close time picker" : "Open time picker",
254
- onPointerDown: (e) => {
255
- e.preventDefault();
256
- },
257
- onMouseDown: (e) => {
258
- e.preventDefault();
259
- },
260
- onClick: () => {
261
- T || (J(!q), P.current?.focus({ preventScroll: !0 }));
262
- },
263
- children: /* @__PURE__ */ i(c, {
264
- "aria-hidden": !0,
265
- className: "size-4"
266
- })
267
- }),
268
- q ? l(/* @__PURE__ */ i("div", {
269
- ref: F,
270
- "data-testid": A,
271
- "data-state": "open",
272
- className: "pointer-events-auto overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
273
- style: {
274
- position: U.strategy,
275
- left: U.left,
276
- top: U.top,
277
- width: U.width
278
- },
279
- onPointerDownCapture: () => {
280
- K.current = !0;
281
- },
282
- onMouseDownCapture: () => {
283
- K.current = !0;
284
- },
285
- children: /* @__PURE__ */ i("div", {
286
- ref: I,
287
- role: "listbox",
288
- className: "max-h-64 overflow-y-auto p-1",
289
- children: x.map((e) => {
290
- let t = e.value === d, n = e.value === V;
291
- return /* @__PURE__ */ a("div", {
292
- role: "option",
293
- "aria-selected": t,
294
- "data-value": e.value,
295
- "data-state": t ? "checked" : "unchecked",
296
- "data-disabled": e.disabled ? "" : void 0,
297
- className: o("relative flex w-full select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none", e.disabled ? "pointer-events-none opacity-50" : "cursor-pointer", n && "bg-accent text-accent-foreground"),
298
- onMouseDown: (e) => {
299
- e.preventDefault();
300
- },
301
- onClick: () => {
302
- e.disabled || (B(e.value), H(e.value), Y(e.value), J(!1), P.current?.focus({ preventScroll: !0 }));
303
- },
304
- onPointerEnter: () => {
305
- e.disabled || H(e.value);
306
- },
307
- onPointerMove: () => {
308
- e.disabled || H(e.value);
309
- },
310
- children: [/* @__PURE__ */ i("span", {
311
- className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
312
- children: t ? /* @__PURE__ */ i(s, {
313
- "aria-hidden": !0,
314
- className: "h-4 w-4"
315
- }) : null
316
- }), /* @__PURE__ */ a("div", {
317
- className: "flex flex-col",
318
- children: [/* @__PURE__ */ i("span", { children: e.label }), e.description == null ? null : /* @__PURE__ */ i("span", {
319
- "data-slot": "description",
320
- className: "text-xs text-muted-foreground",
321
- children: e.description
322
- })]
323
- })]
324
- }, e.value);
325
- })
326
- })
327
- }), M) : null
328
- ]
329
- })
330
- });
331
- }
332
- //#endregion
333
- export { y as ModalHourPickerField };