@wix/headless-bookings 0.0.42 → 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.
- package/cjs/dist/api/index.d.ts +1 -0
- package/cjs/dist/api/index.js +1 -0
- package/cjs/dist/api/query-locations/index.d.ts +38 -0
- package/cjs/dist/api/query-locations/index.js +30 -0
- package/cjs/dist/react/core/location/Location.d.ts +113 -14
- package/cjs/dist/react/core/location/Location.js +189 -30
- package/cjs/dist/react/core/location-list/LocationList.d.ts +102 -0
- package/cjs/dist/react/core/location-list/LocationList.js +71 -0
- package/cjs/dist/react/index.d.ts +1 -0
- package/cjs/dist/react/index.js +1 -0
- package/cjs/dist/react/location/Location.d.ts +211 -41
- package/cjs/dist/react/location/Location.js +219 -46
- package/cjs/dist/react/location/LocationList.d.ts +98 -0
- package/cjs/dist/react/location/LocationList.js +120 -0
- package/cjs/dist/react/service/Service.d.ts +70 -27
- package/cjs/dist/react/service/Service.js +48 -38
- package/cjs/dist/services/index.d.ts +1 -0
- package/cjs/dist/services/index.js +1 -0
- package/cjs/dist/services/location-list/location-list.d.ts +100 -0
- package/cjs/dist/services/location-list/location-list.def.d.ts +62 -0
- package/cjs/dist/services/location-list/location-list.def.js +17 -0
- package/cjs/dist/services/location-list/location-list.js +212 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/query-locations/index.d.ts +38 -0
- package/dist/api/query-locations/index.js +30 -0
- package/dist/react/core/location/Location.d.ts +113 -14
- package/dist/react/core/location/Location.js +189 -30
- package/dist/react/core/location-list/LocationList.d.ts +102 -0
- package/dist/react/core/location-list/LocationList.js +71 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/location/Location.d.ts +211 -41
- package/dist/react/location/Location.js +219 -46
- package/dist/react/location/LocationList.d.ts +98 -0
- package/dist/react/location/LocationList.js +120 -0
- package/dist/react/service/Service.d.ts +70 -27
- package/dist/react/service/Service.js +48 -38
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/location-list/location-list.d.ts +100 -0
- package/dist/services/location-list/location-list.def.d.ts +62 -0
- package/dist/services/location-list/location-list.def.js +17 -0
- package/dist/services/location-list/location-list.js +212 -0
- 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';
|
|
@@ -8,20 +8,49 @@ import { MoneyData } from '@wix/headless-components/react';
|
|
|
8
8
|
import { type Service, type Payment } from '@wix/auto_sdk_bookings_services';
|
|
9
9
|
import * as ServiceMediaModule from './ServiceMedia.js';
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Base props shared by all Service.Root variants
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
interface ServiceRootBaseProps {
|
|
14
14
|
children?: React.ReactNode | AsChildChildren<{
|
|
15
15
|
selected: boolean;
|
|
16
16
|
bookable: boolean;
|
|
17
17
|
}>;
|
|
18
|
-
service: Service;
|
|
19
18
|
appId?: string;
|
|
20
19
|
asChild?: boolean;
|
|
21
20
|
className?: string;
|
|
22
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Props for Service.Root with pre-loaded service object (SSR pattern)
|
|
24
|
+
*/
|
|
25
|
+
type ServiceRootWithService = ServiceRootBaseProps & {
|
|
26
|
+
service: Service;
|
|
27
|
+
serviceId?: never;
|
|
28
|
+
serviceSlug?: never;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Props for Service.Root with dynamic loading by service ID
|
|
32
|
+
*/
|
|
33
|
+
type ServiceRootWithId = ServiceRootBaseProps & {
|
|
34
|
+
service?: never;
|
|
35
|
+
serviceId: string;
|
|
36
|
+
serviceSlug?: never;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Props for Service.Root with dynamic loading by service slug
|
|
40
|
+
*/
|
|
41
|
+
type ServiceRootWithSlug = ServiceRootBaseProps & {
|
|
42
|
+
service?: never;
|
|
43
|
+
serviceId?: never;
|
|
44
|
+
serviceSlug: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Props for Service.Root component.
|
|
48
|
+
* Requires exactly one of: service, serviceId, or serviceSlug.
|
|
49
|
+
*/
|
|
50
|
+
export type ServiceRootProps = ServiceRootWithService | ServiceRootWithId | ServiceRootWithSlug;
|
|
23
51
|
/**
|
|
24
52
|
* Root component that provides service context to the entire app.
|
|
53
|
+
* Requires exactly one of: service, serviceId, or serviceSlug.
|
|
25
54
|
*
|
|
26
55
|
* @order 1
|
|
27
56
|
* @component
|
|
@@ -29,6 +58,7 @@ export interface ServiceRootProps {
|
|
|
29
58
|
* ```tsx
|
|
30
59
|
* import { Service } from '@wix/bookings/components';
|
|
31
60
|
*
|
|
61
|
+
* // With pre-loaded service object (SSR pattern)
|
|
32
62
|
* function ServicePage({ service }) {
|
|
33
63
|
* return (
|
|
34
64
|
* <Service.Root service={service}>
|
|
@@ -37,6 +67,26 @@ export interface ServiceRootProps {
|
|
|
37
67
|
* </Service.Root>
|
|
38
68
|
* );
|
|
39
69
|
* }
|
|
70
|
+
*
|
|
71
|
+
* // With dynamic loading by serviceId
|
|
72
|
+
* function ServicePageById({ serviceId }) {
|
|
73
|
+
* return (
|
|
74
|
+
* <Service.Root serviceId={serviceId}>
|
|
75
|
+
* <Service.Name />
|
|
76
|
+
* <Service.Description />
|
|
77
|
+
* </Service.Root>
|
|
78
|
+
* );
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* // With dynamic loading by serviceSlug
|
|
82
|
+
* function ServicePageBySlug({ slug }) {
|
|
83
|
+
* return (
|
|
84
|
+
* <Service.Root serviceSlug={slug}>
|
|
85
|
+
* <Service.Name />
|
|
86
|
+
* <Service.Description />
|
|
87
|
+
* </Service.Root>
|
|
88
|
+
* );
|
|
89
|
+
* }
|
|
40
90
|
* ```
|
|
41
91
|
*/
|
|
42
92
|
export declare const Root: React.ForwardRefExoticComponent<ServiceRootProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -343,6 +393,7 @@ export interface LocationsProps {
|
|
|
343
393
|
* Container for service locations list (Container Level).
|
|
344
394
|
* Follows the 3-level List/Options/Repeater pattern.
|
|
345
395
|
* Provides context and doesn't render when there are no locations.
|
|
396
|
+
* Internally uses LocationList.Root for consistent location handling.
|
|
346
397
|
*
|
|
347
398
|
* @component
|
|
348
399
|
* @example
|
|
@@ -351,14 +402,8 @@ export interface LocationsProps {
|
|
|
351
402
|
* <Service.Locations>
|
|
352
403
|
* <Service.Locations.List emptyState={<div>No locations available</div>}>
|
|
353
404
|
* <Service.Locations.LocationRepeater>
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* <span>{location.name}</span>
|
|
357
|
-
* <Address.Root address={location.address}>
|
|
358
|
-
* <Address.Formatted />
|
|
359
|
-
* </Address.Root>
|
|
360
|
-
* </div>
|
|
361
|
-
* )}
|
|
405
|
+
* <Location.Name />
|
|
406
|
+
* <Location.Address />
|
|
362
407
|
* </Service.Locations.LocationRepeater>
|
|
363
408
|
* </Service.Locations.List>
|
|
364
409
|
* </Service.Locations>
|
|
@@ -368,7 +413,7 @@ export interface LocationsProps {
|
|
|
368
413
|
* <ul className="locations-list">
|
|
369
414
|
* <Service.Locations.List>
|
|
370
415
|
* <Service.Locations.LocationRepeater>
|
|
371
|
-
*
|
|
416
|
+
* <li><Location.Name /></li>
|
|
372
417
|
* </Service.Locations.LocationRepeater>
|
|
373
418
|
* </Service.Locations.List>
|
|
374
419
|
* </ul>
|
|
@@ -387,6 +432,7 @@ export interface LocationsListProps {
|
|
|
387
432
|
/**
|
|
388
433
|
* List container for locations with empty state support (List Container Level).
|
|
389
434
|
* Renders emptyState when no locations, otherwise renders children.
|
|
435
|
+
* Internally delegates to LocationList.Locations.
|
|
390
436
|
*
|
|
391
437
|
* @component
|
|
392
438
|
* @example
|
|
@@ -412,32 +458,29 @@ export interface LocationRepeaterRenderProps {
|
|
|
412
458
|
* Props for Service Locations.LocationRepeater component
|
|
413
459
|
*/
|
|
414
460
|
export interface LocationRepeaterProps {
|
|
415
|
-
children?: React.ReactNode
|
|
416
|
-
asChild?: boolean;
|
|
461
|
+
children?: React.ReactNode;
|
|
417
462
|
}
|
|
418
463
|
/**
|
|
419
464
|
* Repeater component that renders Location.Root for each location.
|
|
420
|
-
*
|
|
465
|
+
* Internally delegates to LocationList.LocationRepeater.
|
|
466
|
+
* Children are rendered inside each Location.Root context.
|
|
421
467
|
*
|
|
422
468
|
* @component
|
|
423
469
|
* @example
|
|
424
470
|
* ```tsx
|
|
425
471
|
* // Standard usage - renders Location.Root for each location
|
|
426
472
|
* <Service.Locations.LocationRepeater>
|
|
427
|
-
* <
|
|
473
|
+
* <Location.Name />
|
|
474
|
+
* <Location.Address />
|
|
428
475
|
* </Service.Locations.LocationRepeater>
|
|
429
476
|
*
|
|
430
|
-
* //
|
|
431
|
-
* <Service.Locations.LocationRepeater
|
|
432
|
-
*
|
|
433
|
-
* <
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
* </li>
|
|
438
|
-
* ))}
|
|
439
|
-
* </ol>
|
|
440
|
-
* )}
|
|
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>
|
|
441
484
|
* </Service.Locations.LocationRepeater>
|
|
442
485
|
* ```
|
|
443
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
|
|
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) {
|
|
@@ -47,6 +49,7 @@ var TestIds;
|
|
|
47
49
|
})(TestIds || (TestIds = {}));
|
|
48
50
|
/**
|
|
49
51
|
* Root component that provides service context to the entire app.
|
|
52
|
+
* Requires exactly one of: service, serviceId, or serviceSlug.
|
|
50
53
|
*
|
|
51
54
|
* @order 1
|
|
52
55
|
* @component
|
|
@@ -54,6 +57,7 @@ var TestIds;
|
|
|
54
57
|
* ```tsx
|
|
55
58
|
* import { Service } from '@wix/bookings/components';
|
|
56
59
|
*
|
|
60
|
+
* // With pre-loaded service object (SSR pattern)
|
|
57
61
|
* function ServicePage({ service }) {
|
|
58
62
|
* return (
|
|
59
63
|
* <Service.Root service={service}>
|
|
@@ -62,11 +66,31 @@ var TestIds;
|
|
|
62
66
|
* </Service.Root>
|
|
63
67
|
* );
|
|
64
68
|
* }
|
|
69
|
+
*
|
|
70
|
+
* // With dynamic loading by serviceId
|
|
71
|
+
* function ServicePageById({ serviceId }) {
|
|
72
|
+
* return (
|
|
73
|
+
* <Service.Root serviceId={serviceId}>
|
|
74
|
+
* <Service.Name />
|
|
75
|
+
* <Service.Description />
|
|
76
|
+
* </Service.Root>
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* // With dynamic loading by serviceSlug
|
|
81
|
+
* function ServicePageBySlug({ slug }) {
|
|
82
|
+
* return (
|
|
83
|
+
* <Service.Root serviceSlug={slug}>
|
|
84
|
+
* <Service.Name />
|
|
85
|
+
* <Service.Description />
|
|
86
|
+
* </Service.Root>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
65
89
|
* ```
|
|
66
90
|
*/
|
|
67
91
|
export const Root = React.forwardRef((props, ref) => {
|
|
68
|
-
const { children, service, appId, asChild, className, ...attrs } = props;
|
|
69
|
-
return (_jsx(CoreService.Root, { serviceServiceConfig: { service, appId }, children: ({ selected, bookable }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceRoot, "data-selected": selected, "data-bookable": bookable, customElement: children, customElementProps: { selected, bookable }, ...attrs, children: children })) }));
|
|
92
|
+
const { children, service, serviceId, serviceSlug, appId, asChild, className, ...attrs } = props;
|
|
93
|
+
return (_jsx(CoreService.Root, { serviceServiceConfig: { service, serviceId, serviceSlug, appId }, children: ({ selected, bookable }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceRoot, "data-selected": selected, "data-bookable": bookable, customElement: children, customElementProps: { selected, bookable }, ...attrs, children: children })) }));
|
|
70
94
|
});
|
|
71
95
|
Root.displayName = 'Service.Root';
|
|
72
96
|
/**
|
|
@@ -331,6 +355,7 @@ Category.displayName = 'Service.Category';
|
|
|
331
355
|
* Container for service locations list (Container Level).
|
|
332
356
|
* Follows the 3-level List/Options/Repeater pattern.
|
|
333
357
|
* Provides context and doesn't render when there are no locations.
|
|
358
|
+
* Internally uses LocationList.Root for consistent location handling.
|
|
334
359
|
*
|
|
335
360
|
* @component
|
|
336
361
|
* @example
|
|
@@ -339,14 +364,8 @@ Category.displayName = 'Service.Category';
|
|
|
339
364
|
* <Service.Locations>
|
|
340
365
|
* <Service.Locations.List emptyState={<div>No locations available</div>}>
|
|
341
366
|
* <Service.Locations.LocationRepeater>
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
* <span>{location.name}</span>
|
|
345
|
-
* <Address.Root address={location.address}>
|
|
346
|
-
* <Address.Formatted />
|
|
347
|
-
* </Address.Root>
|
|
348
|
-
* </div>
|
|
349
|
-
* )}
|
|
367
|
+
* <Location.Name />
|
|
368
|
+
* <Location.Address />
|
|
350
369
|
* </Service.Locations.LocationRepeater>
|
|
351
370
|
* </Service.Locations.List>
|
|
352
371
|
* </Service.Locations>
|
|
@@ -356,7 +375,7 @@ Category.displayName = 'Service.Category';
|
|
|
356
375
|
* <ul className="locations-list">
|
|
357
376
|
* <Service.Locations.List>
|
|
358
377
|
* <Service.Locations.LocationRepeater>
|
|
359
|
-
*
|
|
378
|
+
* <li><Location.Name /></li>
|
|
360
379
|
* </Service.Locations.LocationRepeater>
|
|
361
380
|
* </Service.Locations.List>
|
|
362
381
|
* </ul>
|
|
@@ -370,18 +389,14 @@ const LocationsBase = React.forwardRef((props, ref) => {
|
|
|
370
389
|
if (!locations || locations.length === 0) {
|
|
371
390
|
return null;
|
|
372
391
|
}
|
|
373
|
-
|
|
374
|
-
const items = locations.map((location, index) => ({
|
|
375
|
-
...location,
|
|
376
|
-
id: location._id || String(index),
|
|
377
|
-
}));
|
|
378
|
-
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 }) }) }));
|
|
379
393
|
} }));
|
|
380
394
|
});
|
|
381
395
|
LocationsBase.displayName = 'Service.Locations';
|
|
382
396
|
/**
|
|
383
397
|
* List container for locations with empty state support (List Container Level).
|
|
384
398
|
* Renders emptyState when no locations, otherwise renders children.
|
|
399
|
+
* Internally delegates to LocationList.Locations.
|
|
385
400
|
*
|
|
386
401
|
* @component
|
|
387
402
|
* @example
|
|
@@ -393,42 +408,36 @@ LocationsBase.displayName = 'Service.Locations';
|
|
|
393
408
|
*/
|
|
394
409
|
export const LocationsList = React.forwardRef((props, ref) => {
|
|
395
410
|
const { children, emptyState, className, ...otherProps } = props;
|
|
396
|
-
return (_jsx(
|
|
411
|
+
return (_jsx(LocationList.Locations, { ref: ref, emptyState: emptyState, className: className, ...otherProps, children: children }));
|
|
397
412
|
});
|
|
398
413
|
LocationsList.displayName = 'Service.Locations.List';
|
|
399
414
|
/**
|
|
400
415
|
* Repeater component that renders Location.Root for each location.
|
|
401
|
-
*
|
|
416
|
+
* Internally delegates to LocationList.LocationRepeater.
|
|
417
|
+
* Children are rendered inside each Location.Root context.
|
|
402
418
|
*
|
|
403
419
|
* @component
|
|
404
420
|
* @example
|
|
405
421
|
* ```tsx
|
|
406
422
|
* // Standard usage - renders Location.Root for each location
|
|
407
423
|
* <Service.Locations.LocationRepeater>
|
|
408
|
-
* <
|
|
424
|
+
* <Location.Name />
|
|
425
|
+
* <Location.Address />
|
|
409
426
|
* </Service.Locations.LocationRepeater>
|
|
410
427
|
*
|
|
411
|
-
* //
|
|
412
|
-
* <Service.Locations.LocationRepeater
|
|
413
|
-
*
|
|
414
|
-
* <
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
* </li>
|
|
419
|
-
* ))}
|
|
420
|
-
* </ol>
|
|
421
|
-
* )}
|
|
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>
|
|
422
435
|
* </Service.Locations.LocationRepeater>
|
|
423
436
|
* ```
|
|
424
437
|
*/
|
|
425
438
|
export const LocationRepeater = React.forwardRef((props, ref) => {
|
|
426
|
-
const { children
|
|
427
|
-
|
|
428
|
-
const locationItemWrapper = ({ item: location, children: itemChildren, }) => {
|
|
429
|
-
return (_jsx(Location.Root, { location: location, "data-testid": TestIds.serviceLocationRepeater, children: itemChildren || undefined }, location.id));
|
|
430
|
-
};
|
|
431
|
-
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 }));
|
|
432
441
|
});
|
|
433
442
|
LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
|
|
434
443
|
/**
|
|
@@ -613,6 +622,7 @@ export var Actions;
|
|
|
613
622
|
selected,
|
|
614
623
|
bookable,
|
|
615
624
|
requiresAvailability,
|
|
625
|
+
service: rawService,
|
|
616
626
|
}, children: _jsx("button", { onClick: handleClick, disabled: !bookable, "data-selected": selected, "data-bookable": bookable, "data-requires-availability": requiresAvailability, children: label }) }));
|
|
617
627
|
} }));
|
|
618
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';
|