@wix/headless-bookings 0.0.62 → 0.0.64

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 (57) 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/core/location/Location.d.ts +2 -0
  9. package/cjs/dist/react/core/location/Location.js +14 -1
  10. package/cjs/dist/react/core/time-slot-list/TimeSlot.js +0 -2
  11. package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +4 -2
  12. package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +19 -8
  13. package/cjs/dist/react/index.d.ts +0 -1
  14. package/cjs/dist/react/index.js +1 -1
  15. package/cjs/dist/react/location/Location.d.ts +4 -0
  16. package/cjs/dist/react/location/Location.js +20 -2
  17. package/cjs/dist/react/location/LocationList.d.ts +4 -0
  18. package/cjs/dist/react/location/LocationList.js +33 -7
  19. package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +5 -3
  20. package/cjs/dist/react/time-slot-list/TimeSlotList.js +2 -6
  21. package/cjs/dist/services/index.d.ts +2 -1
  22. package/cjs/dist/services/index.js +2 -1
  23. package/cjs/dist/services/location-list/location-list.d.ts +1 -0
  24. package/cjs/dist/services/location-list/location-list.js +3 -2
  25. package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +1 -0
  26. package/cjs/dist/services/time-slot-list/time-slot-list.js +2 -9
  27. package/cjs/dist/utils/navigation.d.ts +11 -1
  28. package/cjs/dist/utils/navigation.js +53 -22
  29. package/dist/__mocks__/time-slots.js +1 -0
  30. package/dist/api/index.d.ts +2 -2
  31. package/dist/api/index.js +2 -2
  32. package/dist/api/query-locations/index.d.ts +14 -0
  33. package/dist/api/query-locations/index.js +27 -0
  34. package/dist/api/query-services/index.d.ts +5 -0
  35. package/dist/api/query-services/index.js +2 -2
  36. package/dist/react/core/location/Location.d.ts +2 -0
  37. package/dist/react/core/location/Location.js +14 -1
  38. package/dist/react/core/time-slot-list/TimeSlot.js +0 -2
  39. package/dist/react/core/time-slot-list/TimeSlotList.d.ts +4 -2
  40. package/dist/react/core/time-slot-list/TimeSlotList.js +19 -8
  41. package/dist/react/index.d.ts +0 -1
  42. package/dist/react/index.js +1 -1
  43. package/dist/react/location/Location.d.ts +4 -0
  44. package/dist/react/location/Location.js +20 -2
  45. package/dist/react/location/LocationList.d.ts +4 -0
  46. package/dist/react/location/LocationList.js +33 -7
  47. package/dist/react/time-slot-list/TimeSlotList.d.ts +5 -3
  48. package/dist/react/time-slot-list/TimeSlotList.js +2 -6
  49. package/dist/services/index.d.ts +2 -1
  50. package/dist/services/index.js +2 -1
  51. package/dist/services/location-list/location-list.d.ts +1 -0
  52. package/dist/services/location-list/location-list.js +3 -2
  53. package/dist/services/time-slot-list/time-slot-list.def.d.ts +1 -0
  54. package/dist/services/time-slot-list/time-slot-list.js +2 -9
  55. package/dist/utils/navigation.d.ts +11 -1
  56. package/dist/utils/navigation.js +53 -22
  57. package/package.json +2 -2
@@ -27,7 +27,32 @@ function mapTimeSlotLocationToBookingLocation(timeSlotLocationType) {
27
27
  return BookingsLocationType.UNDEFINED;
28
28
  }
29
29
  }
