@wix/headless-bookings 0.0.104 → 0.0.106

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/cjs/dist/__mocks__/booking/booking-client-service.js +25 -20
  2. package/cjs/dist/__mocks__/booking/booking-mocks.js +28 -20
  3. package/cjs/dist/__mocks__/payment/payment-mocks.js +6 -3
  4. package/cjs/dist/__mocks__/services/services-mocks.js +79 -74
  5. package/cjs/dist/__mocks__/time-slots/time-slots-client-service.js +39 -33
  6. package/cjs/dist/__mocks__/time-slots/time-slots-core.js +43 -33
  7. package/cjs/dist/__mocks__/time-slots/time-slots-mocks.js +18 -13
  8. package/cjs/dist/api/create-booking/index.js +6 -3
  9. package/cjs/dist/api/create-checkout/index.js +9 -4
  10. package/cjs/dist/api/create-order/index.js +6 -3
  11. package/cjs/dist/api/fetch-availability/index.js +18 -15
  12. package/cjs/dist/api/index.js +24 -7
  13. package/cjs/dist/api/query-categories/index.js +6 -3
  14. package/cjs/dist/api/query-locations/index.js +9 -5
  15. package/cjs/dist/api/query-services/index.js +24 -17
  16. package/cjs/dist/react/booking/Book.js +51 -12
  17. package/cjs/dist/react/booking/Booking.js +68 -26
  18. package/cjs/dist/react/booking/BookingItem.d.ts +2 -0
  19. package/cjs/dist/react/booking/BookingItem.js +57 -16
  20. package/cjs/dist/react/booking-form/BookingForm.js +63 -21
  21. package/cjs/dist/react/core/booking/Book.js +14 -11
  22. package/cjs/dist/react/core/booking/Booking.d.ts +3 -1
  23. package/cjs/dist/react/core/booking/Booking.js +38 -25
  24. package/cjs/dist/react/core/booking-form/BookingForm.js +63 -26
  25. package/cjs/dist/react/core/location/Location.js +60 -21
  26. package/cjs/dist/react/core/location-list/LocationList.js +15 -10
  27. package/cjs/dist/react/core/payment/Payment.js +41 -30
  28. package/cjs/dist/react/core/service/Service.js +28 -19
  29. package/cjs/dist/react/core/service/ServiceMediaCover.js +7 -4
  30. package/cjs/dist/react/core/service/ServiceMediaGallery.js +7 -4
  31. package/cjs/dist/react/core/service/ServiceMediaMain.js +7 -4
  32. package/cjs/dist/react/core/service-list/ServiceList.js +12 -8
  33. package/cjs/dist/react/core/service-list/ServiceListFilter.js +9 -6
  34. package/cjs/dist/react/core/staff-member/StaffMember.js +20 -14
  35. package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +19 -14
  36. package/cjs/dist/react/core/time-slot-list/TimeSlot.js +41 -28
  37. package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +21 -15
  38. package/cjs/dist/react/index.js +49 -13
  39. package/cjs/dist/react/location/Location.js +76 -36
  40. package/cjs/dist/react/location/LocationList.js +70 -31
  41. package/cjs/dist/react/payment/Payment.js +87 -48
  42. package/cjs/dist/react/service/Service.js +197 -158
  43. package/cjs/dist/react/service/ServiceMedia.js +56 -17
  44. package/cjs/dist/react/service-list/ServiceList.js +71 -32
  45. package/cjs/dist/react/staff-member/StaffMember.js +61 -20
  46. package/cjs/dist/react/staff-member/StaffMemberList.js +68 -29
  47. package/cjs/dist/react/time-slot-list/TimeSlot.js +95 -56
  48. package/cjs/dist/react/time-slot-list/TimeSlotList.js +87 -48
  49. package/cjs/dist/services/booking/book-action/bookAction.js +21 -18
  50. package/cjs/dist/services/booking/book-action/buildBookingRequest.js +18 -15
  51. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +8 -5
  52. package/cjs/dist/services/booking/book-action/canBook.js +4 -1
  53. package/cjs/dist/services/booking/book-action/index.js +15 -6
  54. package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +4 -1
  55. package/cjs/dist/services/booking/book-action/types.js +5 -2
  56. package/cjs/dist/services/booking/booking.js +11 -8
  57. package/cjs/dist/services/booking-form/booking-form.js +26 -18
  58. package/cjs/dist/services/booking-form/utils.js +10 -4
  59. package/cjs/dist/services/constants.js +6 -3
  60. package/cjs/dist/services/index.js +48 -10
  61. package/cjs/dist/services/location-list/location-list.def.js +7 -5
  62. package/cjs/dist/services/location-list/location-list.js +31 -23
  63. package/cjs/dist/services/payment/payment.def.js +5 -2
  64. package/cjs/dist/services/payment/payment.js +22 -17
  65. package/cjs/dist/services/service/service.js +33 -29
  66. package/cjs/dist/services/service-list/service-list.js +22 -18
  67. package/cjs/dist/services/staff-member-list/staff-member-list.def.js +5 -2
  68. package/cjs/dist/services/staff-member-list/staff-member-list.js +16 -10
  69. package/cjs/dist/services/time-slot-list/index.js +12 -3
  70. package/cjs/dist/services/time-slot-list/time-slot-list.def.js +8 -5
  71. package/cjs/dist/services/time-slot-list/time-slot-list.js +24 -19
  72. package/cjs/dist/services/time-slot-list/time-slot.js +9 -6
  73. package/cjs/dist/utils/dateAndTime.js +7 -2
  74. package/cjs/dist/utils/guid.js +4 -1
  75. package/cjs/dist/utils/index.js +5 -1
  76. package/cjs/dist/utils/money.js +6 -2
  77. package/cjs/dist/utils/navigation.js +6 -3
  78. package/dist/react/booking/BookingItem.d.ts +2 -0
  79. package/dist/react/booking/BookingItem.js +2 -2
  80. package/dist/react/core/booking/Booking.d.ts +3 -1
  81. package/dist/react/core/booking/Booking.js +3 -2
  82. package/package.json +3 -3
