@wix/headless-bookings 0.0.61 → 0.0.63

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 (65) hide show
  1. package/cjs/dist/__mocks__/time-slots.js +1 -0
  2. package/cjs/dist/api/index.d.ts +2 -2
  3. package/cjs/dist/api/index.js +2 -2
  4. package/cjs/dist/api/query-locations/index.d.ts +14 -0
  5. package/cjs/dist/api/query-locations/index.js +27 -0
  6. package/cjs/dist/api/query-services/index.d.ts +5 -0
  7. package/cjs/dist/api/query-services/index.js +2 -2
  8. package/cjs/dist/react/booking/Book.d.ts +2 -0
  9. package/cjs/dist/react/booking/Book.js +11 -1
  10. package/cjs/dist/react/core/location/Location.d.ts +2 -0
  11. package/cjs/dist/react/core/location/Location.js +14 -1
  12. package/cjs/dist/react/core/time-slot-list/TimeSlot.js +0 -2
  13. package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +47 -3
  14. package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +60 -5
  15. package/cjs/dist/react/index.d.ts +0 -1
  16. package/cjs/dist/react/index.js +1 -1
  17. package/cjs/dist/react/location/Location.d.ts +4 -0
  18. package/cjs/dist/react/location/Location.js +20 -2
  19. package/cjs/dist/react/location/LocationList.d.ts +4 -0
  20. package/cjs/dist/react/location/LocationList.js +33 -7
  21. package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +30 -7
  22. package/cjs/dist/react/time-slot-list/TimeSlotList.js +27 -8
  23. package/cjs/dist/services/index.d.ts +2 -1
  24. package/cjs/dist/services/index.js +2 -1
  25. package/cjs/dist/services/location-list/location-list.d.ts +1 -0
  26. package/cjs/dist/services/location-list/location-list.js +3 -2
  27. package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +1 -0
  28. package/cjs/dist/services/time-slot-list/time-slot-list.js +2 -9
  29. package/cjs/dist/utils/index.d.ts +5 -0
  30. package/cjs/dist/utils/index.js +5 -0
  31. package/cjs/dist/utils/navigation.d.ts +7 -0
  32. package/cjs/dist/utils/navigation.js +75 -0
  33. package/dist/__mocks__/time-slots.js +1 -0
  34. package/dist/api/index.d.ts +2 -2
  35. package/dist/api/index.js +2 -2
  36. package/dist/api/query-locations/index.d.ts +14 -0
  37. package/dist/api/query-locations/index.js +27 -0
  38. package/dist/api/query-services/index.d.ts +5 -0
  39. package/dist/api/query-services/index.js +2 -2
  40. package/dist/react/booking/Book.d.ts +2 -0
  41. package/dist/react/booking/Book.js +11 -1
  42. package/dist/react/core/location/Location.d.ts +2 -0
  43. package/dist/react/core/location/Location.js +14 -1
  44. package/dist/react/core/time-slot-list/TimeSlot.js +0 -2
  45. package/dist/react/core/time-slot-list/TimeSlotList.d.ts +47 -3
  46. package/dist/react/core/time-slot-list/TimeSlotList.js +60 -5
  47. package/dist/react/index.d.ts +0 -1
  48. package/dist/react/index.js +1 -1
  49. package/dist/react/location/Location.d.ts +4 -0
  50. package/dist/react/location/Location.js +20 -2
  51. package/dist/react/location/LocationList.d.ts +4 -0
  52. package/dist/react/location/LocationList.js +33 -7
  53. package/dist/react/time-slot-list/TimeSlotList.d.ts +30 -7
  54. package/dist/react/time-slot-list/TimeSlotList.js +27 -8
  55. package/dist/services/index.d.ts +2 -1
  56. package/dist/services/index.js +2 -1
  57. package/dist/services/location-list/location-list.d.ts +1 -0
  58. package/dist/services/location-list/location-list.js +3 -2
  59. package/dist/services/time-slot-list/time-slot-list.def.d.ts +1 -0
  60. package/dist/services/time-slot-list/time-slot-list.js +2 -9
  61. package/dist/utils/index.d.ts +5 -0
  62. package/dist/utils/index.js +5 -0
  63. package/dist/utils/navigation.d.ts +7 -0
  64. package/dist/utils/navigation.js +75 -0
  65. package/package.json +2 -2
@@ -112,5 +112,6 @@ export function createMockTimeSlotListService(config = {}) {
112
112
  dateRangeSignal.set({ start, end });
113
113
  }),
114
114
  },
115
+ dispose: vi.fn(),
115
116
  };
