@wix/headless-bookings 0.0.10 → 0.0.11

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 (61) hide show
  1. package/cjs/dist/api/index.d.ts +10 -1
  2. package/cjs/dist/api/index.js +10 -1
  3. package/cjs/dist/api/query-services/index.d.ts +78 -0
  4. package/cjs/dist/api/query-services/index.js +137 -0
  5. package/cjs/dist/react/core/location/Location.d.ts +44 -0
  6. package/cjs/dist/react/core/location/Location.js +78 -0
  7. package/cjs/dist/react/core/service/Service.d.ts +160 -17
  8. package/cjs/dist/react/core/service/Service.js +211 -13
  9. package/cjs/dist/react/core/service-list/ServiceList.d.ts +75 -0
  10. package/cjs/dist/react/core/service-list/ServiceList.js +58 -0
  11. package/cjs/dist/react/index.d.ts +2 -0
  12. package/cjs/dist/react/index.js +2 -0
  13. package/cjs/dist/react/location/Location.d.ts +77 -0
  14. package/cjs/dist/react/location/Location.js +89 -0
  15. package/cjs/dist/react/service/Service.d.ts +1036 -31
  16. package/cjs/dist/react/service/Service.js +1060 -47
  17. package/cjs/dist/react/service-list/ServiceList.d.ts +185 -0
  18. package/cjs/dist/react/service-list/ServiceList.js +184 -0
  19. package/cjs/dist/services/index.d.ts +2 -1
  20. package/cjs/dist/services/index.js +2 -1
  21. package/cjs/dist/services/service/service.d.ts +71 -18
  22. package/cjs/dist/services/service/service.js +186 -50
  23. package/cjs/dist/services/service-list/service-list.d.ts +157 -0
  24. package/cjs/dist/services/service-list/service-list.js +274 -0
  25. package/cjs/dist/utils/dateAndTime.d.ts +2 -0
  26. package/cjs/dist/utils/dateAndTime.js +18 -0
  27. package/cjs/dist/utils/money.d.ts +21 -0
  28. package/cjs/dist/utils/money.js +34 -0
  29. package/dist/api/index.d.ts +10 -1
  30. package/dist/api/index.js +10 -1
  31. package/dist/api/query-services/index.d.ts +78 -0
  32. package/dist/api/query-services/index.js +137 -0
  33. package/dist/react/core/location/Location.d.ts +44 -0
  34. package/dist/react/core/location/Location.js +78 -0
  35. package/dist/react/core/service/Service.d.ts +160 -17
  36. package/dist/react/core/service/Service.js +211 -13
  37. package/dist/react/core/service-list/ServiceList.d.ts +75 -0
  38. package/dist/react/core/service-list/ServiceList.js +58 -0
  39. package/dist/react/index.d.ts +2 -0
  40. package/dist/react/index.js +2 -0
  41. package/dist/react/location/Location.d.ts +77 -0
  42. package/dist/react/location/Location.js +89 -0
  43. package/dist/react/service/Service.d.ts +1036 -31
  44. package/dist/react/service/Service.js +1060 -47
  45. package/dist/react/service-list/ServiceList.d.ts +185 -0
  46. package/dist/react/service-list/ServiceList.js +184 -0
  47. package/dist/services/index.d.ts +2 -1
  48. package/dist/services/index.js +2 -1
  49. package/dist/services/service/service.d.ts +71 -18
  50. package/dist/services/service/service.js +186 -50
  51. package/dist/services/service-list/service-list.d.ts +157 -0
  52. package/dist/services/service-list/service-list.js +274 -0
  53. package/dist/utils/dateAndTime.d.ts +2 -0
  54. package/dist/utils/dateAndTime.js +18 -0
  55. package/dist/utils/money.d.ts +21 -0
  56. package/dist/utils/money.js +34 -0
  57. package/package.json +2 -2
  58. package/cjs/dist/api/query-service/index.d.ts +0 -23
  59. package/cjs/dist/api/query-service/index.js +0 -41
  60. package/dist/api/query-service/index.d.ts +0 -23
  61. package/dist/api/query-service/index.js +0 -41