30
- export async function navigateToBookingForm({ timeSlot, service, }) {
30
+ /**
31
+ * Cleans a redirect URL by extracting the redirectUrl param and removing:
32
+ * - The 'origin' query parameter
33
+ * - Any query parameters with empty values
34
+ *
35
+ * @param fullUrl - The full URL containing the redirectUrl query parameter
36
+ * @returns The cleaned redirect URL
37
+ */
38
+ export function cleanRedirectUrl(fullUrl) {
39
+ const url = new URL(fullUrl);
40
+ const redirectUrl = url.searchParams.get('redirectUrl');
41
+ if (!redirectUrl) {
42
+ return fullUrl;
43
+ }
44
+ const redirectParsed = new URL(redirectUrl);
45
+ // Remove origin param
46
+ redirectParsed.searchParams.delete('origin');
47
+ // Remove empty params
48
+ for (const [key, value] of [...redirectParsed.searchParams.entries()]) {
49
+ if (!value) {
50
+ redirectParsed.searchParams.delete(key);
51
+ }
52
+ }
53
+ return redirectParsed.toString();
54
+ }
55
+ export async function navigateToBookingForm({ timeSlot, service, timezone, }) {
31
56
  if (!timeSlot) {
32
57
  throw new Error('No time slot provided');
33
58
  }
@@ -36,30 +61,36 @@ export async function navigateToBookingForm({ timeSlot, service, }) {
36
61
  }
37
62
  // Get the first resource (staff member) if available
38
63
  const selectedResource = timeSlot.resources?.[0];
64
+ // Destructure to exclude properties we handle separately (location has incompatible types)
65
+ const { location: _location, resources: _resources, ...restTimeSlot } = timeSlot;
66
+ // Build slot object, only including optional properties when they have values
67
+ const slot = {
68
+ ...restTimeSlot,
69
+ scheduleId: timeSlot.scheduleId,
70
+ startDate: timeSlot.startDate,
71
+ endDate: timeSlot.endDate,
72
+ ...(service._id && { serviceId: service._id }),
73
+ ...(timezone && { timezone }),
74
+ ...(selectedResource && {
75
+ resource: {
76
+ _id: selectedResource._id,
77
+ name: selectedResource.name,
78
+ },
79
+ }),
80
+ ...(timeSlot.location && {
81
+ location: {
82
+ _id: timeSlot.location._id,
83
+ name: timeSlot.location.name,
84
+ formattedAddress: timeSlot.location.formattedAddress,
85
+ locationType: mapTimeSlotLocationToBookingLocation(timeSlot.location.locationType),
86
+ },
87
+ }),
88
+ };
39
89
  const { redirectSession } = await redirects.createRedirectSession({
40
90
  bookingsCheckout: {
41
91
  slotAvailability: {
42
92
  bookable: true,
43
- slot: {
44
- ...timeSlot,
45
- serviceId: service._id ?? undefined,
46
- scheduleId: timeSlot.scheduleId,
47
- startDate: timeSlot.startDate,
48
- endDate: timeSlot.endDate,
49
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
50
- resource: selectedResource
51
- ? {
52
- _id: selectedResource._id,
53
- name: selectedResource.name,
54
- }
55
- : undefined,
56
- location: {
57
- _id: timeSlot.location?._id,
58
- name: timeSlot.location?.name,
59
- formattedAddress: timeSlot.location?.formattedAddress,
60
- locationType: mapTimeSlotLocationToBookingLocation(timeSlot.location?.locationType),
61
- },
62
- },
93
+ slot,
63
94
  },
64
95
  },
65
96
  callbacks: {
@@ -67,7 +98,7 @@ export async function navigateToBookingForm({ timeSlot, service, }) {
67
98
  },
68
99
  });
69
100
  if (redirectSession?.fullUrl) {
70
- window.location.href = redirectSession.fullUrl;
101
+ window.location.href = cleanRedirectUrl(redirectSession.fullUrl);
71
102
  }
72
103
  else {
73
104
  throw new Error('Failed to create redirect session');
@@ -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:
package/dist/api/index.js CHANGED
@@ -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
@@ -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
  }
@@ -12,9 +12,10 @@ import type { Service } from '@wix/auto_sdk_bookings_services';
12
12
  */
13
13
  export interface TimeSlotListRootRenderProps {
14
14
  /** Function to navigate to the booking form with the selected time slot */
15
- navigateToBookingForm: ({ timeSlot, service, }: {
15
+ navigateToBookingForm: ({ timeSlot, service, timezone, }: {
16
16
  timeSlot?: ServiceSelectionTimeSlot;
17
17
  service?: Service;
18
+ timezone?: string;
18
19
  }) => Promise<void>;
19
20
  }
20
21
  /**
@@ -44,9 +45,10 @@ export interface RootProps {
44
45
  * </Root>
45
46
  * ```
46
47
  */
47
- navigateToBookingForm: ({ timeSlot, service, }: {
48
+ navigateToBookingForm: ({ timeSlot, service, timezone, }: {
48
49
  timeSlot?: ServiceSelectionTimeSlot;
49
50
  service?: Service;
51
+ timezone?: string;
50
52
  }) => Promise<void>;
51
53
  }
52
54
  /**
@@ -1,4 +1,9 @@
1
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';
@@ -28,22 +33,29 @@ export function Root(props) {
28
33
  * Internal component that wraps navigateToBookingForm to handle optional parameters
29
34
  */
30
35
  function RootContent({ navigateToBookingForm: providedNavigateToBookingForm, children, }) {
31
- // Get BookingService to use when timeSlot/service are not provided
36
+ const timeSlotListService = useService(TimeSlotListServiceDefinition);
37
+ React.useEffect(() => {
38
+ return () => {
39
+ timeSlotListService.dispose();
40
+ };
41
+ }, [timeSlotListService]);
32
42
  let bookingService = null;
33
43
  try {
34
44
  bookingService = useService(BookingServiceDefinition);
35
45
  }
36
46
  catch {
37
- // BookingService not available - that's ok, user must provide timeSlot/service
38
47
  bookingService = null;
39
48
  }
40
- // Wrap the provided navigateToBookingForm to handle optional parameters
41
- const navigateToBookingForm = async ({ timeSlot, service, }) => {
42
- // If timeSlot or service are not provided, try to get them from BookingService
49
+ const navigateToBookingForm = async ({ timeSlot, service, timezone, }) => {
43
50
  let resolvedTimeSlot = timeSlot;
44
51
  let resolvedService = service;
45
- if ((!resolvedTimeSlot || !resolvedService) && bookingService) {
52
+ let resolvedTimezone = timezone;
53
+ if ((!resolvedTimeSlot || !resolvedService || !resolvedTimezone) &&
54
+ bookingService) {
46
55
  const serviceSelections = bookingService.serviceSelections.get();
56
+ if (!resolvedTimezone) {
57
+ resolvedTimezone = bookingService.timezone.get();
58
+ }
47
59
  if (serviceSelections.length > 0) {
48
60
  const firstSelection = serviceSelections[0];
49
61
  if (firstSelection) {
@@ -52,17 +64,16 @@ function RootContent({ navigateToBookingForm: providedNavigateToBookingForm, chi
52
64
  }
53
65
  }
54
66
  }
55
- // Validate that we have both timeSlot and service
56
67
  if (!resolvedTimeSlot) {
57
68
  throw new Error('timeSlot is required. Either provide it as a parameter or ensure BookingService has a service selection with a timeSlot.');
58
69
  }
59
70
  if (!resolvedService) {
60
71
  throw new Error('service is required. Either provide it as a parameter or ensure BookingService has a service selection.');
61
72
  }
62
- // Call the provided function with resolved values
63
73
  return providedNavigateToBookingForm({
64
74
  timeSlot: resolvedTimeSlot,
65
75
  service: resolvedService,
76
+ timezone: resolvedTimezone,
66
77
  });
67
78
  };
68
79
  return _jsx(_Fragment, { children: children({ navigateToBookingForm }) });
@@ -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 }));
@@ -52,21 +52,23 @@ export declare const Timezone: React.ForwardRefExoticComponent<TimezoneProps & R
52
52
  */
53
53
  export interface RootProps {
54
54
  children: React.ReactNode | ((data: {
55
- navigateToBookingForm: ({ timeSlot, service, }: {
55
+ navigateToBookingForm: ({ timeSlot, service, timezone, }: {
56
56
  timeSlot?: ServiceSelectionTimeSlot;
57
57
  service?: Service;
58
+ timezone?: string;
58
59
  }) => Promise<void>;
59
60
  }) => React.ReactNode);
60
61
  config: TimeSlotListServiceConfig;
61
62
  /**
62
63
  * Function to navigate to the booking form.
63
- * The timeSlot and service parameters are optional - if not provided,
64
+ * The timeSlot, service, and timezone parameters are optional - if not provided,
64
65
  * BookingService will be used to get them from the current service selections.
65
66
  * If not provided, will use the default navigation utility.
66
67
  */
67
- navigateToBookingForm?: ({ timeSlot, service, }: {
68
+ navigateToBookingForm?: ({ timeSlot, service, timezone, }: {
68
69
  timeSlot?: ServiceSelectionTimeSlot;
69
70
  service?: Service;
71
+ timezone?: string;
70
72
  }) => Promise<void>;
71
73
  className?: string;
72
74
  variant?: ListVariant;
@@ -86,16 +86,12 @@ Timezone.displayName = 'TimeSlotList.Timezone';
86
86
  */
87
87
  export const Root = React.forwardRef((props, ref) => {
88
88
  const { children, config, className, variant, navigateToBookingForm: providedNavigateToBookingForm, } = props;
89
- // Wrap defaultNavigateToBookingForm to match optional parameter signature
90
- // The core component will handle getting timeSlot/service from BookingService if not provided
91
89
  const navigateToBookingForm = providedNavigateToBookingForm ||
92
- (async ({ timeSlot, service, }) => {
93
- // This will be handled by the core component's wrapper
94
- // which will resolve timeSlot/service from BookingService if needed
90
+ (async ({ timeSlot, service, timezone, }) => {
95
91
  if (!timeSlot || !service) {
96
92
  throw new Error('timeSlot and service are required when using default navigation. Either provide them or ensure BookingService has service selections.');
97
93
  }
98
- return defaultNavigateToBookingForm({ timeSlot, service });
94
+ return defaultNavigateToBookingForm({ timeSlot, service, timezone });
99
95
  });
100
96
  return (_jsx(CoreTimeSlotList.Root, { config: config, navigateToBookingForm: navigateToBookingForm, children: (coreData) => (_jsx(RootContent, { className: className, ref: ref, variant: variant, children: typeof children === 'function'
101
97
  ? children({
@@ -6,8 +6,9 @@ export { ServiceService, ServiceServiceDefinition, type ServiceServiceAPI, type
6
6
  export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type BookingServiceActions, type ServiceSelection, type ServiceSelectionTimeSlot, } from './booking/booking.js';
7
7
  export { TimeSlotListService, TimeSlotListServiceDefinition, TimeSlotService, TimeSlotServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type TimeSlotServiceAPI, type TimeSlotServiceConfig, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
8
8
  export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListFilters, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
9
+ export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from '../api/query-services/index.js';
9
10
  export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCheckoutParams, } from './booking/book-action/index.js';
10
11
  export { BookingFormService, BookingFormServiceDefinition, type BookingFormServiceAPI, type BookingFormServiceConfig, type BookingFormServiceInternalAPI, type ValidationResult, } from './booking-form/booking-form.js';
11
12
  export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
12
- export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, type LocationListServiceAPI, type LocationListServiceConfig, type LocationListActions, type LocationData, type DisplayLocation, type LoadLocationListServiceResult, } from './location-list/location-list.js';
13
+ export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, type LocationListServiceAPI, type LocationListServiceConfig, type LocationListActions, type LocationData, type DisplayLocation, type LoadLocationListServiceResult, getLocationById, } from './location-list/location-list.js';
13
14
  export { StaffMemberListService, StaffMemberListServiceDefinition, loadStaffMemberListServiceInitialData, staffMemberListServiceBinding, type StaffMemberListServiceAPI, type StaffMemberListServiceConfig, type StaffMemberListActions, type StaffMemberData, type LoadStaffMemberListServiceResult, } from './staff-member-list/staff-member-list.js';
@@ -6,8 +6,9 @@ export { ServiceService, ServiceServiceDefinition, loadServiceServiceInitialData
6
6
  export { BookingService, BookingServiceDefinition, } from './booking/booking.js';
7
7
  export { TimeSlotListService, TimeSlotListServiceDefinition, TimeSlotService, TimeSlotServiceDefinition, ViewMode, loadTimeSlotListConfig, } from './time-slot-list/index.js';
8
8
  export { ServiceListService, ServiceListServiceDefinition, loadServiceListServiceInitialData, } from './service-list/service-list.js';
9
+ export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from '../api/query-services/index.js';
9
10
  export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, } from './booking/book-action/index.js';
10
11
  export { BookingFormService, BookingFormServiceDefinition, } from './booking-form/booking-form.js';
11
12
  export { PaymentService, PaymentServiceDefinition, loadPaymentConfig, } from './payment/payment.js';
12
- export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, } from './location-list/location-list.js';
13
+ export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, getLocationById, } from './location-list/location-list.js';
13
14
  export { StaffMemberListService, StaffMemberListServiceDefinition, loadStaffMemberListServiceInitialData, staffMemberListServiceBinding, } from './staff-member-list/staff-member-list.js';
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { ServiceFactoryConfig } from '@wix/services-definitions';
8
8
  import { type LocationData } from './location-list.def.js';
9
+ export { getLocationById } from '../../api/query-locations/index.js';
9
10
  /**
10
11
  * Configuration interface for LocationListService
11
12
  */
@@ -10,14 +10,15 @@ import { LocationType } from '@wix/auto_sdk_bookings_services';
10
10
  import { LocationListServiceDefinition, } from './location-list.def.js';
11
11
  import { BookingServiceDefinition } from '../booking/booking.js';
12
12
  import { queryLocations } from '../../api/query-locations/index.js';
13
+ export { getLocationById } from '../../api/query-locations/index.js';
13
14
  // ============================================================================
14
15
  // Constants
15
16
  // ============================================================================
16
17
  /**
17
18
  * Synthetic location IDs for non-business locations
18
19
  */
19
- const SYNTHETIC_CUSTOM_ID = '__synthetic_custom__';
20
- const SYNTHETIC_CUSTOMER_ID = '__synthetic_customer__';
20
+ const SYNTHETIC_CUSTOM_ID = 'custom';
21
+ const SYNTHETIC_CUSTOMER_ID = 'customer';
21
22
  // ============================================================================
22
23
  // Helper Functions
23
24
  // ============================================================================
@@ -88,6 +88,7 @@ export interface TimeSlotListServiceAPI {
88
88
  hasMore: Signal<boolean>;
89
89
  dateRange: Signal<DateRange>;
90
90
  actions: TimeSlotListServiceActions;
91
+ dispose: () => void;
91
92
  }
92
93
  export declare const TimeSlotListServiceDefinition: string & {
93
94
  __api: TimeSlotListServiceAPI;