116
117
  }
@@ -4,12 +4,12 @@
4
4
  *
5
5
  * @module API
6
6
  */
7
- export { getServiceById, getServiceBySlug, queryServices, type PagingMetadata, type ServiceListFilters, type QueryServicesRequest, } from './query-services/index.js';
7
+ export { getServiceById, getServiceBySlug, queryServices, type PagingMetadata, type ServiceListFilters, type QueryServicesRequest, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
8
8
  export { fetchAvailability } from './fetch-availability/index.js';
9
9
  export { createBooking, type CreateBookingOptions, type Booking, type CreateBookingRequest, type CreateBookingResponse, type ParticipantNotification, type ContactDetails, } from './create-booking/index.js';
10
10
  export { createCheckout, ChannelType, type CreateCheckoutRequest, type CreateCheckoutResponse, } from './create-checkout/index.js';
11
11
  export { createOrder, type CreateOrderOptions, type CreateOrderResponse, } from './create-order/index.js';
12
- export { queryLocations, type QueryLocationsResult, type LocationData, } from './query-locations/index.js';
12
+ export { queryLocations, getLocationById, type QueryLocationsResult, type LocationData, } from './query-locations/index.js';
13
13
  export { queryCategories, type QueryCategoriesResult, type Category, } from './query-categories/index.js';
14
14
  /**
15
15
  * PagingMetadata includes:
@@ -4,12 +4,12 @@
4
4
  *
5
5
  * @module API
6
6
  */
7
- export { getServiceById, getServiceBySlug, queryServices, } from './query-services/index.js';
7
+ export { getServiceById, getServiceBySlug, queryServices, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
8
8
  export { fetchAvailability } from './fetch-availability/index.js';
9
9
  export { createBooking, } from './create-booking/index.js';
10
10
  export { createCheckout, ChannelType, } from './create-checkout/index.js';
11
11
  export { createOrder, } from './create-order/index.js';
12
- export { queryLocations, } from './query-locations/index.js';
12
+ export { queryLocations, getLocationById, } from './query-locations/index.js';
13
13
  export { queryCategories, } from './query-categories/index.js';
14
14
  /**
15
15
  * PagingMetadata includes:
@@ -36,3 +36,17 @@ export interface QueryLocationsResult {
36
36
  * ```
37
37
  */
38
38
  export declare function queryLocations(): Promise<QueryLocationsResult>;
39
+ /**
40
+ * Fetches a single location by its business location ID
41
+ * @param locationId - The business location ID (GUID)
42
+ * @returns Promise resolving to the location or null if not found
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const location = await getLocationById('12345678-1234-1234-1234-123456789012');
47
+ * if (location) {
48
+ * console.log(location.business?.name);
49
+ * }
50
+ * ```
51
+ */
52
+ export declare function getLocationById(locationId: string): Promise<LocationData | null>;
@@ -28,3 +28,30 @@ export async function queryLocations() {
28
28
  hasCustomerLocations: response.customerLocations?.exists || false,
29
29
  };
30
30
  }
31
+ /**
32
+ * Fetches a single location by its business location ID
33
+ * @param locationId - The business location ID (GUID)
34
+ * @returns Promise resolving to the location or null if not found
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const location = await getLocationById('12345678-1234-1234-1234-123456789012');
39
+ * if (location) {
40
+ * console.log(location.business?.name);
41
+ * }
42
+ * ```
43
+ */
44
+ export async function getLocationById(locationId) {
45
+ try {
46
+ const response = await queryLocationsApi({
47
+ filter: {
48
+ businessLocationIds: [locationId],
49
+ },
50
+ });
51
+ return response.businessLocations?.locations?.[0] ?? null;
52
+ }
53
+ catch (error) {
54
+ console.error(`Failed to load location for id "${locationId}":`, error);
55
+ return null;
56
+ }
57
+ }
@@ -3,6 +3,11 @@
3
3
  * Fetches single or multiple services with pagination and sorting
4
4
  */
5
5
  import { type Service, type Paging, type Sorting } from '@wix/auto_sdk_bookings_services';
6
+ /**
7
+ * Synthetic location ID constants for non-business locations
8
+ */
9
+ export declare const SYNTHETIC_CUSTOM_ID = "custom";
10
+ export declare const SYNTHETIC_CUSTOMER_ID = "customer";
6
11
  /**
7
12
  * Paging metadata from query services response.
8
13
  * Extends the SDK's Paging type with hasNext flag to indicate if more services are available.
@@ -10,8 +10,8 @@ const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
10
10
  /**
11
11
  * Synthetic location ID constants for non-business locations
12
12
  */
13
- const SYNTHETIC_CUSTOM_ID = '__synthetic_custom__';
14
- const SYNTHETIC_CUSTOMER_ID = '__synthetic_customer__';
13
+ export const SYNTHETIC_CUSTOM_ID = 'custom';
14
+ export const SYNTHETIC_CUSTOMER_ID = 'customer';
15
15
  /**
16
16
  * Fetches a service by its ID
17
17
  * @param id - The service ID
@@ -16,9 +16,11 @@ export interface BookProps {
16
16
  disabled?: boolean;
17
17
  onCheckout?: (result: {
18
18
  checkoutId: string;
19
+ navigateToCheckout: (checkoutId: string) => void;
19
20
  }) => void;
20
21
  onComplete?: (result: {
21
22
  orderId: string;
23
+ navigateToThankYou: (orderId: string) => void;
22
24
  }) => void;
23
25
  onError?: (error: BookingError) => void;
24
26
  }
@@ -6,6 +6,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
6
6
  import React from 'react';
7
7
  import { AsChildSlot } from '@wix/headless-utils/react';
8
8
  import * as CoreBook from '../core/booking/Book.js';
9
+ import { navigateToCheckout } from '../../utils/navigation.js';
9
10
  var TestIds;
10
11
  (function (TestIds) {
11
12
  TestIds["bookingActionBook"] = "booking-action-book";
@@ -49,6 +50,15 @@ var TestIds;
49
50
  */
50
51
  export const Book = React.forwardRef((props, ref) => {
51
52
  const { asChild, children, className, label = 'Book Now', loadingState = 'Booking...', disabled, onCheckout, onComplete, onError, } = props;
52
- return (_jsx(CoreBook.Book, { onCheckout: onCheckout, onComplete: onComplete, onError: onError, disabled: disabled, children: (childProps) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.bookingActionBook, "data-in-progress": childProps.isLoading, customElement: children, customElementProps: childProps, children: _jsx("button", { onClick: childProps.onClick, disabled: childProps.disabled, children: childProps.isLoading ? loadingState : label }) })) }));
53
+ return (_jsx(CoreBook.Book, { onCheckout: (result) => {
54
+ onCheckout?.({ ...result, navigateToCheckout });
55
+ }, onComplete: (result) => {
56
+ onComplete?.({
57
+ ...result,
58
+ navigateToThankYou: (orderId) => {
59
+ console.log('navigateToThankYou', orderId);
60
+ },
61
+ });
62
+ }, onError: onError, disabled: disabled, children: (childProps) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.bookingActionBook, "data-in-progress": childProps.isLoading, customElement: children, customElementProps: childProps, children: _jsx("button", { onClick: childProps.onClick, disabled: childProps.disabled, children: childProps.isLoading ? loadingState : label }) })) }));
53
63
  });