@@ -0,0 +1,185 @@
1
+ /**
2
+ * ServiceList - High-level component for displaying services list
3
+ * Provides components for displaying services list with pagination
4
+ */
5
+ import React from 'react';
6
+ import { ListVariant, GenericListLoadMoreRenderProps } from '@wix/headless-components/react';
7
+ import { AsChildChildren } from '@wix/headless-utils/react';
8
+ import type { ServiceListServiceConfig } from '../../services/service-list/service-list.js';
9
+ import type { services } from '@wix/bookings';
10
+ /**
11
+ * Props for the ServiceList root component
12
+ */
13
+ export interface ServiceListRootProps {
14
+ children: React.ReactNode;
15
+ serviceListConfig?: ServiceListServiceConfig;
16
+ className?: string;
17
+ variant?: ListVariant;
18
+ }
19
+ /**
20
+ * Root component that provides the ServiceList service context for rendering services lists.
21
+ *
22
+ * @order 1
23
+ * @component
24
+ * @example
25
+ * ```tsx
26
+ * import { ServiceList } from '@wix/bookings/components';
27
+ *
28
+ * function ServicesPage({ serviceListConfig }) {
29
+ * return (
30
+ * <ServiceList.Root serviceListConfig={serviceListConfig}>
31
+ * <ServiceList.Services emptyState={<div>No services available</div>}>
32
+ * <ServiceList.ServiceRepeater>
33
+ * <Service.Name />
34
+ * <Service.Price />
35
+ * </ServiceList.ServiceRepeater>
36
+ * </ServiceList.Services>
37
+ * </ServiceList.Root>
38
+ * );
39
+ * }
40
+ * ```
41
+ */
42
+ export declare const Root: React.ForwardRefExoticComponent<ServiceListRootProps & React.RefAttributes<HTMLElement>>;
43
+ /**
44
+ * Props for ServiceList Services component
45
+ */
46
+ export interface ServicesProps {
47
+ children: React.ReactNode;
48
+ emptyState?: React.ReactNode;
49
+ infiniteScroll?: boolean;
50
+ pageSize?: number;
51
+ className?: string;
52
+ }
53
+ /**
54
+ * Container for the services list with empty state support.
55
+ * Wraps GenericList.Items. Follows List Container Level pattern.
56
+ *
57
+ * @component
58
+ * @example
59
+ * ```tsx
60
+ * <ServiceList.Services emptyState={<div>No services found</div>}>
61
+ * <ServiceList.ServiceRepeater>
62
+ * <Service.Name />
63
+ * <Service.Price />
64
+ * </ServiceList.ServiceRepeater>
65
+ * </ServiceList.Services>
66
+ * ```
67
+ */
68
+ export declare const Services: React.ForwardRefExoticComponent<ServicesProps & React.RefAttributes<HTMLElement>>;
69
+ /**
70
+ * Function children type for Service.Root component
71
+ * Receives { selected, bookable } props from Service.Root
72
+ */
73
+ export type ServiceRootChildren = AsChildChildren<{
74
+ selected: boolean;
75
+ bookable: boolean;
76
+ }>;
77
+ /**
78
+ * Props for the itemWrapper function in asChild pattern
79
+ * Supports both ReactNode and function children that receive { selected, bookable }
80
+ */
81
+ export interface ServiceItemWrapperProps {
82
+ item: services.Service;
83
+ index?: number;
84
+ /** Children can be ReactNode or a function that receives { selected, bookable } from Service.Root */
85
+ children: React.ReactNode | ServiceRootChildren;
86
+ }
87
+ /**
88
+ * Render props for ServiceRepeater asChild pattern
89
+ * Provides items array and itemWrapper function for custom rendering
90
+ */
91
+ export interface ServiceRepeaterRenderProps {
92
+ items: services.Service[];
93
+ variant?: ListVariant;
94
+ /** Wraps each item in Service.Root - children can be ReactNode or function receiving { selected, bookable } */
95
+ itemWrapper: (props: ServiceItemWrapperProps) => React.ReactNode;
96
+ }
97
+ /**
98
+ * Props for ServiceList ServiceRepeater component
99
+ */
100
+ export interface ServiceRepeaterProps {
101
+ /**
102
+ * Children can be:
103
+ * - ReactNode: Static content rendered for each service
104
+ * - ServiceRootChildren: Function receiving { selected, bookable } from Service.Root
105
+ * - Function (with asChild=true): Receives { items, itemWrapper } for custom rendering
106
+ */
107
+ children: React.ReactNode | ((props: ServiceRepeaterRenderProps, ref?: React.Ref<HTMLElement>) => React.ReactNode) | ServiceRootChildren;
108
+ /** Whether to render as child component (asChild pattern) */
109
+ asChild?: boolean;
110
+ }
111
+ /**
112
+ * Repeater component that renders Service.Root for each service.
113
+ * Follows Repeater Level pattern and uses GenericList.Repeater for consistency.
114
+ * Supports asChild pattern for advanced layout components.
115
+ *
116
+ * @component
117
+ * @example
118
+ * ```tsx
119
+ * // Standard usage
120
+ * <ServiceList.ServiceRepeater>
121
+ * <Service.Name />
122
+ * <Service.Price />
123
+ * </ServiceList.ServiceRepeater>
124
+ *
125
+ * // AsChild usage with custom wrapper
126
+ * <ServiceList.ServiceRepeater asChild>
127
+ * {({ items, variant, itemWrapper }) => (
128
+ * <CustomWrapper
129
+ * items={items}
130
+ * variant={variant}
131
+ * itemRenderer={(item, index) =>
132
+ * itemWrapper({ item, index, children: <>
133
+ * <Service.Name />
134
+ * <Service.Price />
135
+ * </> })
136
+ * }
137
+ * />
138
+ * )}
139
+ * </ServiceList.ServiceRepeater>
140
+ * ```
141
+ */
142
+ export declare const ServiceRepeater: React.ForwardRefExoticComponent<ServiceRepeaterProps & React.RefAttributes<HTMLElement>>;
143
+ /**
144
+ * Props for ServiceList LoadMore component
145
+ */
146
+ export interface LoadMoreProps {
147
+ /** Custom render function when using asChild */
148
+ children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLButtonElement, GenericListLoadMoreRenderProps>;
149
+ /**
150
+ * Whether to render as a child component.
151
+ * @default false
152
+ */
153
+ asChild?: boolean;
154
+ /**
155
+ * The CSS classes to apply to the button.
156
+ */
157
+ className?: string;
158
+ /**
159
+ * The label to display inside the button.
160
+ */
161
+ label?: string;
162
+ /**
163
+ * The loading state to display inside the button.
164
+ */
165
+ loadingState?: React.ReactNode;
166
+ }
167
+ /**
168
+ * Displays a button to load more services. Not rendered if infiniteScroll is false or no services are left to load.
169
+ * Follows the architecture rules - does not support asChild as it's a simple trigger component.
170
+ *
171
+ * @component
172
+ * @example
173
+ * ```tsx
174
+ * <ServiceList.Actions.LoadMore asChild>
175
+ * <button>Load More</button>
176
+ * </ServiceList.Actions.LoadMore>
177
+ * ```
178
+ */
179
+ export declare const LoadMore: React.ForwardRefExoticComponent<LoadMoreProps & React.RefAttributes<HTMLButtonElement>>;
180
+ /**
181
+ * Actions namespace for ServiceList
182
+ */
183
+ export declare const Actions: {
184
+ LoadMore: React.ForwardRefExoticComponent<LoadMoreProps & React.RefAttributes<HTMLButtonElement>>;
185
+ };
@@ -0,0 +1,184 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * ServiceList - High-level component for displaying services list
4
+ * Provides components for displaying services list with pagination
5
+ */
6
+ import React from 'react';
7
+ import { GenericList, } from '@wix/headless-components/react';
8
+ import { useService } from '@wix/services-manager-react';
9
+ import { ServiceListServiceDefinition } from '../../services/service-list/service-list.js';
10
+ import * as CoreServiceList from '../core/service-list/ServiceList.js';
11
+ import * as Service from '../service/Service.js';
12
+ /**
13
+ * Booking app ID constant
14
+ */
15
+ const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
16
+ var TestIds;
17
+ (function (TestIds) {
18
+ TestIds["serviceListRoot"] = "service-list-root";
19
+ TestIds["serviceListServices"] = "service-list-services";
20
+ TestIds["serviceListService"] = "service-list-service";
21
+ TestIds["serviceListLoadMore"] = "service-list-load-more";
22
+ })(TestIds || (TestIds = {}));
23
+ /**
24
+ * Root component that provides the ServiceList service context for rendering services lists.
25
+ *
26
+ * @order 1
27
+ * @component
28
+ * @example
29
+ * ```tsx
30
+ * import { ServiceList } from '@wix/bookings/components';
31
+ *
32
+ * function ServicesPage({ serviceListConfig }) {
33
+ * return (
34
+ * <ServiceList.Root serviceListConfig={serviceListConfig}>
35
+ * <ServiceList.Services emptyState={<div>No services available</div>}>
36
+ * <ServiceList.ServiceRepeater>
37
+ * <Service.Name />
38
+ * <Service.Price />
39
+ * </ServiceList.ServiceRepeater>
40
+ * </ServiceList.Services>
41
+ * </ServiceList.Root>
42
+ * );
43
+ * }
44
+ * ```
45
+ */
46
+ export const Root = React.forwardRef((props, ref) => {
47
+ const { children, serviceListConfig, className, variant } = props;
48
+ const serviceConfig = serviceListConfig || {
49
+ services: [],
50
+ options: {
51
+ appId: BOOKING_APP_ID,
52
+ pagingMetadata: {
53
+ limit: 0,
54
+ offset: 0,
55
+ hasNext: false,
56
+ },
57
+ },
58
+ };
59
+ return (_jsx(CoreServiceList.Root, { serviceListConfig: serviceConfig, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, children: children }) }));
60
+ });
61
+ Root.displayName = 'ServiceList.Root';
62
+ /**
63
+ * Internal component to handle the Root content with service access
64
+ */
65
+ const RootContent = React.forwardRef((props, ref) => {
66
+ const { children, className, variant } = props;
67
+ const serviceListService = useService(ServiceListServiceDefinition);
68
+ const items = serviceListService.servicesSignal
69
+ .get()
70
+ .map((service) => ({
71
+ ...service,
72
+ id: service._id,
73
+ }));
74
+ return (_jsx(GenericList.Root, { items: items, loadMore: () => serviceListService.actions.loadMore(10), hasMore: serviceListService.hasMoreServicesSignal.get(), isLoading: serviceListService.isLoadingSignal.get(), className: className, ref: ref, "data-testid": TestIds.serviceListRoot, variant: variant, children: children }));
75
+ });
76
+ /**
77
+ * Container for the services list with empty state support.
78
+ * Wraps GenericList.Items. Follows List Container Level pattern.
79
+ *
80
+ * @component
81
+ * @example
82
+ * ```tsx
83
+ * <ServiceList.Services emptyState={<div>No services found</div>}>
84
+ * <ServiceList.ServiceRepeater>
85
+ * <Service.Name />
86
+ * <Service.Price />
87
+ * </ServiceList.ServiceRepeater>
88
+ * </ServiceList.Services>
89
+ * ```
90
+ */
91
+ export const Services = React.forwardRef((props, ref) => {
92
+ const { children, ...otherProps } = props;
93
+ return (_jsx(GenericList.Items, { ref: ref, "data-testid": TestIds.serviceListServices, ...otherProps, children: children }));
94
+ });
95
+ Services.displayName = 'ServiceList.Services';
96
+ /**
97
+ * Repeater component that renders Service.Root for each service.
98
+ * Follows Repeater Level pattern and uses GenericList.Repeater for consistency.
99
+ * Supports asChild pattern for advanced layout components.
100
+ *
101
+ * @component
102
+ * @example
103
+ * ```tsx
104
+ * // Standard usage
105
+ * <ServiceList.ServiceRepeater>
106
+ * <Service.Name />
107
+ * <Service.Price />
108
+ * </ServiceList.ServiceRepeater>
109
+ *
110
+ * // AsChild usage with custom wrapper
111
+ * <ServiceList.ServiceRepeater asChild>
112
+ * {({ items, variant, itemWrapper }) => (
113
+ * <CustomWrapper
114
+ * items={items}
115
+ * variant={variant}
116
+ * itemRenderer={(item, index) =>
117
+ * itemWrapper({ item, index, children: <>
118
+ * <Service.Name />
119
+ * <Service.Price />
120
+ * </> })
121
+ * }
122
+ * />
123
+ * )}
124
+ * </ServiceList.ServiceRepeater>
125
+ * ```
126
+ */
127
+ export const ServiceRepeater = React.forwardRef((props, ref) => {
128
+ const { children, asChild } = props;
129
+ const serviceListService = useService(ServiceListServiceDefinition);
130
+ const appId = serviceListService.queryOptionsSignal.get().appId;
131
+ // Check if children is a function that matches ServiceRootChildren pattern
132
+ // (function with single parameter that receives { selected, bookable })
133
+ const isServiceRootFunction = typeof children === 'function' && children.length === 1 && !asChild;
134
+ // Custom itemWrapper that matches ItemWrapperProps signature
135
+ const serviceItemWrapper = (wrapperProps) => {
136
+ const { item: service, children: itemChildren } = wrapperProps;
137
+ return (_jsx(Service.Root, { service: service, appId: appId, "data-testid": TestIds.serviceListService, "data-service-id": service._id, "data-item-id": service._id, children: isServiceRootFunction
138
+ ? children
139
+ : itemChildren }, service._id));
140
+ };
141
+ // Transform children for asChild pattern to provide custom render props
142
+ const transformedChildren = asChild && typeof children === 'function'
143
+ ? (genericProps) => {
144
+ // Create properly typed render props for the consumer
145
+ const renderProps = {
146
+ items: genericProps.items,
147
+ variant: genericProps.variant,
148
+ itemWrapper: (props) => serviceItemWrapper({
149
+ item: props.item,
150
+ index: props.index ?? 0,
151
+ children: props.children,
152
+ }),
153
+ };
154
+ return children(renderProps, ref);
155
+ }
156
+ : isServiceRootFunction
157
+ ? undefined
158
+ : children;
159
+ return (_jsx(GenericList.Repeater, { ref: ref, asChild: asChild, itemWrapper: serviceItemWrapper, children: transformedChildren }));
160
+ });
161
+ ServiceRepeater.displayName = 'ServiceList.ServiceRepeater';
162
+ /**
163
+ * Displays a button to load more services. Not rendered if infiniteScroll is false or no services are left to load.
164
+ * Follows the architecture rules - does not support asChild as it's a simple trigger component.
165
+ *
166
+ * @component
167
+ * @example
168
+ * ```tsx
169
+ * <ServiceList.Actions.LoadMore asChild>
170
+ * <button>Load More</button>
171
+ * </ServiceList.Actions.LoadMore>
172
+ * ```
173
+ */
174
+ export const LoadMore = React.forwardRef((props, ref) => {
175
+ const { children = _jsx("button", {}), ...otherProps } = props;
176
+ return (_jsx(GenericList.Actions.LoadMore, { ref: ref, "data-testid": TestIds.serviceListLoadMore, ...otherProps, children: children }));
177
+ });
178
+ LoadMore.displayName = 'ServiceList.Actions.LoadMore';
179
+ /**
180
+ * Actions namespace for ServiceList
181
+ */
182
+ export const Actions = {
183
+ LoadMore,
184
+ };
@@ -2,5 +2,6 @@
2
2
  * Bookings Services
