@wix/headless-bookings 0.0.43 → 0.0.44

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 (45) hide show
  1. package/cjs/dist/api/index.d.ts +1 -0
  2. package/cjs/dist/api/index.js +1 -0
  3. package/cjs/dist/api/query-locations/index.d.ts +38 -0
  4. package/cjs/dist/api/query-locations/index.js +30 -0
  5. package/cjs/dist/react/core/location/Location.d.ts +113 -14
  6. package/cjs/dist/react/core/location/Location.js +189 -30
  7. package/cjs/dist/react/core/location-list/LocationList.d.ts +102 -0
  8. package/cjs/dist/react/core/location-list/LocationList.js +71 -0
  9. package/cjs/dist/react/index.d.ts +1 -0
  10. package/cjs/dist/react/index.js +1 -0
  11. package/cjs/dist/react/location/Location.d.ts +211 -41
  12. package/cjs/dist/react/location/Location.js +219 -46
  13. package/cjs/dist/react/location/LocationList.d.ts +98 -0
  14. package/cjs/dist/react/location/LocationList.js +120 -0
  15. package/cjs/dist/react/service/Service.d.ts +17 -24
  16. package/cjs/dist/react/service/Service.js +24 -36
  17. package/cjs/dist/services/index.d.ts +1 -0
  18. package/cjs/dist/services/index.js +1 -0
  19. package/cjs/dist/services/location-list/location-list.d.ts +100 -0
  20. package/cjs/dist/services/location-list/location-list.def.d.ts +62 -0
  21. package/cjs/dist/services/location-list/location-list.def.js +17 -0
  22. package/cjs/dist/services/location-list/location-list.js +212 -0
  23. package/dist/api/index.d.ts +1 -0
  24. package/dist/api/index.js +1 -0
  25. package/dist/api/query-locations/index.d.ts +38 -0
  26. package/dist/api/query-locations/index.js +30 -0
  27. package/dist/react/core/location/Location.d.ts +113 -14
  28. package/dist/react/core/location/Location.js +189 -30
  29. package/dist/react/core/location-list/LocationList.d.ts +102 -0
  30. package/dist/react/core/location-list/LocationList.js +71 -0
  31. package/dist/react/index.d.ts +1 -0
  32. package/dist/react/index.js +1 -0
  33. package/dist/react/location/Location.d.ts +211 -41
  34. package/dist/react/location/Location.js +219 -46
  35. package/dist/react/location/LocationList.d.ts +98 -0
  36. package/dist/react/location/LocationList.js +120 -0
  37. package/dist/react/service/Service.d.ts +17 -24
  38. package/dist/react/service/Service.js +24 -36
  39. package/dist/services/index.d.ts +1 -0
  40. package/dist/services/index.js +1 -0
  41. package/dist/services/location-list/location-list.d.ts +100 -0
  42. package/dist/services/location-list/location-list.def.d.ts +62 -0
  43. package/dist/services/location-list/location-list.def.js +17 -0
  44. package/dist/services/location-list/location-list.js +212 -0
  45. package/package.json +2 -2