54
64
  Book.displayName = 'Booking.Actions.Book';
@@ -27,6 +27,8 @@ export interface SyntheticLocation {
27
27
  synthetic: true;
28
28
  /** Optional ID for tracking (matches ServiceLocation._id) */
29
29
  _id?: string;
30
+ /** Optional name/label for the location */
31
+ name?: string;
30
32
  }
31
33
  /**
32
34
  * Union type - location prop accepts Service or Synthetic location
@@ -106,10 +106,23 @@ function computeLocationRenderProps(rawLocation) {
106
106
  if (isSyntheticLocation(rawLocation)) {
107
107
  const syntheticLoc = rawLocation;
108
108
  const locationType = syntheticLoc.locationType;
109
+ // Use provided name or default based on location type
110
+ let name;
111
+ if (syntheticLoc.name) {
112
+ name = syntheticLoc.name;
113
+ }
114
+ else {
115
+ name =
116
+ locationType === LocationType.CUSTOM
117
+ ? 'Custom Locations'
118
+ : locationType === LocationType.CUSTOMER
119
+ ? "Client's Place"
120
+ : undefined;
121
+ }
109
122
  return {
110
123
  locationType,
111
124
  address: null,
112
- name: undefined,
125
+ name,
113
126
  locationId: syntheticLoc._id,
114
127
  isCustomerLocation: locationType === LocationType.CUSTOMER,
115
128
  isCustomLocation: locationType === LocationType.CUSTOM,
@@ -82,7 +82,6 @@ export function Info(props) {
82
82
  const endDate = new Date(timeSlot.localEndDate);
83
83
  const locationName = timeSlot.location?.name ?? '';
84
84
  const bookable = timeSlot.bookable ?? false;
85
- // Calculate duration from start and end dates
86
85
  const durationInMinutes = Math.round((endDate.getTime() - startDate.getTime()) / (1000 * 60));
87
86
  return props.children({
88
87
  startDate,
@@ -166,7 +165,6 @@ export function StaffMembers(props) {
166
165
  const bookingService = useService(BookingServiceDefinition);
167
166
  const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.timeSlot?.resources?.[0]?._id;
168
167
  const staffMembers = timeSlot.availableResources[0].resources;
169
- // Return null if only 1 staff member - nothing to choose from
170
168
  if (staffMembers.length <= 1) {
171
169
  return null;
172
170
  }
@@ -5,12 +5,49 @@
5
5
  import React from 'react';
6
6
  import { type TimeSlotListServiceConfig } from '../../../services/time-slot-list/index.js';
7
7
  import type { TimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
8
+ import { type ServiceSelectionTimeSlot } from '../../../services/booking/booking.js';
9
+ import type { Service } from '@wix/auto_sdk_bookings_services';
10
+ /**
11
+ * Render props data provided to TimeSlotList.Root children
12
+ */
13
+ export interface TimeSlotListRootRenderProps {
14
+ /** Function to navigate to the booking form with the selected time slot */
15
+ navigateToBookingForm: ({ timeSlot, service, }: {
16
+ timeSlot?: ServiceSelectionTimeSlot;
17
+ service?: Service;
18
+ }) => Promise<void>;
19
+ }
8
20
  /**
9
21
  * Props for Root component
10
22
  */