@@ -1,12 +1,15 @@
1
+ "use strict";
1
2
  /**
2
3
  * Core Book - Provides book action data via render props
3
4
  * NO AsChildSlot, NO asChild - that belongs in high-level component
4
5
  */
5
- import { useState } from 'react';
6
- import { useService } from '@wix/services-manager-react';
7
- import { BookingServiceDefinition } from '../../../services/booking/booking.js';
8
- import { canBook } from '../../../services/booking/book-action/canBook.js';
9
- import { BookResultType, } from '../../../services/booking/book-action/types.js';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.Book = Book;
8
+ const react_1 = require("react");
9
+ const services_manager_react_1 = require("@wix/services-manager-react");
10
+ const booking_js_1 = require("../../../services/booking/booking.js");
11
+ const canBook_js_1 = require("../../../services/booking/book-action/canBook.js");
12
+ const types_js_1 = require("../../../services/booking/book-action/types.js");
10
13
  /**
11
14
  * Core Book component - provides book action data via render props.
12
15
  * Used internally by higher-level Booking.Actions.Book component.
@@ -35,20 +38,20 @@ import { BookResultType, } from '../../../services/booking/book-action/types.js'
35
38
  * </Book>
36
39
  * ```
37
40
  */
38
- export function Book(props) {
41
+ function Book(props) {
39
42
  const { children, onCheckout, onComplete, onError, disabled } = props;
40
- const [isLoading, setIsLoading] = useState(false);
41
- const [error, setError] = useState(null);
42
- const bookingService = useService(BookingServiceDefinition);
43
+ const [isLoading, setIsLoading] = (0, react_1.useState)(false);
44
+ const [error, setError] = (0, react_1.useState)(null);
45
+ const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
43
46
  const serviceSelections = bookingService.serviceSelections.get();
44
47
  const formSubmission = bookingService.formSubmission.get();
45
- const canBookValue = canBook({ serviceSelections, formSubmission });
48
+ const canBookValue = (0, canBook_js_1.canBook)({ serviceSelections, formSubmission });
46
49
  const handleClick = async () => {
47
50
  setIsLoading(true);
48
51
  setError(null);
49
52
  try {
50
53
  const result = await bookingService.actions.book();
51
- if (result.type === BookResultType.CheckoutRequired) {
54
+ if (result.type === types_js_1.BookResultType.CheckoutRequired) {
52
55
  await onCheckout?.({ checkoutId: result.checkoutId });
53
56
  }
54
57
  else {
@@ -98,12 +98,14 @@ export declare function BookingItemProvider(props: BookingItemProviderProps): Re
98
98
  * Props for BookingItemInfo render prop component
99
99
  */
100
100
  export interface BookingItemInfoProps {
101
+ /** Label to display when no specific staff member is assigned */
102
+ anyStaffLabel?: string;
101
103
  children: (data: {
102
104
  /** SDK Service object */
103
105
  service: Service;
104
106
  /** Adapted SDK TimeSlot (or null if no time slot selected) */
105
107
  timeSlot: TimeSlot | null;
106
- /** First staff member's name, empty string if none */
108
+ /** First staff member's name, or anyStaffLabel if none */
107
109
  staffName: string;
108
110
  /** Unique identifier for this booking instance */
109
111
  instanceId: string;
@@ -1,13 +1,25 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Root = Root;
7
+ exports.Data = Data;
8
+ exports.useBookingItemContext = useBookingItemContext;
9
+ exports.BookingItemProvider = BookingItemProvider;
10
+ exports.BookingItemInfo = BookingItemInfo;
11
+ exports.ItemsData = ItemsData;
12
+ exports.PaymentData = PaymentData;
13
+ const jsx_runtime_1 = require("react/jsx-runtime");
2
14
  /**
3
15
  * Core Booking Components
4
16
  * Provides low-level access to BookingService via render props and service setup
5
17
  */
6
- import React from 'react';
7
- import { WixServices, useService } from '@wix/services-manager-react';
8
- import { createServicesMap } from '@wix/services-manager';
9
- import { BookingServiceDefinition, BookingService, } from '../../../services/booking/booking.js';
10
- import { LocationType, } from '@wix/auto_sdk_bookings_services';
18
+ const react_1 = __importDefault(require("react"));
19
+ const services_manager_react_1 = require("@wix/services-manager-react");
20
+ const services_manager_1 = require("@wix/services-manager");
21
+ const booking_js_1 = require("../../../services/booking/booking.js");
22
+ const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
11
23
  /**
12
24
  * Root component that provides booking context to the entire app.
13
25
  *
@@ -23,9 +35,9 @@ import { LocationType, } from '@wix/auto_sdk_bookings_services';
23
35
  * </Booking.Root>
24
36
  * ```
25
37
  */
26
- export function Root(props) {
38
+ function Root(props) {
27
39
  const { bookingServiceConfig = {}, children } = props;
28
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(BookingServiceDefinition, BookingService, bookingServiceConfig), disposeOnUnmount: true, children: children }));
40
+ return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(booking_js_1.BookingServiceDefinition, booking_js_1.BookingService, bookingServiceConfig), disposeOnUnmount: true, children: children }));
29
41
  }
30
42
  /**
31
43
  * Core component that provides access to booking data via render props.
@@ -66,9 +78,9 @@ function mapTimeSlotLocationToServiceLocation(timeSlotLocation) {
66
78
  return {
67
79
  _id: timeSlotLocation._id ?? undefined,
68
80
  type: locationType,
69
- ...(locationType === LocationType.CUSTOMER
81
+ ...(locationType === auto_sdk_bookings_services_1.LocationType.CUSTOMER
70
82
  ? null
71
- : locationType === LocationType.CUSTOM
83
+ : locationType === auto_sdk_bookings_services_1.LocationType.CUSTOM
72
84
  ? { custom: location }
73
85
  : { business: location }),
74
86
  };
@@ -79,7 +91,7 @@ function mapTimeSlotLocationToServiceLocation(timeSlotLocation) {
79
91
  * 2. If not set, fall back to the first service selection's slot location
80
92
  */
81
93
  function resolveLocation(bookingLocation, serviceSelections) {
82
- if (bookingLocation && bookingLocation.type === LocationType.BUSINESS) {
94
+ if (bookingLocation && bookingLocation.type === auto_sdk_bookings_services_1.LocationType.BUSINESS) {
83
95
  return bookingLocation;
84
96
  }
85
97
  // Fallback to first slot's location
@@ -89,9 +101,9 @@ function resolveLocation(bookingLocation, serviceSelections) {
89
101
  }
90
102
  return null;
91
103
  }
92
- export function Data(props) {
104
+ function Data(props) {
93
105
  const { children } = props;
94
- const bookingService = useService(BookingServiceDefinition);
106
+ const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
95
107
  const serviceSelections = bookingService.serviceSelections.get();
96
108
  const bookingLocation = bookingService.location.get();
97
109
  const timezone = bookingService.timezone.get();
@@ -109,15 +121,15 @@ export function Data(props) {
109
121
  /**
110
122
  * Context for the current BookingItem
111
123
  */
112
- const BookingItemContext = React.createContext(null);
124
+ const BookingItemContext = react_1.default.createContext(null);
113
125
  /**
114
126
  * Hook to access the current BookingItem from context.
115
127
  * Must be used within BookingItemProvider.
116
128
  *
117
129
  * @throws Error if used outside of BookingItemProvider context
118
130
  */
119
- export function useBookingItemContext() {
120
- const context = React.useContext(BookingItemContext);
131
+ function useBookingItemContext() {
132
+ const context = react_1.default.useContext(BookingItemContext);
121
133
  if (!context) {
122
134
  throw new Error('BookingItem components must be used within BookingItemProvider');
123
135
  }
@@ -137,9 +149,9 @@ export function useBookingItemContext() {
137
149
  * ))}
138
150
  * ```
139
151
  */
140
- export function BookingItemProvider(props) {
152
+ function BookingItemProvider(props) {
141
153
  const { children, item } = props;
142
- return (_jsx(BookingItemContext.Provider, { value: item, children: children }));
154
+ return ((0, jsx_runtime_1.jsx)(BookingItemContext.Provider, { value: item, children: children }));
143
155
  }
144
156
  /**
145
157
  * Core component that provides access to booking item info via render props.
@@ -158,10 +170,11 @@ export function BookingItemProvider(props) {
158
170
  * </BookingItemInfo>
159
171
  * ```
160
172
  */
161
- export function BookingItemInfo(props) {
173
+ function BookingItemInfo(props) {
174
+ const { anyStaffLabel = '', children } = props;
162
175
  const item = useBookingItemContext();
163
- const staffName = item.staff?.[0]?.name || '';
164
- return props.children({
176
+ const staffName = item.staff?.[0]?.name || anyStaffLabel;
177
+ return children({
165
178
  service: item.service,
166
179
  timeSlot: item.timeSlot,
167
180
  staffName,
@@ -247,9 +260,9 @@ function createBookingItem(serviceSelection, index) {
247
260
  * </Booking.ItemsData>
248
261
  * ```
249
262
  */
250
- export function ItemsData(props) {
263
+ function ItemsData(props) {
251
264
  const { children } = props;
252
- const bookingService = useService(BookingServiceDefinition);
265
+ const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
253
266
  const serviceSelections = bookingService.serviceSelections.get();
254
267
  const items = serviceSelections.map((selection, index) => createBookingItem(selection, index));
255
268
  return children({ items });
@@ -270,9 +283,9 @@ export function ItemsData(props) {
270
283
  * </Booking.PaymentData>
271
284
  * ```
272
285
  */
273
- export function PaymentData(props) {
286
+ function PaymentData(props) {
274
287
  const { children } = props;
275
- const bookingService = useService(BookingServiceDefinition);
288
+ const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
276
289
  const serviceSelections = bookingService.serviceSelections.get();
277
290
  const pricingServiceSelections = serviceSelections.map((selection) => ({
278
291
  service: selection.service,
@@ -1,4 +1,42 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BookingFormConfigurationError = exports.LoadError = void 0;
37
+ exports.Root = Root;
38
+ exports.isBookingFormConfigurationError = isBookingFormConfigurationError;
39
+ const jsx_runtime_1 = require("react/jsx-runtime");
2
40
  /**
3
41
  * Core BookingForm Component
4
42
  *
@@ -9,15 +47,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
9
47
  * 1. Client-side: Provide formId to load the form dynamically
10
48
  * 2. SSR/SSG: Provide a pre-loaded form object for server-side rendering
11
49
  */
12
- import * as React from 'react';
13
- import { useRef, useCallback } from 'react';
14
- import { WixServices, useService } from '@wix/services-manager-react';
15
- import { createServicesMap } from '@wix/services-manager';
16
- import { BookingFormServiceDefinition, BookingFormService, BookingFormConfigurationError, } from '../../../services/booking-form/booking-form.js';
17
- import { BookingServiceDefinition } from '../../../services/booking/booking.js';
18
- import { Form } from '@wix/headless-forms/react';
19
- import { FormServiceDefinition } from '@wix/headless-forms/services';
20
- import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
50
+ const React = __importStar(require("react"));
51
+ const react_1 = require("react");
52
+ const services_manager_react_1 = require("@wix/services-manager-react");
53
+ const services_manager_1 = require("@wix/services-manager");
54
+ const booking_form_js_1 = require("../../../services/booking-form/booking-form.js");
55
+ Object.defineProperty(exports, "BookingFormConfigurationError", { enumerable: true, get: function () { return booking_form_js_1.BookingFormConfigurationError; } });
56
+ const booking_js_1 = require("../../../services/booking/booking.js");
57
+ const react_2 = require("@wix/headless-forms/react");
58
+ const services_1 = require("@wix/headless-forms/services");
59
+ const signals_1 = require("@wix/services-definitions/core-services/signals");
21
60
  // ============================================================================
22
61
  // Component
23
62
  // ============================================================================
@@ -89,10 +128,10 @@ import { SignalsServiceDefinition } from '@wix/services-definitions/core-service
89
128
  * </CoreBookingForm.Root>
90
129
  * ```
91
130
  */
92
- export function Root(props) {
131
+ function Root(props) {
93
132
  const { serviceIds, additionalMetadata, fieldMap, children } = props;
94
133
  // Create formRef to pass to Form.Root and BookingFormContent
95
- const formRef = useRef(null);
134
+ const formRef = (0, react_1.useRef)(null);
96
135
  const bookingFormServiceConfig = props.form
97
136
  ? { form: props.form }
98
137
  : props.formId
@@ -100,15 +139,15 @@ export function Root(props) {
100
139
  : undefined;
101
140
  // Use Form.Root to set up FormService, then nest WixServices for BookingFormService
102
141
  // This allows BookingFormService to access FormService via getService internally
103
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(BookingFormServiceDefinition, BookingFormService, bookingFormServiceConfig), disposeOnUnmount: true, children: _jsx(FormWrapper, { formRef: formRef, children: _jsx(BookingFormContent, { fields: fieldMap, formRef: formRef, children: children }) }) }));
142
+ return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(booking_form_js_1.BookingFormServiceDefinition, booking_form_js_1.BookingFormService, bookingFormServiceConfig), disposeOnUnmount: true, children: (0, jsx_runtime_1.jsx)(FormWrapper, { formRef: formRef, children: (0, jsx_runtime_1.jsx)(BookingFormContent, { fields: fieldMap, formRef: formRef, children: children }) }) }));
104
143
  }
105
144
  function FormWrapper({ children, formRef, }) {
106
- const bookingFormService = useService(BookingFormServiceDefinition);
145
+ const bookingFormService = (0, services_manager_react_1.useService)(booking_form_js_1.BookingFormServiceDefinition);
107
146
  const formServiceConfig = bookingFormService.formServiceConfig.get();
108
147
  if (!formServiceConfig) {
109
148
  return null;
110
149
  }
111
- return (_jsx(Form.Root, { formServiceConfig: formServiceConfig, formRef: formRef, children: children }));
150
+ return ((0, jsx_runtime_1.jsx)(react_2.Form.Root, { formServiceConfig: formServiceConfig, formRef: formRef, children: children }));
112
151
  }
113
152
  /**
114
153
  * Internal component that consumes BookingFormService and provides render props.
@@ -126,7 +165,7 @@ function FormWrapper({ children, formRef, }) {
126
165
  * requires Booking.Root to be in the component tree.
127
166
  */
128
167
  function BookingFormContent({ fields, formRef, children, }) {
129
- const bookingFormService = useService(BookingFormServiceDefinition);
168
+ const bookingFormService = (0, services_manager_react_1.useService)(booking_form_js_1.BookingFormServiceDefinition);
130
169
  // Try to get BookingService from parent context (provided by Booking.Root)
131
170
  // Note: useService must be called unconditionally per React hooks rules.
132
171
  // If BookingService is not available, useService will throw an error.
@@ -134,11 +173,11 @@ function BookingFormContent({ fields, formRef, children, }) {
134
173
  // We use a wrapper component pattern to handle this gracefully.
135
174
  // For now, we'll always attempt to get it and let it throw if not available
136
175
  // The user should wrap BookingForm with Booking.Root when using Booking.Actions.Book
137
- const bookingService = useService(BookingServiceDefinition);
138
- const formService = useService(FormServiceDefinition);
139
- const signalsService = useService(SignalsServiceDefinition);
176
+ const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
177
+ const formService = (0, services_manager_react_1.useService)(services_1.FormServiceDefinition);
178
+ const signalsService = (0, services_manager_react_1.useService)(signals_1.SignalsServiceDefinition);
140
179
  // Create validateFormSubmission action that uses the form ref
141
- const validateFormSubmission = useCallback(() => {
180
+ const validateFormSubmission = (0, react_1.useCallback)(() => {
142
181
  return formRef.current?.validate() ?? Promise.resolve(false);
143
182
  }, []);
144
183
  const formValues = formService.formValuesSignal.get();
@@ -186,7 +225,7 @@ function BookingFormContent({ fields, formRef, children, }) {
186
225
  * </CoreBookingForm.LoadError>
187
226
  * ```
188
227
  */
189
- export const LoadError = React.forwardRef((props, ref) => {
228
+ exports.LoadError = React.forwardRef((props, ref) => {
190
229
  const { error, asChild, children, className, ...otherProps } = props;
191
230
  const errorData = { error, message: error.message };
192
231
  if (asChild && React.isValidElement(children)) {
@@ -199,13 +238,11 @@ export const LoadError = React.forwardRef((props, ref) => {
199
238
  ...otherProps,
200
239
  });
201
240
  }
202
- return (_jsx("div", { ref: ref, className: className, "data-testid": "booking-form-load-error", role: "alert", ...otherProps, children: children ?? error.message }));
241
+ return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: className, "data-testid": "booking-form-load-error", role: "alert", ...otherProps, children: children ?? error.message }));
203
242
  });
204
243
  /**
205
244
  * Type guard to check if an error is a BookingFormConfigurationError
206
245
  */
207
- export function isBookingFormConfigurationError(error) {
208
- return error instanceof BookingFormConfigurationError;
246
+ function isBookingFormConfigurationError(error) {
247
+ return error instanceof booking_form_js_1.BookingFormConfigurationError;
209
248
  }
210
- // Re-export the error class for convenience
211
- export { BookingFormConfigurationError };
@@ -1,4 +1,43 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useLocationContext = useLocationContext;
37
+ exports.Root = Root;
38
+ exports.Data = Data;
39
+ exports.Actions = Actions;
40
+ const jsx_runtime_1 = require("react/jsx-runtime");
2
41
  /**
3
42
  * Core Location Component - Parses service location data
4
43
  * Handles business, custom, and customer location types
@@ -6,11 +45,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
6
45
  *
7
46
  * @module Core/Location
8
47
  */
9
- import React, { createContext, useContext } from 'react';
10
- import { useService } from '@wix/services-manager-react';
11
- import { LocationType } from '@wix/auto_sdk_bookings_services';
12
- import { BookingServiceDefinition } from '../../../services/booking/booking.js';
13
- import { LocationListServiceDefinition } from '../../../services/location-list/location-list.def.js';
48
+ const react_1 = __importStar(require("react"));
49
+ const services_manager_react_1 = require("@wix/services-manager-react");
50
+ const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
51
+ const booking_js_1 = require("../../../services/booking/booking.js");
52
+ const location_list_def_js_1 = require("../../../services/location-list/location-list.def.js");
14
53
  // ==========================================
15
54
  // Constants
16
55
  // ==========================================
@@ -24,13 +63,13 @@ const DEFAULT_CUSTOMER_LABEL = "Client's Place";
24
63
  /**
25
64
  * Location context value - same as LocationRenderProps
26
65
  */
27
- const LocationContext = createContext(null);
66
+ const LocationContext = (0, react_1.createContext)(null);
28
67
  /**
29
68
  * Hook to access location context from CoreLocation.Root
30
69
  * @throws Error if used outside of CoreLocation.Root
31
70
  */
32
- export function useLocationContext() {
33
- const context = useContext(LocationContext);
71
+ function useLocationContext() {
72
+ const context = (0, react_1.useContext)(LocationContext);
34
73
  if (!context) {
35
74
  throw new Error('useLocationContext must be used within a CoreLocation.Root component');
36
75
  }
@@ -51,7 +90,7 @@ function hasLocationData(location) {
51
90
  */
52
91
  function parseLocationAddress(location) {
53
92
  // Handle customer location - return null, let consumer handle
54
- if (location.type !== LocationType.BUSINESS) {
93
+ if (location.type !== auto_sdk_bookings_services_1.LocationType.BUSINESS) {
55
94
  return null;
56
95
  }
57
96
  // Get the common address from the appropriate location type
@@ -84,7 +123,7 @@ function parseLocationAddress(location) {
84
123
  * Get location type from location data
85
124
  */
86
125
  function getLocationType(location) {
87
- return location.type || LocationType.BUSINESS;
126
+ return location.type || auto_sdk_bookings_services_1.LocationType.BUSINESS;
88
127
  }
89
128
  /**
90
129
  * Computes LocationRenderProps from location with label fallbacks
@@ -93,7 +132,7 @@ function computeLocationRenderProps(rawLocation, labels) {
93
132
  // Handle no location
94
133
  if (!rawLocation) {
95
134
  return {
96
- locationType: LocationType.BUSINESS,
135
+ locationType: auto_sdk_bookings_services_1.LocationType.BUSINESS,
97
136
  address: null,
98
137
  name: undefined,
99
138
  locationId: undefined,
@@ -107,8 +146,8 @@ function computeLocationRenderProps(rawLocation, labels) {
107
146
  }
108
147
  const locationType = getLocationType(rawLocation);
109
148
  const hasData = hasLocationData(rawLocation);
110
- const isCustomLocation = locationType === LocationType.CUSTOM;
111
- const isCustomerLocation = locationType === LocationType.CUSTOMER;
149
+ const isCustomLocation = locationType === auto_sdk_bookings_services_1.LocationType.CUSTOM;
150
+ const isCustomerLocation = locationType === auto_sdk_bookings_services_1.LocationType.CUSTOMER;
112
151
  // Compute name with fallback chain:
113
152
  // 1. business.name
114
153
  // 2. custom.address.addressLine
@@ -156,13 +195,13 @@ function computeLocationRenderProps(rawLocation, labels) {
156
195
  * </CoreLocation.Root>
157
196
  * ```
158
197
  */
159
- export function Root(props) {
198
+ function Root(props) {
160
199
  const { location, children } = props;
161
200
  // Try to get LocationListService for labels - it's optional (Location can be standalone)
162
201
  let locationListService = null;
163
202
  try {
164
203
  // eslint-disable-next-line react-hooks/rules-of-hooks
165
- locationListService = useService(LocationListServiceDefinition);
204
+ locationListService = (0, services_manager_react_1.useService)(location_list_def_js_1.LocationListServiceDefinition);
166
205
  }
167
206
  catch {
168
207
  // LocationListService not available - using defaults
@@ -174,7 +213,7 @@ export function Root(props) {
174
213
  customerLocationLabel: locationListService?.customerLocationLabel.get(),
175
214
  };
176
215
  const renderProps = computeLocationRenderProps(location, labels);
177
- return (_jsx(LocationContext.Provider, { value: renderProps, children: children }));
216
+ return ((0, jsx_runtime_1.jsx)(LocationContext.Provider, { value: renderProps, children: children }));
178
217
  }
179
218
  // ==========================================
180
219
  // Data Component (Render Props)
@@ -198,7 +237,7 @@ export function Root(props) {
198
237
  * </CoreLocation.Root>
199
238
  * ```
200
239
  */
201
- export function Data(props) {
240
+ function Data(props) {
202
241
  const context = useLocationContext();
203
242
  return props.children(context);
204
243
  }
@@ -220,19 +259,19 @@ export function Data(props) {
220
259
  * </CoreLocation.Root>
221
260
  * ```
222
261
  */
223
- export function Actions(props) {
262
+ function Actions(props) {
224
263
  const { rawLocation } = useLocationContext();
225
264
  // Try to get BookingService for setting location
226
265
  let bookingService = null;
227
266
  try {
228
267
  // eslint-disable-next-line react-hooks/rules-of-hooks
229
- bookingService = useService(BookingServiceDefinition);
268
+ bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
230
269
  }
231
270
  catch {
232
271
  bookingService = null;
233
272
  }
234
273
  // Compute selected state from BookingService
235
- const selected = React.useMemo(() => {
274
+ const selected = react_1.default.useMemo(() => {
236
275
  if (!bookingService || !rawLocation)
237
276
  return false;
238
277
  const currentLocation = bookingService.location.get();
@@ -1,7 +1,12 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { WixServices, useService } from '@wix/services-manager-react';
3
- import { createServicesMap } from '@wix/services-manager';
4
- import { LocationListServiceDefinition, LocationListService, } from '../../../services/location-list/location-list.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Root = Root;
4
+ exports.Locations = Locations;
5
+ exports.Actions = Actions;
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const services_manager_react_1 = require("@wix/services-manager-react");
8
+ const services_manager_1 = require("@wix/services-manager");
9
+ const location_list_js_1 = require("../../../services/location-list/location-list.js");
5
10
  /**
6
11
  * Root component that provides LocationList service context
7
12
  *
@@ -17,8 +22,8 @@ import { LocationListServiceDefinition, LocationListService, } from '../../../se
17
22
  * </CoreLocationList.Root>
18
23
  * ```
19
24
  */
20
- export function Root(props) {
21
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(LocationListServiceDefinition, LocationListService, props.locationListServiceConfig), disposeOnUnmount: true, children: props.children }));
25
+ function Root(props) {
26
+ return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(location_list_js_1.LocationListServiceDefinition, location_list_js_1.LocationListService, props.locationListServiceConfig), disposeOnUnmount: true, children: props.children }));
22
27
  }
23
28
  /**
24
29
  * Core component that provides access to locations list via render props
@@ -33,8 +38,8 @@ export function Root(props) {
33
38
  * </CoreLocationList.Locations>
34
39
  * ```
35
40
  */
36
- export function Locations(props) {
37
- const service = useService(LocationListServiceDefinition);
41
+ function Locations(props) {
42
+ const service = (0, services_manager_react_1.useService)(location_list_js_1.LocationListServiceDefinition);
38
43
  const locations = service.locations.get();
39
44
  const displayLocations = service.displayLocations.get();
40
45
  return props.children({
@@ -62,8 +67,8 @@ export function Locations(props) {
62
67
  * </CoreLocationList.Actions>
63
68
  * ```
64
69
  */
65
- export function Actions(props) {
66
- const service = useService(LocationListServiceDefinition);
70
+ function Actions(props) {
71
+ const service = (0, services_manager_react_1.useService)(location_list_js_1.LocationListServiceDefinition);
67
72
  return props.children({
68
73
  select: service.actions.select,
69
74
  selectedLocation: service.selectedLocation.get(),