@@ -0,0 +1,98 @@
1
+ /**
2
+ * LocationList - High-level component for displaying locations list
3
+ * Follows the pattern from ServiceList.tsx
4
+ *
5
+ * @module React/LocationList
6
+ */
7
+ import React from 'react';
8
+ import { GenericListRepeaterProps, type ListVariant } from '@wix/headless-components/react';
9
+ import { type AsChildChildren } from '@wix/headless-utils/react';
10
+ import type { LocationListServiceConfig } from '../../services/location-list/location-list.js';
11
+ import { type DisplayLocation } from '../../services/location-list/location-list.def.js';
12
+ /**
13
+ * Props for the LocationList root component
14
+ */
15
+ export interface RootProps {
16
+ children: React.ReactNode;
17
+ locationListConfig?: LocationListServiceConfig;
18
+ className?: string;
19
+ variant?: ListVariant;
20
+ }
21
+ /**
22
+ * Root component that provides the LocationList service context for rendering locations lists.
23
+ *
24
+ * @component
25
+ * @example
26
+ * ```tsx
27
+ * import { LocationList, Location } from '@wix/bookings/react';
28
+ *
29
+ * function LocationsPage({ locationListConfig }) {
30
+ * return (
31
+ * <LocationList.Root locationListConfig={locationListConfig}>
32
+ * <LocationList.Locations emptyState={<div>No locations available</div>}>
33
+ * <LocationList.LocationRepeater>
34
+ * <Location.Name />
35
+ * <Location.Address />
36
+ * </LocationList.LocationRepeater>
37
+ * </LocationList.Locations>
38
+ * </LocationList.Root>
39
+ * );
40
+ * }
41
+ * ```
42
+ */
43
+ export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLElement>>;
44
+ /**
45
+ * Props for LocationList.Locations component
46
+ */
47
+ export interface LocationsProps {
48
+ children: React.ReactNode;
49
+ emptyState?: React.ReactNode;
50
+ className?: string;
51
+ }
52
+ /**
53
+ * Container for the locations list with empty state support.
54
+ * Wraps GenericList.Items internally (no separate Items export).
55
+ *
56
+ * @component
57
+ * @example
58
+ * ```tsx
59
+ * <LocationList.Locations emptyState={<div>No locations available</div>}>
60
+ * <LocationList.LocationRepeater>
61
+ * <Location.Name />
62
+ * <Location.Address />
63
+ * </LocationList.LocationRepeater>
64
+ * </LocationList.Locations>
65
+ * ```
66
+ */
67
+ export declare const Locations: React.ForwardRefExoticComponent<LocationsProps & React.RefAttributes<HTMLElement>>;
68
+ /**
69
+ * Props for LocationList.LocationRepeater component
70
+ */
71
+ export type LocationRepeaterProps = GenericListRepeaterProps<DisplayLocation>;
72
+ export declare const LocationRepeater: React.ForwardRefExoticComponent<LocationRepeaterProps & React.RefAttributes<HTMLElement>>;
73
+ /**
74
+ * Props for LocationList.Totals component
75
+ */
76
+ export interface TotalsProps {
77
+ asChild?: boolean;
78
+ children?: React.ReactNode | AsChildChildren<{
79
+ count: number;
80
+ hasLocations: boolean;
81
+ }>;
82
+ className?: string;
83
+ }
84
+ /**
85
+ * Displays the total count of locations.
86
+ *
87
+ * @component
88
+ * @example
89
+ * ```tsx
90
+ * <LocationList.Totals />
91
+ *
92
+ * // With asChild
93
+ * <LocationList.Totals asChild>
94
+ * {({ count }) => <span>{count} locations available</span>}
95
+ * </LocationList.Totals>
96
+ * ```
97
+ */
98
+ export declare const Totals: React.ForwardRefExoticComponent<TotalsProps & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,120 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * LocationList - High-level component for displaying locations list
4
+ * Follows the pattern from ServiceList.tsx
5
+ *
6
+ * @module React/LocationList
7
+ */
8
+ import React from 'react';
9
+ import { GenericList, } from '@wix/headless-components/react';
10
+ import { AsChildSlot } from '@wix/headless-utils/react';
11
+ import * as CoreLocationList from '../core/location-list/LocationList.js';
12
+ import * as Location from './Location.js';
13
+ // ============================================================================
14
+ // TestIds
15
+ // ============================================================================
16
+ var TestIds;
17
+ (function (TestIds) {
18
+ TestIds["locationListRoot"] = "location-list-root";
19
+ TestIds["locationListLocations"] = "location-list-locations";
20
+ TestIds["locationListLocation"] = "location-list-location";
21
+ })(TestIds || (TestIds = {}));
22
+ /**
23
+ * Root component that provides the LocationList service context for rendering locations lists.
24
+ *
25
+ * @component
26
+ * @example
27
+ * ```tsx
28
+ * import { LocationList, Location } from '@wix/bookings/react';
29
+ *
30
+ * function LocationsPage({ locationListConfig }) {
31
+ * return (
32
+ * <LocationList.Root locationListConfig={locationListConfig}>
33
+ * <LocationList.Locations emptyState={<div>No locations available</div>}>
34
+ * <LocationList.LocationRepeater>
35
+ * <Location.Name />
36
+ * <Location.Address />
37
+ * </LocationList.LocationRepeater>
38
+ * </LocationList.Locations>
39
+ * </LocationList.Root>
40
+ * );
41
+ * }
42
+ * ```
43
+ */
44
+ export const Root = React.forwardRef((props, ref) => {
45
+ const { children, locationListConfig, className, variant } = props;
46
+ const config = locationListConfig || {
47
+ locations: [],
48
+ };
49
+ return (_jsx(CoreLocationList.Root, { locationListServiceConfig: config, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, children: children }) }));
50
+ });
51
+ Root.displayName = 'LocationList.Root';
52
+ /**
53
+ * Internal component to handle the Root content with service access
54
+ */
55
+ const RootContent = React.forwardRef((props, ref) => {
56
+ const { children, className, variant } = props;
57
+ return (_jsx(CoreLocationList.Locations, { children: ({ displayLocations, isLoading }) => {
58
+ // Items already have id from DisplayLocation
59
+ return (_jsx(GenericList.Root, { items: displayLocations, hasMore: false, isLoading: isLoading, className: className, ref: ref, "data-testid": TestIds.locationListRoot, variant: variant, children: children }));
60
+ } }));
61
+ });
62
+ RootContent.displayName = 'LocationList.RootContent';
63
+ /**
64
+ * Container for the locations list with empty state support.
65
+ * Wraps GenericList.Items internally (no separate Items export).
66
+ *
67
+ * @component
68
+ * @example
69
+ * ```tsx
70
+ * <LocationList.Locations emptyState={<div>No locations available</div>}>
71
+ * <LocationList.LocationRepeater>
72
+ * <Location.Name />
73
+ * <Location.Address />
74
+ * </LocationList.LocationRepeater>
75
+ * </LocationList.Locations>
76
+ * ```
77
+ */
78
+ export const Locations = React.forwardRef((props, ref) => {
79
+ const { children, ...otherProps } = props;
80
+ return (_jsx(GenericList.Items, { ref: ref, "data-testid": TestIds.locationListLocations, ...otherProps, children: children }));
81
+ });
82
+ Locations.displayName = 'LocationList.Locations';
83
+ export const LocationRepeater = React.forwardRef((props, ref) => {
84
+ const { children } = props;
85
+ // Custom itemWrapper that wraps each item in Location.Root
86
+ const locationItemWrapper = ({ item: displayLocation, children: itemChildren, }) => {
87
+ // Convert DisplayLocation to LocationInput
88
+ // If location is null, create a SyntheticLocation
89
+ const location = displayLocation.location ?? {
90
+ locationType: displayLocation.type,
91
+ synthetic: true,
92
+ id: displayLocation.id,
93
+ };
94
+ 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));
95
+ };
96
+ return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: locationItemWrapper, children: children }));
97
+ });
98
+ LocationRepeater.displayName = 'LocationList.LocationRepeater';
99
+ /**
100
+ * Displays the total count of locations.
101
+ *
102
+ * @component
103
+ * @example
104
+ * ```tsx
105
+ * <LocationList.Totals />
106
+ *
107
+ * // With asChild
108
+ * <LocationList.Totals asChild>
109
+ * {({ count }) => <span>{count} locations available</span>}
110
+ * </LocationList.Totals>
111
+ * ```
112
+ */
113
+ export const Totals = React.forwardRef((props, ref) => {
114
+ const { asChild, children, className, ...attrs } = props;
115
+ return (_jsx(CoreLocationList.Locations, { children: ({ displayLocations, hasLocations }) => {
116
+ const count = displayLocations.length;
117
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { count, hasLocations }, ...attrs, children: _jsx("span", { children: count }) }));
118
+ } }));
119
+ });
120
+ Totals.displayName = 'LocationList.Totals';
@@ -393,6 +393,7 @@ export interface LocationsProps {
393
393
  * Container for service locations list (Container Level).
394
394
  * Follows the 3-level List/Options/Repeater pattern.
395
395
  * Provides context and doesn't render when there are no locations.
396
+ * Internally uses LocationList.Root for consistent location handling.
396
397
  *
397
398
  * @component
398
399
  * @example
@@ -401,14 +402,8 @@ export interface LocationsProps {
401
402
  * <Service.Locations>
402
403
  * <Service.Locations.List emptyState={<div>No locations available</div>}>
403
404
  * <Service.Locations.LocationRepeater>
404
- * {({ location }) => (
405
- * <div>
406
- * <span>{location.name}</span>
407
- * <Address.Root address={location.address}>
408
- * <Address.Formatted />
409
- * </Address.Root>
410
- * </div>
411
- * )}
405
+ * <Location.Name />
406
+ * <Location.Address />
412
407
  * </Service.Locations.LocationRepeater>
413
408
  * </Service.Locations.List>
414
409
  * </Service.Locations>
@@ -418,7 +413,7 @@ export interface LocationsProps {
418
413
  * <ul className="locations-list">
419
414
  * <Service.Locations.List>
420
415
  * <Service.Locations.LocationRepeater>
421
- * {({ location }) => <li>{location.name}</li>}
416
+ * <li><Location.Name /></li>
422
417
  * </Service.Locations.LocationRepeater>
423
418
  * </Service.Locations.List>
424
419
  * </ul>
@@ -437,6 +432,7 @@ export interface LocationsListProps {
437
432
  /**
438
433
  * List container for locations with empty state support (List Container Level).
439
434
  * Renders emptyState when no locations, otherwise renders children.
435
+ * Internally delegates to LocationList.Locations.
440
436
  *
441
437
  * @component
442
438
  * @example
@@ -462,32 +458,29 @@ export interface LocationRepeaterRenderProps {
462
458
  * Props for Service Locations.LocationRepeater component
463
459
  */
464
460
  export interface LocationRepeaterProps {
465
- children?: React.ReactNode | ((props: LocationRepeaterRenderProps) => React.ReactNode);
466
- asChild?: boolean;
461
+ children?: React.ReactNode;
467
462
  }
468
463
  /**
469
464
  * Repeater component that renders Location.Root for each location.
470
- * Supports asChild pattern for custom rendering.
465
+ * Internally delegates to LocationList.LocationRepeater.
466
+ * Children are rendered inside each Location.Root context.
471
467
  *
472
468
  * @component
473
469
  * @example
474
470
  * ```tsx
475
471
  * // Standard usage - renders Location.Root for each location
476
472
  * <Service.Locations.LocationRepeater>
477
- * <span className="location-badge">📍</span>
473
+ * <Location.Name />
474
+ * <Location.Address />
478
475
  * </Service.Locations.LocationRepeater>
479
476
  *
480
- * // AsChild usage with custom numbered list
481
- * <Service.Locations.LocationRepeater asChild>
482
- * {({ items, itemWrapper }) => (
483
- * <ol>
484
- * {items.map((item, index) => (
485
- * <li key={item.id}>
486
- * {index + 1}. {itemWrapper({ item, index, children: null })}
487
- * </li>
488
- * ))}
489
- * </ol>
490
- * )}
477
+ * // With custom styling
478
+ * <Service.Locations.LocationRepeater>
479
+ * <div className="location-card">
480
+ * <Location.Name className="font-bold" />
481
+ * <Location.Address />
482
+ * <Location.Phone />
483
+ * </div>
491
484
  * </Service.Locations.LocationRepeater>
492
485
  * ```
493
486
  */
@@ -8,7 +8,9 @@ import * as CoreService from '../core/service/Service.js';
8
8
  import { AsChildSlot } from '@wix/headless-utils/react';
9
9
  import { Money, GenericList } from '@wix/headless-components/react';
10
10
  import { RateType, } from '@wix/auto_sdk_bookings_services';
11
- import * as Location from '../location/Location.js';
11
+ import * as LocationList from '../location/LocationList.js';
12
+ // Note: Location components are used inside LocationList.LocationRepeater
13
+ // Users should import { Location } from '@wix/headless-bookings/react' for Location.Name, Location.Address, etc.
12
14
  import * as ServiceMediaModule from './ServiceMedia.js';
13
15
  var TestIds;
14
16
  (function (TestIds) {
@@ -353,6 +355,7 @@ Category.displayName = 'Service.Category';
353
355
  * Container for service locations list (Container Level).
354
356
  * Follows the 3-level List/Options/Repeater pattern.
355
357
  * Provides context and doesn't render when there are no locations.
358
+ * Internally uses LocationList.Root for consistent location handling.
356
359
  *
357
360
  * @component
358
361
  * @example
@@ -361,14 +364,8 @@ Category.displayName = 'Service.Category';
361
364
  * <Service.Locations>
362
365
  * <Service.Locations.List emptyState={<div>No locations available</div>}>
363
366
  * <Service.Locations.LocationRepeater>
364
- * {({ location }) => (
365
- * <div>
366
- * <span>{location.name}</span>
367
- * <Address.Root address={location.address}>
368
- * <Address.Formatted />
369
- * </Address.Root>
370
- * </div>
371
- * )}
367
+ * <Location.Name />
368
+ * <Location.Address />
372
369
  * </Service.Locations.LocationRepeater>
373
370
  * </Service.Locations.List>
374
371
  * </Service.Locations>
@@ -378,7 +375,7 @@ Category.displayName = 'Service.Category';
378
375
  * <ul className="locations-list">
379
376
  * <Service.Locations.List>
380
377
  * <Service.Locations.LocationRepeater>
381
- * {({ location }) => <li>{location.name}</li>}
378
+ * <li><Location.Name /></li>
382
379
  * </Service.Locations.LocationRepeater>
383
380
  * </Service.Locations.List>
384
381
  * </ul>
@@ -392,18 +389,14 @@ const LocationsBase = React.forwardRef((props, ref) => {
392
389
  if (!locations || locations.length === 0) {
393
390
  return null;
394
391
  }
395
- // Map locations to include required id field for GenericList
396
- const items = locations.map((location, index) => ({
397
- ...location,
398
- id: location._id || String(index),
399
- }));
400
- return (_jsx(GenericList.Root, { items: items, children: _jsx(AsChildSlot, { ...attributes, ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceLocations, customElement: children, children: _jsx("div", { children: React.isValidElement(children) ? children : null }) }) }));
392
+ return (_jsx(LocationList.Root, { locationListConfig: { locations }, className: className, ref: ref, children: _jsx(AsChildSlot, { ...attributes, asChild: asChild, className: className, "data-testid": TestIds.serviceLocations, customElement: children, children: _jsx("div", { children: children }) }) }));
401
393
  } }));
402
394
  });
403
395
  LocationsBase.displayName = 'Service.Locations';
404
396
  /**
405
397
  * List container for locations with empty state support (List Container Level).
406
398
  * Renders emptyState when no locations, otherwise renders children.
399
+ * Internally delegates to LocationList.Locations.
407
400
  *
408
401
  * @component
409
402
  * @example
@@ -415,42 +408,36 @@ LocationsBase.displayName = 'Service.Locations';
415
408
  */
416
409
  export const LocationsList = React.forwardRef((props, ref) => {
417
410
  const { children, emptyState, className, ...otherProps } = props;
418
- return (_jsx(GenericList.Items, { ref: ref, emptyState: emptyState, className: className, ...otherProps, children: children }));
411
+ return (_jsx(LocationList.Locations, { ref: ref, emptyState: emptyState, className: className, ...otherProps, children: children }));
419
412
  });
420
413
  LocationsList.displayName = 'Service.Locations.List';
421
414
  /**
422
415
  * Repeater component that renders Location.Root for each location.
423
- * Supports asChild pattern for custom rendering.
416
+ * Internally delegates to LocationList.LocationRepeater.
417
+ * Children are rendered inside each Location.Root context.
424
418
  *
425
419
  * @component
426
420
  * @example
427
421
  * ```tsx
428
422
  * // Standard usage - renders Location.Root for each location
429
423
  * <Service.Locations.LocationRepeater>
430
- * <span className="location-badge">📍</span>
424
+ * <Location.Name />
425
+ * <Location.Address />
431
426
  * </Service.Locations.LocationRepeater>
432
427
  *
433
- * // AsChild usage with custom numbered list
434
- * <Service.Locations.LocationRepeater asChild>
435
- * {({ items, itemWrapper }) => (
436
- * <ol>
437
- * {items.map((item, index) => (
438
- * <li key={item.id}>
439
- * {index + 1}. {itemWrapper({ item, index, children: null })}
440
- * </li>
441
- * ))}
442
- * </ol>
443
- * )}
428
+ * // With custom styling
429
+ * <Service.Locations.LocationRepeater>
430
+ * <div className="location-card">
431
+ * <Location.Name className="font-bold" />
432
+ * <Location.Address />
433
+ * <Location.Phone />
434
+ * </div>
444
435
  * </Service.Locations.LocationRepeater>
445
436
  * ```
446
437
  */
447
438
  export const LocationRepeater = React.forwardRef((props, ref) => {
448
- const { children, asChild } = props;
449
- // Custom itemWrapper that renders Location.Root for each location
450
- const locationItemWrapper = ({ item: location, children: itemChildren, }) => {
451
- return (_jsx(Location.Root, { location: location, "data-testid": TestIds.serviceLocationRepeater, children: itemChildren || undefined }, location.id));
452
- };
453
- return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: locationItemWrapper, asChild: asChild, children: children }));
439
+ const { children } = props;
440
+ return (_jsx(LocationList.LocationRepeater, { ref: ref, children: children }));
454
441
  });