11
23
  export interface RootProps {
12
- children: React.ReactNode;
24
+ children: (data: TimeSlotListRootRenderProps) => React.ReactNode;
13
25
  config: TimeSlotListServiceConfig;
26
+ /**
27
+ * Function to navigate to the booking form with the selected time slot.
28
+ * The timeSlot and service parameters are optional - if not provided,
29
+ * BookingService will be used to get them from the current service selections.
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * <Root
34
+ * config={config}
35
+ * navigateToBookingForm={async ({ timeSlot, service }) => {
36
+ * // Custom navigation logic
37
+ * await navigateToBookingForm({ timeSlot, service });
38
+ * }}
39
+ * >
40
+ * {({ navigateToBookingForm }) => (
41
+ * // Use navigateToBookingForm in children
42
+ * // Can call with: navigateToBookingForm() or navigateToBookingForm({ timeSlot, service })
43
+ * )}
44
+ * </Root>
45
+ * ```
46
+ */
47
+ navigateToBookingForm: ({ timeSlot, service, }: {
48
+ timeSlot?: ServiceSelectionTimeSlot;
49
+ service?: Service;
50
+ }) => Promise<void>;
14
51
  }
15
52
  /**
16
53
  * Root component that provides TimeSlotListService context to its children.
@@ -18,8 +55,15 @@ export interface RootProps {
18
55
  * @component
19
56
  * @example
20
57
  * ```tsx
21
- * <Root config={{ services, timeSlots, timezone }}>
22
- * {children}
58
+ * <Root
59
+ * config={{ services, timeSlots, timezone }}
60
+ * navigateToBookingForm={async (selection) => {
61
+ * await navigateToBookingForm(selection);
62
+ * }}
63
+ * >
64
+ * {({ navigateToBookingForm }) => (
65
+ * // Your components that can use navigateToBookingForm
66
+ * )}
23
67
  * </Root>
24
68
  * ```
25
69
  */
@@ -1,21 +1,76 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * Core TimeSlotList Components
4
+ * Provides low-level access to TimeSlotListService via render props
5
+ */
6
+ import React from 'react';
2
7
  import { useService, WixServices } from '@wix/services-manager-react';
3
8
  import { createServicesMap } from '@wix/services-manager';
4
9
  import { TimeSlotListServiceDefinition, TimeSlotListService, } from '../../../services/time-slot-list/index.js';
5
- import { BookingServiceDefinition } from '../../../services/booking/booking.js';
10
+ import { BookingServiceDefinition, } from '../../../services/booking/booking.js';
6
11
  /**
7
12
  * Root component that provides TimeSlotListService context to its children.
8
13
  *
9
14
  * @component
10
15
  * @example
11
16
  * ```tsx
12
- * <Root config={{ services, timeSlots, timezone }}>
13
- * {children}
17
+ * <Root
18
+ * config={{ services, timeSlots, timezone }}
19
+ * navigateToBookingForm={async (selection) => {
20
+ * await navigateToBookingForm(selection);
21
+ * }}
22
+ * >
23
+ * {({ navigateToBookingForm }) => (
24
+ * // Your components that can use navigateToBookingForm
25
+ * )}
14
26
  * </Root>
15
27
  * ```
16
28
  */
