@riverbankcms/sdk 0.132.0 → 0.134.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/CHANGELOG.md +10 -0
- package/dist/{PreviewEditorSidebar-DKQ5eFK9.mjs → PreviewEditorSidebar-DfRhJPFQ.mjs} +3 -3
- package/dist/{PreviewEditorUI-CNTcOjCC.mjs → PreviewEditorUI-Dppxcr_g.mjs} +2 -2
- package/dist/{SdkPreviewModeRuntime-DJu3qu33.mjs → SdkPreviewModeRuntime-8CyGCXir.mjs} +46 -15
- package/dist/{SiteChromeCustomizeContext-2TzT3vbj.mjs → SiteChromeCustomizeContext-DVMTMvqA.mjs} +497 -169
- package/dist/_dts/ai/src/contracts/proposals.d.ts +384 -384
- package/dist/_dts/ai/src/contracts/siteStyleProposalSchemas.d.ts +219 -219
- package/dist/_dts/api/src/accountApi.d.ts +5 -5
- package/dist/_dts/api/src/appointmentEndpointDefinitions.d.ts +1 -1
- package/dist/_dts/api/src/bookingOperations.d.ts +2 -14
- package/dist/_dts/api/src/bookings.d.ts +2 -2
- package/dist/_dts/api/src/contentRuntime.d.ts +1 -1
- package/dist/_dts/api/src/courseEndpointDefinitions.d.ts +2 -2
- package/dist/_dts/api/src/endpoints.d.ts +3 -3
- package/dist/_dts/api/src/indexCoreTypes.d.ts +1 -1
- package/dist/_dts/api/src/navigation/contracts.d.ts +9 -6
- package/dist/_dts/api/src/navigation/linkResolver.d.ts +6 -2
- package/dist/_dts/api/src/navigation/types.d.ts +23 -6
- package/dist/_dts/api/src/navigation.d.ts +1 -1
- package/dist/_dts/api/src/publicBookingService.d.ts +15 -0
- package/dist/_dts/api/src/publicExperience/eventEndpoints.d.ts +3 -1
- package/dist/_dts/api/src/publicExperience/wholeSeriesEndpoints.d.ts +2 -0
- package/dist/_dts/api/src/sdk-event-upsert.d.ts +1 -1
- package/dist/_dts/api/src/sdkThemeWire.d.ts +50 -50
- package/dist/_dts/api/src/siteBanner.d.ts +4 -2
- package/dist/_dts/api/src/types.d.ts +1 -1
- package/dist/_dts/api/src/webhooks.d.ts +12 -12
- package/dist/_dts/blocks/src/client.d.ts +1 -1
- package/dist/_dts/blocks/src/contracts/proof-block-islands.d.ts +28 -72
- package/dist/_dts/blocks/src/index.d.ts +3 -2
- package/dist/_dts/blocks/src/primitives/content/components/RichText.d.ts +2 -2
- package/dist/_dts/blocks/src/primitives/content/primitives.d.ts +1 -0
- package/dist/_dts/blocks/src/system/blocks/events/shared/schemas.d.ts +36 -14
- package/dist/_dts/blocks/src/system/blocks/events/shared/types.d.ts +3 -0
- package/dist/_dts/blocks/src/system/blocks/events/whole-series/schemas.d.ts +3 -3
- package/dist/_dts/blocks/src/system/blocks/events/whole-series/types.d.ts +3 -0
- package/dist/_dts/blocks/src/system/blocks/location-map.d.ts +4 -4
- package/dist/_dts/blocks/src/system/blocks/media-text.d.ts +148 -148
- package/dist/_dts/blocks/src/system/blocks/offerings-preview/model.d.ts +2 -1
- package/dist/_dts/blocks/src/system/blocks/shared/bookingConsent.d.ts +36 -0
- package/dist/_dts/blocks/src/system/manifest/hydrateLinks.d.ts +9 -2
- package/dist/_dts/blocks/src/system/manifest/resolveBlockData.d.ts +8 -0
- package/dist/_dts/blocks/src/system/manifest/schema.d.ts +79 -79
- package/dist/_dts/blocks/src/system/runtime/api/types/appointments.d.ts +2 -11
- package/dist/_dts/blocks/src/system/runtime/api/types/courses.d.ts +2 -0
- package/dist/_dts/blocks/src/system/runtime/api/types/events.d.ts +1 -0
- package/dist/_dts/blocks/src/system/runtime/components/multi-step/DynamicFormFields.d.ts +3 -19
- package/dist/_dts/blocks/src/system/runtime/components/runtime-backed-blocks.d.ts +1 -1
- package/dist/_dts/blocks/src/system/runtime/hooks/useSelectedAppointmentConsentForm.d.ts +2 -0
- package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.consent.d.ts +10 -0
- package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.field-values.d.ts +4 -0
- package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.fields.d.ts +21 -0
- package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.headless.state.d.ts +2 -1
- package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.interactive.d.ts +38 -144
- package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.state.d.ts +5 -19
- package/dist/_dts/blocks/src/system/runtime/nodes/booking-runtime-sources.d.ts +3 -2
- package/dist/_dts/blocks/src/system/runtime/nodes/event-registration/AttendeeDetailsStep.d.ts +2 -0
- package/dist/_dts/blocks/src/system/runtime/nodes/event-registration/registrationSurface.d.ts +18 -1
- package/dist/_dts/blocks/src/system/runtime/nodes/event-registration/useEventRegistrationWizard.d.ts +4 -4
- package/dist/_dts/blocks/src/system/runtime/nodes/event-registration/validation.d.ts +2 -1
- package/dist/_dts/blocks/src/system/runtime/nodes/event-registration/whole-series/components.d.ts +2 -1
- package/dist/_dts/blocks/src/system/runtime/nodes/event-registration/whole-series/whole-series-registration.headless.contract.d.ts +2 -0
- package/dist/_dts/blocks/src/system/runtime/nodes/events/shared/eventCollectionContract.d.ts +34 -12
- package/dist/_dts/blocks/src/system/runtime/shared/components/BookingConsentAgreement.d.ts +7 -0
- package/dist/_dts/blocks/src/system/runtime/shared/types.d.ts +1 -0
- package/dist/_dts/blocks/src/system/types/link.d.ts +7 -1
- package/dist/_dts/content-model/src/content-types/schema.d.ts +4 -4
- package/dist/_dts/core/src/booking-consent.d.ts +8 -0
- package/dist/_dts/core/src/index.d.ts +1 -0
- package/dist/_dts/db/src/generated/supabase/database.types.d.ts +9 -3
- package/dist/_dts/db/src/schemas/forms.d.ts +21 -21
- package/dist/_dts/db/src/types/jsonb.d.ts +1 -1
- package/dist/_dts/editor/src/primitives/rich-text/RichTextEditorSurface.d.ts +2 -1
- package/dist/_dts/editor/src/primitives/rich-text/config.d.ts +2 -1
- package/dist/_dts/editor/src/primitives/rich-text/toolbar/linkPopoverUtils.d.ts +3 -2
- package/dist/_dts/editor/src/primitives/rich-text/useRichTextEditor.d.ts +3 -4
- package/dist/_dts/media-core/src/usageScanner.d.ts +1 -1
- package/dist/_dts/sdk/src/bookings/types.d.ts +7 -89
- package/dist/_dts/sdk/src/config/validation.d.ts +30 -30
- package/dist/_dts/sdk/src/contracts/content.d.ts +10 -36
- package/dist/_dts/sdk/src/contracts/rendering.d.ts +1 -1
- package/dist/_dts/sdk/src/manifest/passes/pass1-fields.d.ts +9 -9
- package/dist/_dts/sdk/src/public-api/contracts.d.ts +6 -19
- package/dist/_dts/sdk/src/version.d.ts +1 -1
- package/dist/_dts/theme-core/src/accordions/types.d.ts +2 -2
- package/dist/_dts/theme-core/src/buttons/types.d.ts +12 -12
- package/dist/_dts/theme-core/src/cards/types.d.ts +5 -5
- package/dist/_dts/theme-core/src/mock-themes/all.d.ts +72 -72
- package/dist/_dts/theme-core/src/navigation/types.d.ts +4 -4
- package/dist/_dts/theme-core/src/palette/colors.d.ts +1 -1
- package/dist/_dts/theme-core/src/palette/curated/types.d.ts +2 -2
- package/dist/_dts/theme-core/src/schema.d.ts +82 -82
- package/dist/_dts/theme-core/src/site-styles/cardRoleVocabulary.d.ts +1 -1
- package/dist/_dts/theme-core/src/site-styles/designState.d.ts +2 -2
- package/dist/_dts/theme-core/src/site-styles/generatedSchemas.d.ts +4 -4
- package/dist/_dts/theme-core/src/site-styles/logoBranding.d.ts +4 -4
- package/dist/_dts/theme-core/src/tokens/themeColorTokens.d.ts +1 -1
- package/dist/_dts/ui/src/badge.d.ts +1 -1
- package/dist/_dts/ui/src/button.d.ts +1 -1
- package/dist/_dts/ui/src/callout.d.ts +1 -1
- package/dist/_dts/ui/src/card.d.ts +1 -1
- package/dist/client/{StepIndicator-CGixP_LW.mjs → BookingConsentAgreement-BxgpGEFD.mjs} +26 -4
- package/dist/client/{DiscountCodeDisclosure-DO7llLxm.mjs → DiscountCodeDisclosure-CfuPOHD0.mjs} +1 -1
- package/dist/client/{EventCombined.client-xID7zN__.mjs → EventCombined.client-DB8Qfzi-.mjs} +3 -3
- package/dist/client/{EventListing.client-CriBslp0.mjs → EventListing.client-DD4X8hp4.mjs} +2 -2
- package/dist/client/{LeafletStaticMap-DYmHnM8g.mjs → LeafletStaticMap-QhgIBQbv.mjs} +1 -1
- package/dist/client/{WholeSeriesRegistrationWizard-BEjzSiOA.mjs → WholeSeriesRegistrationWizard-DwtC7bCs.mjs} +72 -22
- package/dist/client/{accordion-CgFbnnnQ.mjs → accordion-DFXpLvwg.mjs} +1 -1
- package/dist/client/{bookingForm-dUyGpbxc.mjs → bookingForm-sI05d3lk.mjs} +73 -47
- package/dist/client/bookings.mjs +989 -140
- package/dist/client/{carousel-BvBwkUzx.mjs → carousel-wjyWTZCh.mjs} +1 -1
- package/dist/client/{cart-DiZENT2E.mjs → cart-DCwdpA4i.mjs} +3 -3
- package/dist/client/{checkout-Dq13KIgR.mjs → checkout-DTDW3l0R.mjs} +3 -3
- package/dist/client/checkoutUrls-DQYC_Br-.mjs +187 -0
- package/dist/client/client.mjs +556 -237
- package/dist/client/{context-B83PiNzm.mjs → context-TSK1CGx8.mjs} +1 -14
- package/dist/client/{courseRegistration-CKC5NmyH.mjs → courseRegistration-A-Tg7qw_.mjs} +3 -3
- package/dist/client/{eventCalendar-BF0Jatfw.mjs → eventCalendar-B0Zg-i_w.mjs} +5 -5
- package/dist/client/{eventCombined-BuoCF8je.mjs → eventCombined-B8Y2wizd.mjs} +3 -3
- package/dist/client/{eventDetails-CKwh0S9s.mjs → eventDetails-DPDOwURJ.mjs} +3 -3
- package/dist/client/{eventListing-eUxaWFaB.mjs → eventListing-CjBcmSLn.mjs} +3 -3
- package/dist/client/{eventRegistration-CfkNOkPb.mjs → eventRegistration-CK30HsAq.mjs} +111 -64
- package/dist/client/{form-C17H1c_H.mjs → form-CUXfsABE.mjs} +2 -2
- package/dist/client/{headerSection-DEwUmrtt.mjs → headerSection-N-mN3rjr.mjs} +2 -2
- package/dist/client/hooks.mjs +106 -3
- package/dist/client/{locationMap-Pf2QwuvW.mjs → locationMap-oiIDQMBt.mjs} +2 -2
- package/dist/client/{newsletterForm-BWQAH5Sv.mjs → newsletterForm-CkQ2tTrM.mjs} +2 -2
- package/dist/client/{pricing-CVdvbopJ.mjs → pricing-Caa0QWzh.mjs} +1 -1
- package/dist/client/{productDetail-BZi1Fa_G.mjs → productDetail-CnidyrsN.mjs} +3 -3
- package/dist/client/{productList-qq-55DNk.mjs → productList-CttYcS_S.mjs} +3 -3
- package/dist/client/{propsDecoder-BxmqPKdP.mjs → propsDecoder-CeUMxI9a.mjs} +211 -100
- package/dist/client/rendering/client.mjs +428 -151
- package/dist/client/rendering/islands.mjs +18 -18
- package/dist/client/rendering.mjs +643 -324
- package/dist/client/{scrollToBlock-B3CcKdtG.mjs → scrollToBlock-lPr1oqxB.mjs} +1 -1
- package/dist/client/{shop-DNWJPut5.mjs → shop-DXQtMo2O.mjs} +6 -6
- package/dist/client/{shop-commerce-BhvQCosS.mjs → shop-commerce-quDL411J.mjs} +7 -164
- package/dist/client/{shop-commerce-store-B04sCNnW.mjs → shop-commerce-store-Dnu-8Iub.mjs} +1 -1
- package/dist/client/{shopShared-DNNgZlmW.mjs → shopShared-BWPUURvG.mjs} +3 -3
- package/dist/client/{useEventFilters-CUmhE24_.mjs → useEventFilters-DRhWp2_5.mjs} +3 -3
- package/dist/client/{usePolling-M5jG675x.mjs → usePolling-UN4WKnaM.mjs} +2 -2
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/{sdk-runtime-BEXb1wqo.mjs → sdk-runtime-Ca5RD78X.mjs} +1 -1
- package/dist/{separator-DGMuip1D.mjs → separator-CMhj6BTi.mjs} +1 -1
- package/dist/server/components.mjs +117 -37
- package/dist/server/config-validation.mjs +106 -3
- package/dist/server/config.mjs +106 -3
- package/dist/server/data.mjs +106 -3
- package/dist/server/index.mjs +1 -1
- package/dist/server/next.mjs +186 -106
- package/dist/server/page-converter.mjs +105 -2
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/rendering/server.mjs +119 -37
- package/dist/server/rendering.mjs +117 -37
- package/dist/server/routing.mjs +132 -73
- package/dist/server/server.mjs +107 -4
- package/dist/server/theme-bridge.mjs +4 -4
- package/package.json +2 -2
- package/dist/client/checkoutUrls-Ct8Mxna3.mjs +0 -26
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { S as unsafeAsPassId, _ as unsafeAsAppointmentResourceId, b as unsafeAsFormId, v as unsafeAsAppointmentServiceId, y as unsafeAsCustomerPassId } from "./colorStyles-CrxJrPjJ.mjs";
|
|
3
|
-
import { n as buildBookingPaymentSelectionViewModel, t as usePolling } from "./usePolling-
|
|
4
|
-
import { Ct as
|
|
5
|
-
import { n as useBlockApi, t as BlockApiProvider } from "./context-
|
|
3
|
+
import { n as buildBookingPaymentSelectionViewModel, t as usePolling } from "./usePolling-UN4WKnaM.mjs";
|
|
4
|
+
import { $ as themeButtonClassName, At as okWith, Bt as parseBookingLocalDate, Ct as isBookingRequirementConsentFieldId, Dt as clearWorkflowFeedback, Et as assertNever, It as formatBookingInstant, Mt as reportWorkflowSuccess, Nt as addLocalScheduleDays, Ot as err, Rt as formatLocalScheduleDate, St as BOOKING_FORM_DATA_RESERVED_KEYS, Vt as resolveBookingTimeZoneId, Zt as formatCurrencyAmount, _t as resolveBookingSiteId, at as logger, bt as projectSelectedAppointmentConsentIntoForm, ct as formatBookingSubmissionPreparationError, dt as getBookingSuccessMessage, ft as isBookingServiceSlidingAmountInRange, gt as resolveBookingPaymentStep, ht as resolveAppointmentCheckoutVerificationState, jt as reportWorkflowError, lt as getBookingRedirectStateFromLocation, mt as prepareBookingSubmission, ot as deriveBookingFormViewState, pt as parseBookingCurrencyInputToCents, st as formatBookingCentsAsCurrencyInput, t as defineIslandPropsDecoder, ut as getBookingServiceSlidingScale, vt as resolveDefaultBookingServiceId, xt as resolveSelectedAppointmentConsent, yt as toSelectedCollectionOptionKind } from "./propsDecoder-CeUMxI9a.mjs";
|
|
5
|
+
import { n as useBlockApi, t as BlockApiProvider } from "./context-TSK1CGx8.mjs";
|
|
6
6
|
import { n as isSpamProtectionEnabled, r as AltchaWidget, t as getChallengeUrl } from "./src-B833rYRr.mjs";
|
|
7
|
-
import { a as CheckIcon, i as StateIcon, n as useDiscountCodeUi, r as TerminalPanel, t as scrollToBlock } from "./scrollToBlock-
|
|
8
|
-
import { t as DiscountCodeDisclosure } from "./DiscountCodeDisclosure-
|
|
9
|
-
import { n as SpinnerNode, t as
|
|
7
|
+
import { a as CheckIcon, i as StateIcon, n as useDiscountCodeUi, r as TerminalPanel, t as scrollToBlock } from "./scrollToBlock-lPr1oqxB.mjs";
|
|
8
|
+
import { t as DiscountCodeDisclosure } from "./DiscountCodeDisclosure-CfuPOHD0.mjs";
|
|
9
|
+
import { n as StepIndicator, r as SpinnerNode, t as BookingConsentAgreement } from "./BookingConsentAgreement-BxgpGEFD.mjs";
|
|
10
10
|
import { t as FeedbackMessage } from "./FeedbackMessage-CtLvvS_d.mjs";
|
|
11
11
|
import { n as getFieldValidationControlProps, t as FieldValidationMessage } from "./FieldValidationMessage-AYanWFb-.mjs";
|
|
12
|
-
import { t as buildCheckoutReturnUrls } from "./checkoutUrls-
|
|
12
|
+
import { t as buildCheckoutReturnUrls } from "./checkoutUrls-DQYC_Br-.mjs";
|
|
13
13
|
import { t as mountReactIsland } from "./reactMount-SY8AVRof.mjs";
|
|
14
14
|
import { t as buildRouteIslandApiConfig } from "./routeIslandApiConfig-UNsfPcYq.mjs";
|
|
15
15
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
@@ -38,6 +38,11 @@ const SuccessMessage = ({ message, resourceName, className }) => {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
//#endregion
|
|
41
|
+
//#region ../blocks/src/system/runtime/hooks/useSelectedAppointmentConsentForm.ts
|
|
42
|
+
function useSelectedAppointmentConsentForm(form, selectedService) {
|
|
43
|
+
return useMemo(() => projectSelectedAppointmentConsentIntoForm(form, resolveSelectedAppointmentConsent(selectedService)), [form, selectedService]);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
41
46
|
//#region ../blocks/src/utils/date-formatting.ts
|
|
42
47
|
/**
|
|
43
48
|
* Resolve the browser/runtime timezone for booking surfaces.
|
|
@@ -682,6 +687,19 @@ function clearBookingFieldError(errors, fieldId) {
|
|
|
682
687
|
};
|
|
683
688
|
}
|
|
684
689
|
//#endregion
|
|
690
|
+
//#region ../blocks/src/system/runtime/nodes/booking-form.field-values.ts
|
|
691
|
+
function collectInitialBookingFieldValues(initialData) {
|
|
692
|
+
const values = {};
|
|
693
|
+
for (const [key, value] of Object.entries(initialData)) if (!BOOKING_FORM_DATA_RESERVED_KEYS.has(key) && !isBookingRequirementConsentFieldId(key) && isBookingFieldValue(value)) values[key] = value;
|
|
694
|
+
return values;
|
|
695
|
+
}
|
|
696
|
+
function omitBookingConsentEntries(record) {
|
|
697
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => !isBookingRequirementConsentFieldId(key)));
|
|
698
|
+
}
|
|
699
|
+
function isBookingFieldValue(value) {
|
|
700
|
+
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
701
|
+
}
|
|
702
|
+
//#endregion
|
|
685
703
|
//#region ../blocks/src/system/runtime/nodes/booking-form.headless.state.ts
|
|
686
704
|
const unsafeAsBookingFieldId = (id) => id;
|
|
687
705
|
function createInitialBookingFlowReducerState(input) {
|
|
@@ -693,7 +711,7 @@ function createInitialBookingFlowReducerState(input) {
|
|
|
693
711
|
selectedResourceId: toOptionalAppointmentResourceId(toOptionalString(initialData.resourceId) ?? input.defaultResourceId),
|
|
694
712
|
selectedDate: toOptionalString(initialData.selectedDate),
|
|
695
713
|
selectedSlot: null,
|
|
696
|
-
fieldValues:
|
|
714
|
+
fieldValues: collectInitialBookingFieldValues(initialData),
|
|
697
715
|
touchedFields: {},
|
|
698
716
|
attemptedStepIds: {},
|
|
699
717
|
discountCode: toOptionalString(initialData.discountCode) ?? "",
|
|
@@ -705,14 +723,6 @@ function createInitialBookingFlowReducerState(input) {
|
|
|
705
723
|
feedback: { kind: "none" }
|
|
706
724
|
};
|
|
707
725
|
}
|
|
708
|
-
function collectInitialFieldValues(initialData) {
|
|
709
|
-
const values = {};
|
|
710
|
-
for (const [key, value] of Object.entries(initialData)) {
|
|
711
|
-
if (BOOKING_FORM_DATA_RESERVED_KEYS.has(key) || !isBookingFieldValue(value)) continue;
|
|
712
|
-
values[key] = value;
|
|
713
|
-
}
|
|
714
|
-
return values;
|
|
715
|
-
}
|
|
716
726
|
function toOptionalString(value) {
|
|
717
727
|
if (typeof value !== "string") return void 0;
|
|
718
728
|
const trimmed = value.trim();
|
|
@@ -731,9 +741,6 @@ function toOptionalAppointmentResourceId(value) {
|
|
|
731
741
|
function toOptionalCustomerPassId(value) {
|
|
732
742
|
return toOptionalBrandedId(value, unsafeAsCustomerPassId);
|
|
733
743
|
}
|
|
734
|
-
function isBookingFieldValue(value) {
|
|
735
|
-
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
736
|
-
}
|
|
737
744
|
/**
|
|
738
745
|
* Send the flow back to the date step when the slot it was holding went away,
|
|
739
746
|
* leaving a scoped feedback message. A completed booking is left alone.
|
|
@@ -755,17 +762,7 @@ function applyAvailabilitySelectionInvalidation(state, invalidation) {
|
|
|
755
762
|
}
|
|
756
763
|
function bookingFlowReducer(state, event) {
|
|
757
764
|
switch (event.type) {
|
|
758
|
-
case "service-selected": return
|
|
759
|
-
...state,
|
|
760
|
-
selectedServiceId: event.serviceId,
|
|
761
|
-
selectedResourceId: void 0,
|
|
762
|
-
selectedDate: void 0,
|
|
763
|
-
selectedSlot: null,
|
|
764
|
-
selectedAppointmentPackageId: void 0,
|
|
765
|
-
selectedSlidingAmountInput: "",
|
|
766
|
-
selectedCollectionOptionKind: void 0,
|
|
767
|
-
validationErrors: clearBookingFormError(state.validationErrors)
|
|
768
|
-
};
|
|
765
|
+
case "service-selected": return applyBookingServiceSelection(state, event.serviceId);
|
|
769
766
|
case "resource-selected": return {
|
|
770
767
|
...state,
|
|
771
768
|
selectedResourceId: event.resourceId ?? void 0,
|
|
@@ -872,6 +869,24 @@ function bookingFlowReducer(state, event) {
|
|
|
872
869
|
default: return assertNever(event);
|
|
873
870
|
}
|
|
874
871
|
}
|
|
872
|
+
function applyBookingServiceSelection(state, serviceId) {
|
|
873
|
+
return {
|
|
874
|
+
...state,
|
|
875
|
+
selectedServiceId: serviceId,
|
|
876
|
+
selectedResourceId: void 0,
|
|
877
|
+
selectedDate: void 0,
|
|
878
|
+
selectedSlot: null,
|
|
879
|
+
selectedAppointmentPackageId: void 0,
|
|
880
|
+
selectedSlidingAmountInput: "",
|
|
881
|
+
selectedCollectionOptionKind: void 0,
|
|
882
|
+
fieldValues: omitBookingConsentEntries(state.fieldValues),
|
|
883
|
+
touchedFields: omitBookingConsentEntries(state.touchedFields),
|
|
884
|
+
validationErrors: {
|
|
885
|
+
...clearBookingFormError(state.validationErrors),
|
|
886
|
+
fieldErrors: omitBookingConsentEntries(state.validationErrors.fieldErrors)
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
}
|
|
875
890
|
function clearAvailabilityFeedback(feedback) {
|
|
876
891
|
return feedback.kind === "error" && feedback.scope === "availability" ? { kind: "none" } : feedback;
|
|
877
892
|
}
|
|
@@ -1032,7 +1047,8 @@ function validateBookingFields(input) {
|
|
|
1032
1047
|
return errors;
|
|
1033
1048
|
}
|
|
1034
1049
|
function validateBookingField(field, value) {
|
|
1035
|
-
|
|
1050
|
+
const requiredError = validateRequiredBookingField(field, value);
|
|
1051
|
+
if (requiredError) return requiredError;
|
|
1036
1052
|
if (isBlankFieldValue(value)) return null;
|
|
1037
1053
|
const strValue = typeof value === "string" ? value : String(value);
|
|
1038
1054
|
if (field.type === "email") return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(strValue) ? null : "Please enter a valid email address";
|
|
@@ -1061,6 +1077,10 @@ function validateBookingField(field, value) {
|
|
|
1061
1077
|
}
|
|
1062
1078
|
return null;
|
|
1063
1079
|
}
|
|
1080
|
+
function validateRequiredBookingField(field, value) {
|
|
1081
|
+
if (field.type === "booking_requirement_consent") return value === true ? null : `${field.label} is required`;
|
|
1082
|
+
return field.required && isBlankFieldValue(value) ? `${field.label} is required` : null;
|
|
1083
|
+
}
|
|
1064
1084
|
function deriveBookingFlowSteps(input) {
|
|
1065
1085
|
const stepResolution = buildBookingStepResolution({
|
|
1066
1086
|
form: input.form,
|
|
@@ -1132,7 +1152,8 @@ function deriveBookingFieldViews(input) {
|
|
|
1132
1152
|
return (input.form?.schema?.fields ?? []).map((field) => {
|
|
1133
1153
|
const fieldId = unsafeAsBookingFieldId(field.id);
|
|
1134
1154
|
const inputId = `${input.idPrefix}-${fieldId}`;
|
|
1135
|
-
const
|
|
1155
|
+
const helpText = field.type === "booking_requirement_consent" ? null : field.helpText ?? null;
|
|
1156
|
+
const helpTextId = helpText ? `${inputId}-help` : null;
|
|
1136
1157
|
const fieldValue = input.values[field.id] ?? null;
|
|
1137
1158
|
const localError = input.touched?.[field.id] ? validateBookingField(field, fieldValue) : null;
|
|
1138
1159
|
const error = input.errors[field.id] ?? localError;
|
|
@@ -1142,17 +1163,17 @@ function deriveBookingFieldViews(input) {
|
|
|
1142
1163
|
field,
|
|
1143
1164
|
id: fieldId,
|
|
1144
1165
|
label: field.label,
|
|
1145
|
-
type: field.type,
|
|
1146
1166
|
value: fieldValue,
|
|
1147
1167
|
required: Boolean(field.required),
|
|
1148
1168
|
error,
|
|
1149
|
-
helpText
|
|
1169
|
+
helpText,
|
|
1150
1170
|
inputId,
|
|
1151
1171
|
labelId: `${inputId}-label`,
|
|
1152
1172
|
helpTextId,
|
|
1153
1173
|
errorId,
|
|
1154
1174
|
describedBy,
|
|
1155
|
-
ariaInvalid: Boolean(error)
|
|
1175
|
+
ariaInvalid: Boolean(error),
|
|
1176
|
+
type: field.type
|
|
1156
1177
|
};
|
|
1157
1178
|
});
|
|
1158
1179
|
}
|
|
@@ -1346,6 +1367,7 @@ function useHeadlessBookingFlow(options) {
|
|
|
1346
1367
|
const selectedServiceId = state.selectedServiceId ?? defaultServiceId;
|
|
1347
1368
|
const selectedResourceId = state.selectedResourceId ?? defaultResourceId;
|
|
1348
1369
|
const selectedService = options.services.find((service) => service.id === selectedServiceId) ?? null;
|
|
1370
|
+
const runtimeForm = useSelectedAppointmentConsentForm(options.form, selectedService);
|
|
1349
1371
|
const lastSlidingServiceIdRef = useRef(null);
|
|
1350
1372
|
useEffect(() => {
|
|
1351
1373
|
const selectedId = selectedService?.id ?? null;
|
|
@@ -1386,7 +1408,7 @@ function useHeadlessBookingFlow(options) {
|
|
|
1386
1408
|
viewerTimeZone
|
|
1387
1409
|
]);
|
|
1388
1410
|
const stepState = useMemo(() => deriveBookingFlowSteps({
|
|
1389
|
-
form:
|
|
1411
|
+
form: runtimeForm,
|
|
1390
1412
|
services: options.services,
|
|
1391
1413
|
data,
|
|
1392
1414
|
defaultServiceId,
|
|
@@ -1402,7 +1424,7 @@ function useHeadlessBookingFlow(options) {
|
|
|
1402
1424
|
defaultServiceId,
|
|
1403
1425
|
defaultResourceId,
|
|
1404
1426
|
options.enableAppointmentPackages,
|
|
1405
|
-
|
|
1427
|
+
runtimeForm,
|
|
1406
1428
|
options.requiresResourceSelection,
|
|
1407
1429
|
options.requiresServiceSelection,
|
|
1408
1430
|
options.services,
|
|
@@ -1456,13 +1478,13 @@ function useHeadlessBookingFlow(options) {
|
|
|
1456
1478
|
state.selectedSlot
|
|
1457
1479
|
]);
|
|
1458
1480
|
const fields = useMemo(() => deriveBookingFieldViews({
|
|
1459
|
-
form:
|
|
1481
|
+
form: runtimeForm,
|
|
1460
1482
|
values: state.fieldValues,
|
|
1461
1483
|
errors: state.validationErrors.fieldErrors,
|
|
1462
1484
|
touched: state.touchedFields,
|
|
1463
1485
|
idPrefix: `booking-${options.formId}`
|
|
1464
1486
|
}), [
|
|
1465
|
-
|
|
1487
|
+
runtimeForm,
|
|
1466
1488
|
options.formId,
|
|
1467
1489
|
state.fieldValues,
|
|
1468
1490
|
state.touchedFields,
|
|
@@ -1582,7 +1604,7 @@ function useHeadlessBookingFlow(options) {
|
|
|
1582
1604
|
const latestRef = useLatestRef({
|
|
1583
1605
|
state,
|
|
1584
1606
|
data,
|
|
1585
|
-
form:
|
|
1607
|
+
form: runtimeForm,
|
|
1586
1608
|
formId: formKey,
|
|
1587
1609
|
services: options.services,
|
|
1588
1610
|
defaultServiceId,
|
|
@@ -1834,7 +1856,7 @@ function useHeadlessBookingFlow(options) {
|
|
|
1834
1856
|
phase: state.phase
|
|
1835
1857
|
});
|
|
1836
1858
|
const view = resolveHeadlessBookingView({
|
|
1837
|
-
form:
|
|
1859
|
+
form: runtimeForm,
|
|
1838
1860
|
feedback: state.feedback
|
|
1839
1861
|
});
|
|
1840
1862
|
const appointmentPackagesModel = resolveAppointmentPackagesModel({
|
|
@@ -2608,7 +2630,11 @@ function DefaultDynamicField({ booking, field }) {
|
|
|
2608
2630
|
return /* @__PURE__ */ jsxs("div", {
|
|
2609
2631
|
className: "rb-space-y-2",
|
|
2610
2632
|
children: [
|
|
2611
|
-
/* @__PURE__ */
|
|
2633
|
+
field.field.type === "booking_requirement_consent" ? /* @__PURE__ */ jsx(BookingConsentAgreement, {
|
|
2634
|
+
agreement: field.field.agreement,
|
|
2635
|
+
title: field.label,
|
|
2636
|
+
titleId: field.labelId
|
|
2637
|
+
}) : /* @__PURE__ */ jsxs("label", {
|
|
2612
2638
|
id: field.labelId,
|
|
2613
2639
|
htmlFor: field.inputId,
|
|
2614
2640
|
className: "form-label",
|
|
@@ -2653,7 +2679,7 @@ function DefaultFieldInput({ describedBy, error, errorId, field, onBlur, onChang
|
|
|
2653
2679
|
required: field.required,
|
|
2654
2680
|
...validationProps
|
|
2655
2681
|
};
|
|
2656
|
-
switch (field.type) {
|
|
2682
|
+
switch (field.field.type) {
|
|
2657
2683
|
case "textarea": return /* @__PURE__ */ jsx("textarea", {
|
|
2658
2684
|
...commonProps,
|
|
2659
2685
|
value: strValue,
|
|
@@ -2767,7 +2793,7 @@ function DefaultFieldInput({ describedBy, error, errorId, field, onBlur, onChang
|
|
|
2767
2793
|
className: "form-checkbox rb-mt-0.5"
|
|
2768
2794
|
}), /* @__PURE__ */ jsx("span", {
|
|
2769
2795
|
className: "rb-caption",
|
|
2770
|
-
children: field.field.
|
|
2796
|
+
children: field.field.checkboxLabel
|
|
2771
2797
|
})]
|
|
2772
2798
|
});
|
|
2773
2799
|
case "number": return /* @__PURE__ */ jsx("input", {
|
|
@@ -2836,10 +2862,10 @@ function DefaultBookingDiscount({ booking }) {
|
|
|
2836
2862
|
children: /* @__PURE__ */ jsxs("p", {
|
|
2837
2863
|
className: "ab-text",
|
|
2838
2864
|
children: [
|
|
2839
|
-
"Discount available:
|
|
2840
|
-
booking.discount.autoAppliedDiscount.publicLabel,
|
|
2865
|
+
"Discount available:",
|
|
2841
2866
|
" ",
|
|
2842
|
-
|
|
2867
|
+
booking.discount.autoAppliedDiscount.publicLabel,
|
|
2868
|
+
" will apply automatically at checkout."
|
|
2843
2869
|
]
|
|
2844
2870
|
})
|
|
2845
2871
|
}) : null]
|