3
3
  * Main export file for all service definitions and implementations
4
4
  */
5
- export { ServiceService, ServiceServiceDefinition, type ServiceServiceAPI, type ServiceServiceConfig, loadServiceServiceConfig, type SuccessServiceServiceConfigResult, type NotFoundServiceServiceConfigResult, } from './service/service.js';
5
+ export { ServiceService, ServiceServiceDefinition, type ServiceServiceAPI, type ServiceServiceConfig, type ServiceActions, type ServicePaymentData, loadServiceServiceInitialData, type SuccessServiceServiceConfigResult, type NotFoundServiceServiceConfigResult, } from './service/service.js';
6
6
  export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type ServiceSelection, type Location, type BookingServiceActions, } from './booking/booking.js';
7
+ export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
@@ -2,5 +2,6 @@
2
2
  * Bookings Services
3
3
  * Main export file for all service definitions and implementations
4
4
  */
5
- export { ServiceService, ServiceServiceDefinition, loadServiceServiceConfig, } from './service/service.js';
5
+ export { ServiceService, ServiceServiceDefinition, loadServiceServiceInitialData, } from './service/service.js';
6
6
  export { BookingService, BookingServiceDefinition, } from './booking/booking.js';
7
+ export { ServiceListService, ServiceListServiceDefinition, loadServiceListServiceInitialData, } from './service-list/service-list.js';
@@ -2,8 +2,43 @@
2
2
  * Service Service - Reactive service data management