17
29
  export function Root(props) {
18
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(TimeSlotListServiceDefinition, TimeSlotListService, props.config), children: props.children }));
30
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(TimeSlotListServiceDefinition, TimeSlotListService, props.config), children: _jsx(RootContent, { navigateToBookingForm: props.navigateToBookingForm, children: props.children }) }));
31
+ }
32
+ /**
33
+ * Internal component that wraps navigateToBookingForm to handle optional parameters
34
+ */
35
+ function RootContent({ navigateToBookingForm: providedNavigateToBookingForm, children, }) {
36
+ const timeSlotListService = useService(TimeSlotListServiceDefinition);
37
+ React.useEffect(() => {
38
+ return () => {
39
+ timeSlotListService.dispose();
40
+ };
41
+ }, [timeSlotListService]);
42
+ let bookingService = null;
43
+ try {
44
+ bookingService = useService(BookingServiceDefinition);
45
+ }
46
+ catch {
47
+ bookingService = null;
48
+ }
49
+ const navigateToBookingForm = async ({ timeSlot, service, }) => {
50
+ let resolvedTimeSlot = timeSlot;
51
+ let resolvedService = service;
52
+ if ((!resolvedTimeSlot || !resolvedService) && bookingService) {
53
+ const serviceSelections = bookingService.serviceSelections.get();
54
+ if (serviceSelections.length > 0) {
55
+ const firstSelection = serviceSelections[0];
56
+ if (firstSelection) {
57
+ resolvedService = resolvedService || firstSelection.service;
58
+ resolvedTimeSlot = resolvedTimeSlot || firstSelection.timeSlot;
59
+ }
60
+ }
61
+ }
62
+ if (!resolvedTimeSlot) {
63
+ throw new Error('timeSlot is required. Either provide it as a parameter or ensure BookingService has a service selection with a timeSlot.');
64
+ }
65
+ if (!resolvedService) {
66
+ throw new Error('service is required. Either provide it as a parameter or ensure BookingService has a service selection.');
67
+ }
68
+ return providedNavigateToBookingForm({
69
+ timeSlot: resolvedTimeSlot,
70
+ service: resolvedService,
71
+ });
72
+ };
73
+ return _jsx(_Fragment, { children: children({ navigateToBookingForm }) });
19
74
  }
20
75
  // ============================================================================
21
76
  // Timezone Component
@@ -1,5 +1,4 @@
1
1
  export * as Booking from './booking/Booking.js';
2
- export * as BookingForm from './booking-form/BookingForm.js';
3
2
  export * as Service from './service/Service.js';
4
3
  export * as ServiceMedia from './service/ServiceMedia.js';
5
4
  export * as TimeSlotList from './time-slot-list/TimeSlotList.js';
@@ -1,5 +1,5 @@
1
1
  export * as Booking from './booking/Booking.js';
2
- export * as BookingForm from './booking-form/BookingForm.js';
2
+ // export * as BookingForm from './booking-form/BookingForm.js';
3
3
  export * as Service from './service/Service.js';
4
4
  export * as ServiceMedia from './service/ServiceMedia.js';
5
5
  export * as TimeSlotList from './time-slot-list/TimeSlotList.js';
@@ -23,6 +23,10 @@ export interface RootProps {
23
23
  children?: React.ReactNode | AsChildChildren<CoreLocation.LocationRenderProps>;
24
24
  /** CSS class name */
25
25
  className?: string;
26
+ /** Custom label for CUSTOM location type */
27
+ customLocationLabel?: string;
28
+ /** Custom label for CUSTOMER location type */
29
+ customerLocationLabel?: string;
26
30
  /** Data attributes */
27
31
  [key: `data-${string}`]: string | undefined;
28
32
  }
@@ -9,6 +9,7 @@ import React from 'react';
9
9
  import * as CoreLocation from '../core/location/Location.js';
10
10
  import { AsChildSlot } from '@wix/headless-utils/react';
11
11
  import { Address } from '@wix/headless-components/react';
12
+ import { LocationType } from '../../services/location-list/location-list.def.js';
12
13
  // Re-export useLocationContext from core
13
14
  export { useLocationContext } from '../core/location/Location.js';
14
15
  // ==========================================