455
442
  LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
456
443
  /**
@@ -635,6 +622,7 @@ export var Actions;
635
622
  selected,
636
623
  bookable,
637
624
  requiresAvailability,
625
+ service: rawService,
638
626
  }, children: _jsx("button", { onClick: handleClick, disabled: !bookable, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, children: label }) }));
639
627
  } }));
640
628
  });
@@ -9,3 +9,4 @@ export { ServiceListService, ServiceListServiceDefinition, type ServiceListServi
9
9
  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
10
  export { BookingFormService, BookingFormServiceDefinition, type BookingFormServiceAPI, type BookingFormServiceConfig, type BookingFormServiceInternalAPI, type ValidationResult, } from './booking-form/booking-form.js';
11
11
  export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type SlotService, 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';
@@ -9,3 +9,4 @@ export { ServiceListService, ServiceListServiceDefinition, loadServiceListServic
9
9
  export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, } from './booking/book-action/index.js';
10
10
  export { BookingFormService, BookingFormServiceDefinition, } from './booking-form/booking-form.js';
11
11
  export { PaymentService, PaymentServiceDefinition, loadPaymentConfig, } from './payment/payment.js';
12
+ export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, } from './location-list/location-list.js';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Location List Service Implementation
3
+ * Manages location state, auto-detection, and BookingService integration
4
+ *
5
+ * @module Services/LocationList
6
+ */
7
+ import type { ServiceFactoryConfig } from '@wix/services-definitions';
8
+ import { type LocationData } from './location-list.def.js';
9
+ /**
10
+ * Configuration interface for LocationListService
11
+ */
12
+ export interface LocationListServiceConfig {
13
+ /** Locations array (can include any type: BUSINESS, CUSTOM, CUSTOMER) */
14
+ locations?: LocationData[];
15
+ /** Explicit flag for custom locations (overrides auto-detection) */
16
+ hasCustomLocations?: boolean;
17
+ /** Explicit flag for customer locations (overrides auto-detection) */
18
+ hasCustomerLocations?: boolean;
19
+ }
20
+ /**
21
+ * Implementation of the LocationList service
22
+ * Manages location state and integrates with BookingService for selection (optional)
23
+ */
24
+ export declare const LocationListService: import("@wix/services-definitions").ServiceFactory<string & {
25
+ __api: import("./location-list.def.js").LocationListServiceAPI;
26
+ __config: {};
27
+ isServiceDefinition?: boolean;
28
+ } & import("./location-list.def.js").LocationListServiceAPI, LocationListServiceConfig>;
29
+ /**
30
+ * Result type for SSR loader
31
+ */
32
+ export type LoadLocationListServiceResult = {
33
+ type: 'success';
34
+ config: LocationListServiceConfig;
35
+ } | {
36
+ type: 'error';
37
+ error: string;
38
+ };
39
+ /**
40
+ * SSR Loader: Fetches locations from API for server-side rendering.
41
+ *
42
+ * @param options - Optional configuration
43
+ * @returns Configuration result for LocationListService with pre-fetched locations
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // Fetch from API
48
+ * const result = await loadLocationListServiceInitialData();
49
+ *
50
+ * if (result.type === 'error') {
51
+ * return Astro.redirect('/500');
52
+ * }
53
+ *
54
+ * const locationListConfig = result.config;
55
+ * ```
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * // Pass locations directly (e.g., from service.locations)
60
+ * const result = await loadLocationListServiceInitialData({
61
+ * locations: service.locations,
62
+ * // hasCustom/hasCustomer will be auto-detected from array
63
+ * });
64
+ * ```
65
+ */
66
+ export declare function loadLocationListServiceInitialData(options?: {
67
+ /** Pass locations directly instead of fetching */
68
+ locations?: LocationData[];
69
+ /** Explicit flag for custom locations */
70
+ hasCustomLocations?: boolean;
71
+ /** Explicit flag for customer locations */
72
+ hasCustomerLocations?: boolean;
73
+ }): Promise<LoadLocationListServiceResult>;
74
+ /**
75
+ * Service binding helper for LocationListService.
76
+ * Bundles definition, implementation, and config for ServicesManager.
77
+ *
78
+ * @param servicesConfigs - Object containing LocationListServiceDefinition config
79
+ * @returns Tuple of [Definition, Implementation, Config] for addService()
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const servicesManager = createServicesManager(
84
+ * createServicesMap()
85
+ * .addService(...locationListServiceBinding(configs))
86
+ * );
87
+ * ```
88
+ */
89
+ export declare const locationListServiceBinding: <T extends {
90
+ [key: string]: LocationListServiceConfig;
91
+ }>(servicesConfigs: T) => readonly [string & {
92
+ __api: import("./location-list.def.js").LocationListServiceAPI;
93
+ __config: {};
94
+ isServiceDefinition?: boolean;
95
+ } & import("./location-list.def.js").LocationListServiceAPI, import("@wix/services-definitions").ServiceFactory<string & {
96
+ __api: import("./location-list.def.js").LocationListServiceAPI;
97
+ __config: {};
98
+ isServiceDefinition?: boolean;
99
+ } & import("./location-list.def.js").LocationListServiceAPI, LocationListServiceConfig>, LocationListServiceConfig];
100
+ export { LocationListServiceDefinition, LocationType, type LocationData, type DisplayLocation, type LocationListActions, type LocationListServiceAPI, } from './location-list.def.js';
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Location List Service Definition
3
+ * Defines types and service interface for managing location lists
4
+ *
5
+ * @module Services/LocationList/Definition
6
+ */
7
+ import type { Signal, ReadOnlySignal } from '@wix/services-definitions/core-services/signals';
8
+ import { LocationType, type Service } from '@wix/auto_sdk_bookings_services';
9
+ /**
10
+ * LocationData type - from Service['locations'][number]
11
+ */
12
+ export type LocationData = NonNullable<Service['locations']>[number];
13
+ /**
14
+ * Display location wrapper - includes metadata for rendering
15
+ */
16
+ export interface DisplayLocation {
17
+ /** Original location data, null for synthetic entries */
18
+ location: LocationData | null;
19
+ /** Location type */
20
+ type: LocationType;
21
+ /** True if created from flag (not from array) */
22
+ isSynthetic: boolean;
23
+ /** Unique ID for list rendering */
24
+ id: string;
25
+ }
26
+ /**
27
+ * Actions interface for location list management
28
+ */
29
+ export interface LocationListActions {
30
+ /** Select a location (updates BookingService.location if available) */
31
+ select: (displayLocation: DisplayLocation) => void;
32
+ }
33
+ /**
34
+ * API interface for the LocationList service
35
+ */
36
+ export interface LocationListServiceAPI {
37
+ /** Reactive signal containing the raw locations array */
38
+ locations: Signal<LocationData[]>;
39
+ /** Reactive signal containing the display locations (processed for UI) */
40
+ displayLocations: ReadOnlySignal<DisplayLocation[]>;
41
+ /** Whether custom locations exist */
42
+ hasCustomLocations: ReadOnlySignal<boolean>;
43
+ /** Whether customer locations exist */
44
+ hasCustomerLocations: ReadOnlySignal<boolean>;
45
+ /** Reactive signal indicating if locations are loading */
46
+ isLoading: Signal<boolean>;
47
+ /** Reactive signal containing any error message */
48
+ error: Signal<string | null>;
49
+ /** Computed signal for selected location (from BookingService, null if standalone) */
50
+ selectedLocation: ReadOnlySignal<LocationData | null>;
51
+ /** Actions for location management */
52
+ actions: LocationListActions;
53
+ }
54
+ /**
55
+ * Service definition for LocationList
56
+ */
57
+ export declare const LocationListServiceDefinition: string & {
58
+ __api: LocationListServiceAPI;
59
+ __config: {};
60
+ isServiceDefinition?: boolean;
61
+ } & LocationListServiceAPI;
62
+ export { LocationType };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Location List Service Definition
3
+ * Defines types and service interface for managing location lists
4
+ *
5
+ * @module Services/LocationList/Definition
6
+ */
7
+ import { defineService } from '@wix/services-definitions';
8
+ import { LocationType } from '@wix/auto_sdk_bookings_services';
9
+ // ============================================================================
10
+ // Service Definition
11
+ // ============================================================================
12
+ /**
13
+ * Service definition for LocationList
14
+ */
15
+ export const LocationListServiceDefinition = defineService('location-list');
16
+ // Re-export LocationType for consumers
17
+ export { LocationType };