3
3
  * Handles loading and managing a single service's data, loading state, and errors.
4
4
  */
5
- import { type Signal } from '@wix/services-definitions/core-services/signals';
5
+ import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals';
6
6
  import { services } from '@wix/bookings';
7
+ import type { MoneyData } from '@wix/headless-components/react';
8
+ /**
9
+ * Actions object for service selection
10
+ */
11
+ export interface ServiceActions {
12
+ /** Replace entire selection with this service (with current modifiers) */
13
+ select: () => void;
14
+ /** Add this service to selection (with current modifiers) */
15
+ add: () => void;
16
+ /** Remove this service from selection */
17
+ remove: () => void;
18
+ }
19
+ /**
20
+ * Payment data derived from service payment information
21
+ *
22
+ * @interface ServicePaymentData
23
+ */
24
+ export interface ServicePaymentData {
25
+ /** The service payment information from the service */
26
+ servicePayment: services.Payment | undefined;
27
+ /** The rate type of the service (FIXED, VARIED, CUSTOM, NO_FEE, etc.) */
28
+ rateType: services.Payment['rateType'] | undefined;
29
+ /** Primary price (used for FIXED or VARIED default) */
30
+ money: MoneyData | null;
31
+ /** Minimum price (used for VARIED) */
32
+ minPrice: MoneyData | null;
33
+ /** Maximum price (used for VARIED) */
34
+ maxPrice: MoneyData | null;
35
+ /** Price description text (used for CUSTOM) */
36
+ priceDescription: string | null;
37
+ /** Whether the service has add-ons available */
38
+ hasAddOns: boolean;
39
+ /** Whether the service has pricing plans available */
40
+ hasPricingPlans: boolean;
41
+ }
7
42
  /**
8
43
  * API interface for the Service service, providing reactive service data management.
9
44
  *
@@ -11,19 +46,23 @@ import { services } from '@wix/bookings';
11
46
  */