@@ -63,10 +64,27 @@ const useLocationContext = CoreLocation.useLocationContext;
63
64
  * ```
64
65
  */
65
66
  export const Root = React.forwardRef((props, ref) => {
66
- const { location, asChild, children, className, ...attrs } = props;
67
+ const { location, asChild, children, className, customLocationLabel, customerLocationLabel, ...attrs } = props;
67
68
  // Extract data-* attributes
68
69
  const dataAttrs = Object.fromEntries(Object.entries(attrs).filter(([key]) => key.startsWith('data-')));
69
- return (_jsx(CoreLocation.Root, { location: location, children: _jsx(CoreLocation.Data, { children: (renderProps) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationRoot, "data-location-type": renderProps.locationType, customElement: children, customElementProps: renderProps, ...dataAttrs, children: children })) }) }));
70
+ // If location is synthetic and labels are provided, update the synthetic location's name
71
+ let processedLocation = location;
72
+ if (location && 'synthetic' in location && location.synthetic === true) {
73
+ const syntheticLoc = location;
74
+ const shouldUpdateName = (syntheticLoc.locationType === LocationType.CUSTOM &&
75
+ customLocationLabel !== undefined) ||
76
+ (syntheticLoc.locationType === LocationType.CUSTOMER &&
77
+ customerLocationLabel !== undefined);
78
+ if (shouldUpdateName) {
79
+ processedLocation = {
80
+ ...syntheticLoc,
81
+ name: syntheticLoc.locationType === LocationType.CUSTOM
82
+ ? customLocationLabel
83
+ : customerLocationLabel,
84
+ };
85
+ }
86
+ }
87
+ return (_jsx(CoreLocation.Root, { location: processedLocation, children: _jsx(CoreLocation.Data, { children: (renderProps) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationRoot, "data-location-type": renderProps.locationType, customElement: children, customElementProps: renderProps, ...dataAttrs, children: children })) }) }));
70
88
  });
71
89
  Root.displayName = 'Location.Root';
72
90
  /**
@@ -17,6 +17,10 @@ export interface RootProps {
17
17
  locationListConfig?: LocationListServiceConfig;
18
18
  className?: string;
19
19
  variant?: ListVariant;
20
+ /** Custom label for CUSTOM location type */
21
+ customLocationLabel?: string;
22
+ /** Custom label for CUSTOMER location type */
23
+ customerLocationLabel?: string;
20
24
  }
21
25
  /**
22
26
  * Root component that provides the LocationList service context for rendering locations lists.
@@ -9,9 +9,15 @@ import React from 'react';
9
9
  import { GenericList, } from '@wix/headless-components/react';
10
10
  import { AsChildSlot } from '@wix/headless-utils/react';
11
11
  import { useService } from '@wix/services-manager-react';
12
+ import { LocationType, } from '../../services/location-list/location-list.def.js';
12
13
  import { BookingServiceDefinition } from '../../services/booking/booking.js';
13
14
  import * as CoreLocationList from '../core/location-list/LocationList.js';
14
15
  import * as Location from './Location.js';
16
+ const LocationLabelsContext = React.createContext(null);
17
+ function useLocationLabelsContext() {
18
+ const context = React.useContext(LocationLabelsContext);
19
+ return context || {};
20
+ }
15
21
  // ============================================================================
16
22
  // TestIds
17
23
  // ============================================================================
@@ -45,11 +51,11 @@ var TestIds;
45
51
  * ```
46
52
  */
47
53
  export const Root = React.forwardRef((props, ref) => {
48
- const { children, locationListConfig, className, variant } = props;
54
+ const { children, locationListConfig, className, variant, customLocationLabel, customerLocationLabel, } = props;
49
55
  const config = locationListConfig || {
50
56
  locations: [],
51
57
  };
52
- return (_jsx(CoreLocationList.Root, { locationListServiceConfig: config, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, children: children }) }));
58
+ return (_jsx(LocationLabelsContext.Provider, { value: { customLocationLabel, customerLocationLabel }, children: _jsx(CoreLocationList.Root, { locationListServiceConfig: config, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, children: children }) }) }));
53
59
  });
54
60
  Root.displayName = 'LocationList.Root';
55
61
  /**
@@ -85,15 +91,35 @@ export const Locations = React.forwardRef((props, ref) => {
85
91
  Locations.displayName = 'LocationList.Locations';
86
92
  export const LocationRepeater = React.forwardRef((props, ref) => {
87
93
  const { children } = props;
94
+ const { customLocationLabel, customerLocationLabel } = useLocationLabelsContext();
88
95
  // Custom itemWrapper that wraps each item in Location.Root
89
96
  const locationItemWrapper = ({ item: displayLocation, children: itemChildren, }) => {
90
97
  // Convert DisplayLocation to LocationInput
91
98
  // If location is null, create a SyntheticLocation
92
- const location = displayLocation.location ?? {
93
- locationType: displayLocation.type,
94
- synthetic: true,
95
- _id: displayLocation.id,
96
- };
99
+ let location;
100
+ if (displayLocation.location) {
101
+ location = displayLocation.location;
102
+ }
103
+ else {
104
+ const locationType = displayLocation.type;
105
+ // Determine the name based on labels or defaults
106
+ let name;
107
+ if (locationType === LocationType.CUSTOM &&
108
+ customLocationLabel !== undefined) {
109
+ name = customLocationLabel;
110
+ }
111
+ else if (locationType === LocationType.CUSTOMER &&
112
+ customerLocationLabel !== undefined) {
113
+ name = customerLocationLabel;
114
+ }
115
+ // If no label provided, name will be undefined and defaults will be used in computeLocationRenderProps
116
+ location = {
117
+ locationType,
118
+ synthetic: true,
119
+ _id: displayLocation.id,
120
+ name,
121
+ };
122
+ }
97
123
  return (_jsx(Location.Root, { location: location, "data-testid": TestIds.locationListLocation, "data-location-id": displayLocation.id, "data-location-type": displayLocation.type, "data-item-id": displayLocation.id, children: itemChildren }, displayLocation.id));
98
124
  };
99
125
  return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: locationItemWrapper, children: children }));
@@ -6,7 +6,9 @@ import React from 'react';
6
6
  import { ListVariant } from '@wix/headless-components/react';
7
7
  import { AsChildChildren } from '@wix/headless-utils/react';
8
8
  import type { TimeSlot as TimeSlotType } from '@wix/auto_sdk_bookings_availability-time-slots';
9
+ import type { Service } from '@wix/auto_sdk_bookings_services';
9
10
  import type { TimeSlotListServiceConfig } from '../../services/time-slot-list/time-slot-list.def.js';
11
+ import { ServiceSelectionTimeSlot } from '../../services/booking/booking.js';
10
12
  export type { StartDateProps as TimeSlotStartDateProps, EndDateProps as TimeSlotEndDateProps, DurationProps as TimeSlotDurationProps, SelectProps as TimeSlotSelectProps, LocationNameProps as TimeSlotLocationNameProps, StaffMembersProps as TimeSlotStaffMembersProps, StaffMemberRepeaterProps as TimeSlotStaffMemberRepeaterProps, StaffMemberNameProps as TimeSlotStaffMemberNameProps, SelectStaffMemberProps as TimeSlotSelectStaffMemberProps, ClearStaffSelectionProps as TimeSlotClearStaffSelectionProps, } from './TimeSlot.js';
11
13
  /**
12
14
  * Render props for TimeSlotList.Timezone component
@@ -49,8 +51,23 @@ export declare const Timezone: React.ForwardRefExoticComponent<TimezoneProps & R
49
51
  * Props for TimeSlotList.Root component
50
52
  */
51
53
  export interface RootProps {
52
- children: React.ReactNode;
54
+ children: React.ReactNode | ((data: {
55
+ navigateToBookingForm: ({ timeSlot, service, }: {
56
+ timeSlot?: ServiceSelectionTimeSlot;
57
+ service?: Service;
58
+ }) => Promise<void>;
59
+ }) => React.ReactNode);
53
60
  config: TimeSlotListServiceConfig;
61
+ /**
62
+ * Function to navigate to the booking form.
63
+ * The timeSlot and service parameters are optional - if not provided,
64
+ * BookingService will be used to get them from the current service selections.
65
+ * If not provided, will use the default navigation utility.
66
+ */
67
+ navigateToBookingForm?: ({ timeSlot, service, }: {
68
+ timeSlot?: ServiceSelectionTimeSlot;
69
+ service?: Service;
70
+ }) => Promise<void>;
54
71
  className?: string;
55
72
  variant?: ListVariant;
56
73
  }