12
47
  export interface ServiceServiceAPI {
13
48
  /** Reactive signal containing the current service data */
14
- service: Signal<services.Service>;
49
+ serviceSignal: Signal<services.Service>;
15
50
  /** Reactive signal indicating if a service is currently being loaded */
16
- isLoading: Signal<boolean>;
51
+ isLoadingSignal: Signal<boolean>;
17
52
  /** Reactive signal containing any error message, or null if no error */
18
- error: Signal<string | null>;
53
+ errorSignal: Signal<string | null>;
19
54
  /** Function to load a service by its id */
20
- loadService: (id: string) => Promise<void>;
21
- /** Function to select this service (replaces entire selection) */
22
- select: () => void;
23
- /** Function to add this service to the selection */
24
- add: () => void;
25
- /** Function to remove this service from the selection */
26
- remove: () => void;
55
+ loadServiceById: (id: string) => Promise<void>;
56
+ /** Indicates if BookingService is available (false in showcase mode/lead nurturing) */
57
+ bookableSignal: ReadOnlySignal<boolean>;
58
+ /** Indicates if the current service is selected in BookingService */
59
+ selectedSignal: ReadOnlySignal<boolean>;
60
+ /** Indicates if the service requires availability selection (true for APPOINTMENT and CLASS, false for COURSE) */
61
+ requiresAvailabilitySignal: ReadOnlySignal<boolean>;
62
+ /** Reactive signal containing computed payment data derived from service */
63
+ paymentDataSignal: ReadOnlySignal<ServicePaymentData>;
64
+ /** Actions object containing service selection actions (only work when bookable is true) */
65
+ actions: ServiceActions;
27
66
  }