@@ -62,15 +79,21 @@ export interface RootProps {
62
79
  * @example
63
80
  * ```tsx
64
81
  * import { TimeSlotList } from '@wix/bookings/components';
82
+ * import { navigateToBookingForm } from '@wix/headless-bookings/utils';
65
83
  *
66
84
  * function TimeSlotsPage({ config }) {
67
85
  * return (
68
- * <TimeSlotList.Root config={config}>
69
- * <TimeSlotList.TimeSlots>
70
- * <TimeSlotList.TimeSlotRepeater>
71
- * {children}
72
- * </TimeSlotList.TimeSlotRepeater>
73
- * </TimeSlotList.TimeSlots>
86
+ * <TimeSlotList.Root
87
+ * config={config}
88
+ * navigateToBookingForm={navigateToBookingForm}
89
+ * >
90
+ * {({ navigateToBookingForm }) => (
91
+ * <TimeSlotList.TimeSlots>
92
+ * <TimeSlotList.TimeSlotRepeater>
93
+ * {children}
94
+ * </TimeSlotList.TimeSlotRepeater>
95
+ * </TimeSlotList.TimeSlots>
96
+ * )}
74
97
  * </TimeSlotList.Root>
75
98
  * );
76
99
  * }
@@ -9,6 +9,7 @@ import { AsChildSlot } from '@wix/headless-utils/react';
9
9
  import * as CoreTimeSlotList from '../core/time-slot-list/TimeSlotList.js';
10
10
  import * as CoreTimeSlot from '../core/time-slot-list/TimeSlot.js';
11
11
  import { StartDate as TimeSlotStartDate, EndDate as TimeSlotEndDate, Duration, Actions as TimeSlotActions, Location, StaffMembers, StaffMemberRepeater, StaffMember, Root as TimeSlotRoot, } from './TimeSlot.js';
12
+ import { navigateToBookingForm as defaultNavigateToBookingForm } from '../../utils/navigation.js';
12
13
  // ============================================================================
13
14
  // Utilities
14
15
  // ============================================================================
@@ -28,6 +29,7 @@ var TestIds;
28
29
  TestIds["timeSlotListTimeSlot"] = "time-slot-list-time-slot";
29
30
  TestIds["timeSlotListTimezone"] = "time-slot-list-timezone";
30
31
  TestIds["timeSlotListLoadMore"] = "time-slot-list-load-more";
32
+ TestIds["timeSlotListContinue"] = "time-slot-list-continue";
31
33
  TestIds["timeSlotListDateRangeInput"] = "time-slot-list-date-range-input";
32
34
  })(TestIds || (TestIds = {}));
33
35
  /**
@@ -62,23 +64,40 @@ Timezone.displayName = 'TimeSlotList.Timezone';
62
64
  * @example
63
65
  * ```tsx
64
66
  * import { TimeSlotList } from '@wix/bookings/components';
67
+ * import { navigateToBookingForm } from '@wix/headless-bookings/utils';
65
68
  *
66
69
  * function TimeSlotsPage({ config }) {
67
70
  * return (
68
- * <TimeSlotList.Root config={config}>
69
- * <TimeSlotList.TimeSlots>
70
- * <TimeSlotList.TimeSlotRepeater>
71
- * {children}
72
- * </TimeSlotList.TimeSlotRepeater>
73
- * </TimeSlotList.TimeSlots>
71
+ * <TimeSlotList.Root
72
+ * config={config}
73
+ * navigateToBookingForm={navigateToBookingForm}
74
+ * >
75
+ * {({ navigateToBookingForm }) => (
76
+ * <TimeSlotList.TimeSlots>
77
+ * <TimeSlotList.TimeSlotRepeater>
78
+ * {children}
79
+ * </TimeSlotList.TimeSlotRepeater>
80
+ * </TimeSlotList.TimeSlots>
81
+ * )}
74
82
  * </TimeSlotList.Root>
75
83
  * );
76
84
  * }
77
85
  * ```
78
86
  */
79
87
  export const Root = React.forwardRef((props, ref) => {
80
- const { children, config, className, variant } = props;
81
- return (_jsx(CoreTimeSlotList.Root, { config: config, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, children: children }) }));
88
+ const { children, config, className, variant, navigateToBookingForm: providedNavigateToBookingForm, } = props;
89
+ const navigateToBookingForm = providedNavigateToBookingForm ||
90
+ (async ({ timeSlot, service, }) => {
91
+ if (!timeSlot || !service) {
92
+ throw new Error('timeSlot and service are required when using default navigation. Either provide them or ensure BookingService has service selections.');
93
+ }
94
+ return defaultNavigateToBookingForm({ timeSlot, service });
95
+ });
96
+ return (_jsx(CoreTimeSlotList.Root, { config: config, navigateToBookingForm: navigateToBookingForm, children: (coreData) => (_jsx(RootContent, { className: className, ref: ref, variant: variant, children: typeof children === 'function'
97
+ ? children({
98
+ navigateToBookingForm: coreData.navigateToBookingForm,
99
+ })
100
+ : children })) }));
82
101
  });
83
102
  Root.displayName = 'TimeSlotList.Root';
84
103
  /**