28
67
  /**
29
68
  * Service definition for the Service service.
@@ -47,6 +86,10 @@ export interface ServiceServiceConfig {
47
86
  service?: services.Service;
48
87
  /** The service ID to load if no initial service is provided */
49
88
  serviceId?: string;
89
+ /** The service slug to load if no initial service is provided */
90
+ serviceSlug?: string;
91
+ /** The app ID to filter services by app and determine bookable */
92
+ appId?: string;
50
93
  }
51
94
  /**
52
95
  * Implementation of the Service service that manages reactive service data.
@@ -70,9 +113,9 @@ export interface ServiceServiceConfig {
70
113
  *
71
114
  * function ServiceDisplay() {
72
115
  * const serviceService = useService(ServiceServiceDefinition);
73
- * const service = serviceService.service.get();
74
- * const isLoading = serviceService.isLoading.get();
75
- * const error = serviceService.error.get();
116
+ * const service = serviceService.serviceSignal.get();
117
+ * const isLoading = serviceService.isLoadingSignal.get();
118
+ * const error = serviceService.errorSignal.get();
76
119
  *
77
120
  * if (isLoading) return <div>Loading...</div>;
78
121
  * if (error) return <div>Error: {error}</div>;
@@ -101,15 +144,19 @@ export type NotFoundServiceServiceConfigResult = {
101
144
  * This function is designed to be called during the build or server-side rendering phase
102
145
  * to pre-fetch service data before the React components are hydrated on the client.
103
146
  *
104
- * @param slug - The slug of the service to load (e.g., "group-trainings", "yoga-class")
147
+ * @param params - Either `{ slug: string, appId?: string }` or `{ serviceId: string, appId?: string }`
105
148
  * @returns A promise that resolves to either a success result with the config or a notFound result
106
149
  *
107
150
  * @example
108
151
  * ```ts
109
152
  * // In an Astro page or API route
110
- * import { loadServiceServiceConfig } from '@wix/headless-bookings/services';
153
+ * import { loadServiceServiceInitialData } from '@wix/headless-bookings/services';
154
+ *
155
+ * // Load by slug
156
+ * const serviceResult = await loadServiceServiceInitialData({ slug: 'group-trainings' });
111
157
  *
112
- * const serviceResult = await loadServiceServiceConfig('group-trainings');
158
+ * // Load by serviceId
159
+ * const serviceResult = await loadServiceServiceInitialData({ serviceId: 'service-id-123' });
113
160
  *
114
161
  * if (serviceResult.type === 'notFound') {
115
162
  * return Astro.redirect('/404');
@@ -118,4 +165,10 @@ export type NotFoundServiceServiceConfigResult = {
118
165
  * const serviceConfig = serviceResult.config;
119
166
  * ```
120
167
  */
121
- export declare function loadServiceServiceConfig(slug: string): Promise<SuccessServiceServiceConfigResult | NotFoundServiceServiceConfigResult>;
168
+ export declare function loadServiceServiceInitialData(params: {
169
+ slug: string;
170
+ appId?: string;
171
+ } | {
172
+ serviceId: string;
173
+ appId?: string;
174
+ }): Promise<SuccessServiceServiceConfigResult | NotFoundServiceServiceConfigResult>;