@wix/headless-bookings 0.0.28 → 0.0.30
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/__mocks__/booking.d.ts +82 -0
- package/cjs/dist/__mocks__/booking.js +163 -0
- package/cjs/dist/react/core/service/ServiceMediaCover.d.ts +43 -0
- package/cjs/dist/react/core/service/ServiceMediaCover.js +34 -0
- package/cjs/dist/react/core/service/ServiceMediaGallery.d.ts +50 -0
- package/cjs/dist/react/core/service/ServiceMediaGallery.js +37 -0
- package/cjs/dist/react/core/service/ServiceMediaMain.d.ts +42 -0
- package/cjs/dist/react/core/service/ServiceMediaMain.js +33 -0
- package/cjs/dist/react/index.d.ts +1 -0
- package/cjs/dist/react/index.js +1 -0
- package/cjs/dist/react/service/Service.d.ts +7 -154
- package/cjs/dist/react/service/Service.js +8 -148
- package/cjs/dist/react/service/ServiceMedia.d.ts +191 -0
- package/cjs/dist/react/service/ServiceMedia.js +175 -0
- package/dist/__mocks__/booking.d.ts +82 -0
- package/dist/__mocks__/booking.js +163 -0
- package/dist/react/core/service/ServiceMediaCover.d.ts +43 -0
- package/dist/react/core/service/ServiceMediaCover.js +34 -0
- package/dist/react/core/service/ServiceMediaGallery.d.ts +50 -0
- package/dist/react/core/service/ServiceMediaGallery.js +37 -0
- package/dist/react/core/service/ServiceMediaMain.d.ts +42 -0
- package/dist/react/core/service/ServiceMediaMain.js +33 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/service/Service.d.ts +7 -154
- package/dist/react/service/Service.js +8 -148
- package/dist/react/service/ServiceMedia.d.ts +191 -0
- package/dist/react/service/ServiceMedia.js +175 -0
- package/package.json +2 -2
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared mock data for booking service tests
|
|
3
|
+
*/
|
|
4
|
+
import type { Resource } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
5
|
+
import type { FormValues } from '@wix/form-public';
|
|
6
|
+
import type { ServiceSelection, ServiceSelectionTimeSlot, Location, BookingServiceConfig } from '../services/booking/booking.js';
|
|
7
|
+
/**
|
|
8
|
+
* Mock time slot data
|
|
9
|
+
*/
|
|
10
|
+
export declare const mockTimeSlot: ServiceSelectionTimeSlot;
|
|
11
|
+
/**
|
|
12
|
+
* Mock time slot for afternoon
|
|
13
|
+
*/
|
|
14
|
+
export declare const mockTimeSlotAfternoon: ServiceSelectionTimeSlot;
|
|
15
|
+
/**
|
|
16
|
+
* Mock resource (staff member)
|
|
17
|
+
*/
|
|
18
|
+
export declare const mockResource: Resource;
|
|
19
|
+
/**
|
|
20
|
+
* Mock resource (another staff member)
|
|
21
|
+
*/
|
|
22
|
+
export declare const mockResourceTwo: Resource;
|
|
23
|
+
/**
|
|
24
|
+
* Mock resource (room)
|
|
25
|
+
*/
|
|
26
|
+
export declare const mockResourceRoom: Resource;
|
|
27
|
+
/**
|
|
28
|
+
* Mock service selection with all data
|
|
29
|
+
*/
|
|
30
|
+
export declare const mockServiceSelection: ServiceSelection;
|
|
31
|
+
/**
|
|
32
|
+
* Mock service selection without time slot (incomplete)
|
|
33
|
+
*/
|
|
34
|
+
export declare const mockServiceSelectionWithoutTimeSlot: ServiceSelection;
|
|
35
|
+
/**
|
|
36
|
+
* Mock service selection for class
|
|
37
|
+
*/
|
|
38
|
+
export declare const mockServiceSelectionClass: ServiceSelection;
|
|
39
|
+
/**
|
|
40
|
+
* Mock location
|
|
41
|
+
*/
|
|
42
|
+
export declare const mockLocation: Location;
|
|
43
|
+
/**
|
|
44
|
+
* Mock location (second)
|
|
45
|
+
*/
|
|
46
|
+
export declare const mockLocationTwo: Location;
|
|
47
|
+
/**
|
|
48
|
+
* Mock form submission (contact info)
|
|
49
|
+
*/
|
|
50
|
+
export declare const mockFormSubmission: FormValues;
|
|
51
|
+
/**
|
|
52
|
+
* Mock form submission (minimal)
|
|
53
|
+
*/
|
|
54
|
+
export declare const mockFormSubmissionMinimal: FormValues;
|
|
55
|
+
/**
|
|
56
|
+
* Mock form submission with custom fields
|
|
57
|
+
*/
|
|
58
|
+
export declare const mockFormSubmissionWithCustomFields: FormValues;
|
|
59
|
+
/**
|
|
60
|
+
* Default timezone for tests
|
|
61
|
+
*/
|
|
62
|
+
export declare const mockTimezone = "America/New_York";
|
|
63
|
+
/**
|
|
64
|
+
* Mock booking service config (empty)
|
|
65
|
+
*/
|
|
66
|
+
export declare const mockEmptyBookingConfig: BookingServiceConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Mock booking service config with initial data
|
|
69
|
+
*/
|
|
70
|
+
export declare const mockBookingConfigWithData: BookingServiceConfig;
|
|
71
|
+
/**
|
|
72
|
+
* Mock booking service config with multiple selections
|
|
73
|
+
*/
|
|
74
|
+
export declare const mockBookingConfigMultipleSelections: BookingServiceConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Helper to create a service selection with custom instanceId
|
|
77
|
+
*/
|
|
78
|
+
export declare function createMockServiceSelection(overrides?: Partial<ServiceSelection>): Omit<ServiceSelection, 'instanceId'>;
|
|
79
|
+
/**
|
|
80
|
+
* Helper to create multiple service selections
|
|
81
|
+
*/
|
|
82
|
+
export declare function createMockServiceSelections(count: number): ServiceSelection[];
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared mock data for booking service tests
|
|
3
|
+
*/
|
|
4
|
+
import { mockService, mockServiceClass } from './services.js';
|
|
5
|
+
/**
|
|
6
|
+
* Mock time slot data
|
|
7
|
+
*/
|
|
8
|
+
export const mockTimeSlot = {
|
|
9
|
+
startDate: '2024-03-15T10:00:00Z',
|
|
10
|
+
endDate: '2024-03-15T11:00:00Z',
|
|
11
|
+
totalCapacity: 10,
|
|
12
|
+
remainingCapacity: 5,
|
|
13
|
+
scheduleId: 'schedule-123',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Mock time slot for afternoon
|
|
17
|
+
*/
|
|
18
|
+
export const mockTimeSlotAfternoon = {
|
|
19
|
+
startDate: '2024-03-15T14:00:00Z',
|
|
20
|
+
endDate: '2024-03-15T15:00:00Z',
|
|
21
|
+
totalCapacity: 10,
|
|
22
|
+
remainingCapacity: 8,
|
|
23
|
+
scheduleId: 'schedule-456',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Mock resource (staff member)
|
|
27
|
+
*/
|
|
28
|
+
export const mockResource = {
|
|
29
|
+
_id: 'resource-1',
|
|
30
|
+
name: 'John Doe',
|
|
31
|
+
email: 'john.doe@example.com',
|
|
32
|
+
tag: 'STAFF',
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Mock resource (another staff member)
|
|
36
|
+
*/
|
|
37
|
+
export const mockResourceTwo = {
|
|
38
|
+
_id: 'resource-2',
|
|
39
|
+
name: 'Jane Smith',
|
|
40
|
+
email: 'jane.smith@example.com',
|
|
41
|
+
tag: 'STAFF',
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Mock resource (room)
|
|
45
|
+
*/
|
|
46
|
+
export const mockResourceRoom = {
|
|
47
|
+
_id: 'resource-room-1',
|
|
48
|
+
name: 'Conference Room A',
|
|
49
|
+
tag: 'RESOURCE',
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Mock service selection with all data
|
|
53
|
+
*/
|
|
54
|
+
export const mockServiceSelection = {
|
|
55
|
+
instanceId: 'instance-1',
|
|
56
|
+
service: mockService,
|
|
57
|
+
resources: [mockResource],
|
|
58
|
+
timeSlot: mockTimeSlot,
|
|
59
|
+
totalParticipants: 1,
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Mock service selection without time slot (incomplete)
|
|
63
|
+
*/
|
|
64
|
+
export const mockServiceSelectionWithoutTimeSlot = {
|
|
65
|
+
instanceId: 'instance-2',
|
|
66
|
+
service: mockService,
|
|
67
|
+
resources: [],
|
|
68
|
+
totalParticipants: 1,
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Mock service selection for class
|
|
72
|
+
*/
|
|
73
|
+
export const mockServiceSelectionClass = {
|
|
74
|
+
instanceId: 'instance-3',
|
|
75
|
+
service: mockServiceClass,
|
|
76
|
+
resources: [mockResource],
|
|
77
|
+
timeSlot: mockTimeSlotAfternoon,
|
|
78
|
+
totalParticipants: 3,
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Mock location
|
|
82
|
+
*/
|
|
83
|
+
export const mockLocation = {
|
|
84
|
+
id: 'location-1',
|
|
85
|
+
name: 'Main Office',
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Mock location (second)
|
|
89
|
+
*/
|
|
90
|
+
export const mockLocationTwo = {
|
|
91
|
+
id: 'location-2',
|
|
92
|
+
name: 'Downtown Branch',
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Mock form submission (contact info)
|
|
96
|
+
*/
|
|
97
|
+
export const mockFormSubmission = {
|
|
98
|
+
firstName: 'John',
|
|
99
|
+
lastName: 'Doe',
|
|
100
|
+
email: 'john.doe@example.com',
|
|
101
|
+
phone: '+1234567890',
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Mock form submission (minimal)
|
|
105
|
+
*/
|
|
106
|
+
export const mockFormSubmissionMinimal = {
|
|
107
|
+
email: 'test@example.com',
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Mock form submission with custom fields
|
|
111
|
+
*/
|
|
112
|
+
export const mockFormSubmissionWithCustomFields = {
|
|
113
|
+
firstName: 'Jane',
|
|
114
|
+
lastName: 'Smith',
|
|
115
|
+
email: 'jane.smith@example.com',
|
|
116
|
+
notes: 'Please call before the appointment',
|
|
117
|
+
customField1: 'Custom value 1',
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Default timezone for tests
|
|
121
|
+
*/
|
|
122
|
+
export const mockTimezone = 'America/New_York';
|
|
123
|
+
/**
|
|
124
|
+
* Mock booking service config (empty)
|
|
125
|
+
*/
|
|
126
|
+
export const mockEmptyBookingConfig = {};
|
|
127
|
+
/**
|
|
128
|
+
* Mock booking service config with initial data
|
|
129
|
+
*/
|
|
130
|
+
export const mockBookingConfigWithData = {
|
|
131
|
+
serviceSelections: [mockServiceSelection],
|
|
132
|
+
location: mockLocation,
|
|
133
|
+
timezone: mockTimezone,
|
|
134
|
+
formSubmission: mockFormSubmission,
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Mock booking service config with multiple selections
|
|
138
|
+
*/
|
|
139
|
+
export const mockBookingConfigMultipleSelections = {
|
|
140
|
+
serviceSelections: [mockServiceSelection, mockServiceSelectionClass],
|
|
141
|
+
location: mockLocation,
|
|
142
|
+
timezone: mockTimezone,
|
|
143
|
+
formSubmission: mockFormSubmission,
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Helper to create a service selection with custom instanceId
|
|
147
|
+
*/
|
|
148
|
+
export function createMockServiceSelection(overrides = {}) {
|
|
149
|
+
const { instanceId: _, ...base } = mockServiceSelection;
|
|
150
|
+
return {
|
|
151
|
+
...base,
|
|
152
|
+
...overrides,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Helper to create multiple service selections
|
|
157
|
+
*/
|
|
158
|
+
export function createMockServiceSelections(count) {
|
|
159
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
160
|
+
...mockServiceSelection,
|
|
161
|
+
instanceId: `instance-${i + 1}`,
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core ServiceMediaCover Component
|
|
3
|
+
* Provides low-level access to service cover media via render props
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Render props for CoverMedia component
|
|
8
|
+
*/
|
|
9
|
+
export interface CoverMediaRenderProps {
|
|
10
|
+
/** Cover media object containing the image string */
|
|
11
|
+
coverMedia: {
|
|
12
|
+
image?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Whether the service has a cover media image */
|
|
15
|
+
hasCoverMedia: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Props for CoverMedia component
|
|
19
|
+
*/
|
|
20
|
+
export interface CoverMediaProps {
|
|
21
|
+
/** Render prop function that receives cover media data */
|
|
22
|
+
children: (props: CoverMediaRenderProps) => React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Core component that provides access to service cover media via render props.
|
|
26
|
+
* The cover media is typically used as a hero/banner image.
|
|
27
|
+
* Must be used within a Service.Root context.
|
|
28
|
+
*
|
|
29
|
+
* @component
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <ServiceMediaCover.CoverMedia>
|
|
33
|
+
* {({ coverMedia, hasCoverMedia }) => (
|
|
34
|
+
* hasCoverMedia ? (
|
|
35
|
+
* <img src={coverMedia.image} alt="Service Cover" />
|
|
36
|
+
* ) : (
|
|
37
|
+
* <div>No cover image available</div>
|
|
38
|
+
* )
|
|
39
|
+
* )}
|
|
40
|
+
* </ServiceMediaCover.CoverMedia>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function CoverMedia(props: CoverMediaProps): React.ReactNode;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core ServiceMediaCover Component
|
|
3
|
+
* Provides low-level access to service cover media via render props
|
|
4
|
+
*/
|
|
5
|
+
import { useService } from '@wix/services-manager-react';
|
|
6
|
+
import { ServiceServiceDefinition } from '../../../services/service/service.js';
|
|
7
|
+
/**
|
|
8
|
+
* Core component that provides access to service cover media via render props.
|
|
9
|
+
* The cover media is typically used as a hero/banner image.
|
|
10
|
+
* Must be used within a Service.Root context.
|
|
11
|
+
*
|
|
12
|
+
* @component
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <ServiceMediaCover.CoverMedia>
|
|
16
|
+
* {({ coverMedia, hasCoverMedia }) => (
|
|
17
|
+
* hasCoverMedia ? (
|
|
18
|
+
* <img src={coverMedia.image} alt="Service Cover" />
|
|
19
|
+
* ) : (
|
|
20
|
+
* <div>No cover image available</div>
|
|
21
|
+
* )
|
|
22
|
+
* )}
|
|
23
|
+
* </ServiceMediaCover.CoverMedia>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function CoverMedia(props) {
|
|
27
|
+
const serviceService = useService(ServiceServiceDefinition);
|
|
28
|
+
const service = serviceService.serviceSignal.get();
|
|
29
|
+
const coverMedia = {
|
|
30
|
+
image: service.media?.coverMedia?.image,
|
|
31
|
+
};
|
|
32
|
+
const hasCoverMedia = !!coverMedia.image;
|
|
33
|
+
return props.children({ coverMedia, hasCoverMedia });
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core ServiceMediaGallery Component
|
|
3
|
+
* Provides low-level access to service media gallery items via render props
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Media item type for gallery items
|
|
8
|
+
*/
|
|
9
|
+
export interface MediaItem {
|
|
10
|
+
image?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Render props for MediaGallery component
|
|
14
|
+
*/
|
|
15
|
+
export interface MediaGalleryRenderProps {
|
|
16
|
+
/** Array of media items in the gallery */
|
|
17
|
+
mediaItems: MediaItem[];
|
|
18
|
+
/** Whether the service has any media items */
|
|
19
|
+
hasMediaItems: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Props for MediaGallery component
|
|
23
|
+
*/
|
|
24
|
+
export interface MediaGalleryProps {
|
|
25
|
+
/** Render prop function that receives media gallery data */
|
|
26
|
+
children: (props: MediaGalleryRenderProps) => React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Core component that provides access to service media gallery items via render props.
|
|
30
|
+
* Must be used within a Service.Root context.
|
|
31
|
+
*
|
|
32
|
+
* @component
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <ServiceMediaGallery.MediaGallery>
|
|
36
|
+
* {({ mediaItems, hasMediaItems }) => (
|
|
37
|
+
* hasMediaItems ? (
|
|
38
|
+
* <div>
|
|
39
|
+
* {mediaItems.map((item, index) => (
|
|
40
|
+
* <img key={index} src={item.image} alt={`Gallery item ${index}`} />
|
|
41
|
+
* ))}
|
|
42
|
+
* </div>
|
|
43
|
+
* ) : (
|
|
44
|
+
* <div>No gallery items available</div>
|
|
45
|
+
* )
|
|
46
|
+
* )}
|
|
47
|
+
* </ServiceMediaGallery.MediaGallery>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function MediaGallery(props: MediaGalleryProps): React.ReactNode;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core ServiceMediaGallery Component
|
|
3
|
+
* Provides low-level access to service media gallery items via render props
|
|
4
|
+
*/
|
|
5
|
+
import { useService } from '@wix/services-manager-react';
|
|
6
|
+
import { ServiceServiceDefinition } from '../../../services/service/service.js';
|
|
7
|
+
/**
|
|
8
|
+
* Core component that provides access to service media gallery items via render props.
|
|
9
|
+
* Must be used within a Service.Root context.
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <ServiceMediaGallery.MediaGallery>
|
|
15
|
+
* {({ mediaItems, hasMediaItems }) => (
|
|
16
|
+
* hasMediaItems ? (
|
|
17
|
+
* <div>
|
|
18
|
+
* {mediaItems.map((item, index) => (
|
|
19
|
+
* <img key={index} src={item.image} alt={`Gallery item ${index}`} />
|
|
20
|
+
* ))}
|
|
21
|
+
* </div>
|
|
22
|
+
* ) : (
|
|
23
|
+
* <div>No gallery items available</div>
|
|
24
|
+
* )
|
|
25
|
+
* )}
|
|
26
|
+
* </ServiceMediaGallery.MediaGallery>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function MediaGallery(props) {
|
|
30
|
+
const serviceService = useService(ServiceServiceDefinition);
|
|
31
|
+
const service = serviceService.serviceSignal.get();
|
|
32
|
+
const mediaItems = service.media?.items?.map((item) => ({
|
|
33
|
+
image: item.image,
|
|
34
|
+
})) || [];
|
|
35
|
+
const hasMediaItems = mediaItems.length > 0;
|
|
36
|
+
return props.children({ mediaItems, hasMediaItems });
|
|
37
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core ServiceMediaMain Component
|
|
3
|
+
* Provides low-level access to service main media via render props
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Render props for MainMedia component
|
|
8
|
+
*/
|
|
9
|
+
export interface MainMediaRenderProps {
|
|
10
|
+
/** Main media object containing the image string */
|
|
11
|
+
mainMedia: {
|
|
12
|
+
image?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Whether the service has a main media image */
|
|
15
|
+
hasMainMedia: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Props for MainMedia component
|
|
19
|
+
*/
|
|
20
|
+
export interface MainMediaProps {
|
|
21
|
+
/** Render prop function that receives main media data */
|
|
22
|
+
children: (props: MainMediaRenderProps) => React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Core component that provides access to service main media via render props.
|
|
26
|
+
* Must be used within a Service.Root context.
|
|
27
|
+
*
|
|
28
|
+
* @component
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <ServiceMediaMain.MainMedia>
|
|
32
|
+
* {({ mainMedia, hasMainMedia }) => (
|
|
33
|
+
* hasMainMedia ? (
|
|
34
|
+
* <img src={mainMedia.image} alt="Service" />
|
|
35
|
+
* ) : (
|
|
36
|
+
* <div>No image available</div>
|
|
37
|
+
* )
|
|
38
|
+
* )}
|
|
39
|
+
* </ServiceMediaMain.MainMedia>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function MainMedia(props: MainMediaProps): React.ReactNode;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core ServiceMediaMain Component
|
|
3
|
+
* Provides low-level access to service main media via render props
|
|
4
|
+
*/
|
|
5
|
+
import { useService } from '@wix/services-manager-react';
|
|
6
|
+
import { ServiceServiceDefinition } from '../../../services/service/service.js';
|
|
7
|
+
/**
|
|
8
|
+
* Core component that provides access to service main media via render props.
|
|
9
|
+
* Must be used within a Service.Root context.
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <ServiceMediaMain.MainMedia>
|
|
15
|
+
* {({ mainMedia, hasMainMedia }) => (
|
|
16
|
+
* hasMainMedia ? (
|
|
17
|
+
* <img src={mainMedia.image} alt="Service" />
|
|
18
|
+
* ) : (
|
|
19
|
+
* <div>No image available</div>
|
|
20
|
+
* )
|
|
21
|
+
* )}
|
|
22
|
+
* </ServiceMediaMain.MainMedia>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function MainMedia(props) {
|
|
26
|
+
const serviceService = useService(ServiceServiceDefinition);
|
|
27
|
+
const service = serviceService.serviceSignal.get();
|
|
28
|
+
const mainMedia = {
|
|
29
|
+
image: service.media?.mainMedia?.image,
|
|
30
|
+
};
|
|
31
|
+
const hasMainMedia = !!mainMedia.image;
|
|
32
|
+
return props.children({ mainMedia, hasMainMedia });
|
|
33
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as Booking from './booking/Booking.js';
|
|
2
2
|
export * as BookingForm from './booking-form/BookingForm.js';
|
|
3
3
|
export * as Service from './service/Service.js';
|
|
4
|
+
export * as ServiceMedia from './service/ServiceMedia.js';
|
|
4
5
|
export * as TimeSlotList from './time-slot-list/TimeSlotList.js';
|
|
5
6
|
export * as ServiceList from './service-list/ServiceList.js';
|
|
6
7
|
export * as Location from './location/Location.js';
|
package/cjs/dist/react/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as Booking from './booking/Booking.js';
|
|
2
2
|
export * as BookingForm from './booking-form/BookingForm.js';
|
|
3
3
|
export * as Service from './service/Service.js';
|
|
4
|
+
export * as ServiceMedia from './service/ServiceMedia.js';
|
|
4
5
|
export * as TimeSlotList from './time-slot-list/TimeSlotList.js';
|
|
5
6
|
export * as ServiceList from './service-list/ServiceList.js';
|
|
6
7
|
export * as Location from './location/Location.js';
|
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
7
7
|
import { MoneyData } from '@wix/headless-components/react';
|
|
8
8
|
import { type Service, type Payment } from '@wix/auto_sdk_bookings_services';
|
|
9
|
+
import * as ServiceMediaModule from './ServiceMedia.js';
|
|
9
10
|
/**
|
|
10
11
|
* Props for Service.Root component
|
|
11
12
|
*/
|
|
@@ -558,159 +559,6 @@ export interface StaffMemberRepeaterProps {
|
|
|
558
559
|
* ```
|
|
559
560
|
*/
|
|
560
561
|
export declare const StaffMemberRepeater: React.ForwardRefExoticComponent<StaffMemberRepeaterProps & React.RefAttributes<HTMLElement>>;
|
|
561
|
-
/**
|
|
562
|
-
* Props for Service MainMedia component
|
|
563
|
-
*/
|
|
564
|
-
export interface MainMediaProps {
|
|
565
|
-
asChild?: boolean;
|
|
566
|
-
children?: AsChildChildren<{
|
|
567
|
-
media: {
|
|
568
|
-
image?: string;
|
|
569
|
-
};
|
|
570
|
-
}>;
|
|
571
|
-
className?: string;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Displays the service main media image using WixMediaImage.
|
|
575
|
-
*
|
|
576
|
-
* @component
|
|
577
|
-
* @example
|
|
578
|
-
* ```tsx
|
|
579
|
-
* // Default usage
|
|
580
|
-
* <Service.MainMedia className="w-full h-64 object-cover rounded-lg" />
|
|
581
|
-
* ```
|
|
582
|
-
*
|
|
583
|
-
* @example
|
|
584
|
-
* ```tsx
|
|
585
|
-
* // asChild with primitive img element
|
|
586
|
-
* <Service.MainMedia asChild>
|
|
587
|
-
* <img className="w-full h-64 object-cover shadow-lg" />
|
|
588
|
-
* </Service.MainMedia>
|
|
589
|
-
* ```
|
|
590
|
-
*
|
|
591
|
-
* @example
|
|
592
|
-
* ```tsx
|
|
593
|
-
* // asChild with custom component accessing media data
|
|
594
|
-
* <Service.MainMedia asChild>
|
|
595
|
-
* {React.forwardRef(({media, ...props}, ref) => (
|
|
596
|
-
* <div ref={ref} {...props} className="relative aspect-video">
|
|
597
|
-
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
598
|
-
* <div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 p-4">
|
|
599
|
-
* <Service.Name className="text-primary-foreground" />
|
|
600
|
-
* </div>
|
|
601
|
-
* </div>
|
|
602
|
-
* ))}
|
|
603
|
-
* </Service.MainMedia>
|
|
604
|
-
* ```
|
|
605
|
-
*/
|
|
606
|
-
export declare const MainMedia: React.ForwardRefExoticComponent<MainMediaProps & React.RefAttributes<HTMLImageElement>>;
|
|
607
|
-
/**
|
|
608
|
-
* Props for Service CoverMedia component
|
|
609
|
-
*/
|
|
610
|
-
export interface CoverMediaProps {
|
|
611
|
-
asChild?: boolean;
|
|
612
|
-
children?: AsChildChildren<{
|
|
613
|
-
media: {
|
|
614
|
-
image?: string;
|
|
615
|
-
};
|
|
616
|
-
}>;
|
|
617
|
-
className?: string;
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Displays the service cover media image using WixMediaImage.
|
|
621
|
-
* The cover media is typically used as a hero/banner image.
|
|
622
|
-
*
|
|
623
|
-
* @component
|
|
624
|
-
* @example
|
|
625
|
-
* ```tsx
|
|
626
|
-
* // Default usage
|
|
627
|
-
* <Service.CoverMedia className="w-full h-96 object-cover" />
|
|
628
|
-
* ```
|
|
629
|
-
*
|
|
630
|
-
* @example
|
|
631
|
-
* ```tsx
|
|
632
|
-
* // asChild as a background image container
|
|
633
|
-
* <Service.CoverMedia asChild>
|
|
634
|
-
* <div className="w-full h-96 bg-cover bg-center" />
|
|
635
|
-
* </Service.CoverMedia>
|
|
636
|
-
* ```
|
|
637
|
-
*
|
|
638
|
-
* @example
|
|
639
|
-
* ```tsx
|
|
640
|
-
* // asChild with custom component accessing media data
|
|
641
|
-
* <Service.CoverMedia asChild>
|
|
642
|
-
* {React.forwardRef(({media, ...props}, ref) => (
|
|
643
|
-
* <header ref={ref} {...props} className="relative h-96">
|
|
644
|
-
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
645
|
-
* <div className="absolute inset-0 bg-black/40 flex items-center justify-center">
|
|
646
|
-
* <h1 className="text-4xl font-bold text-primary-foreground">
|
|
647
|
-
* <Service.Name />
|
|
648
|
-
* </h1>
|
|
649
|
-
* </div>
|
|
650
|
-
* </header>
|
|
651
|
-
* ))}
|
|
652
|
-
* </Service.CoverMedia>
|
|
653
|
-
* ```
|
|
654
|
-
*/
|
|
655
|
-
export declare const CoverMedia: React.ForwardRefExoticComponent<CoverMediaProps & React.RefAttributes<HTMLImageElement>>;
|
|
656
|
-
/**
|
|
657
|
-
* Props for Service MediaItems component
|
|
658
|
-
*/
|
|
659
|
-
export interface MediaItemsProps {
|
|
660
|
-
children: React.ReactNode;
|
|
661
|
-
infinite?: boolean;
|
|
662
|
-
autoPlay?: {
|
|
663
|
-
direction?: 'forward' | 'backward';
|
|
664
|
-
intervalMs?: number;
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Container for service media items gallery.
|
|
669
|
-
* Renders a MediaGallery.Root with the service media items.
|
|
670
|
-
* Supports autoPlay and infinite scroll options for carousel behavior.
|
|
671
|
-
*
|
|
672
|
-
* @component
|
|
673
|
-
* @example
|
|
674
|
-
* ```tsx
|
|
675
|
-
* // Basic usage with MediaGallery components
|
|
676
|
-
* <Service.MediaItems>
|
|
677
|
-
* <MediaGallery.Thumbnails>
|
|
678
|
-
* <MediaGallery.ThumbnailRepeater>
|
|
679
|
-
* {({ mediaItem, isActive }) => (
|
|
680
|
-
* <img
|
|
681
|
-
* src={mediaItem.url}
|
|
682
|
-
* alt={mediaItem.altText}
|
|
683
|
-
* className={isActive ? 'active' : ''}
|
|
684
|
-
* />
|
|
685
|
-
* )}
|
|
686
|
-
* </MediaGallery.ThumbnailRepeater>
|
|
687
|
-
* </MediaGallery.Thumbnails>
|
|
688
|
-
* </Service.MediaItems>
|
|
689
|
-
*
|
|
690
|
-
* // With autoPlay carousel
|
|
691
|
-
* <Service.MediaItems
|
|
692
|
-
* autoPlay={{ direction: 'forward', intervalMs: 3000 }}
|
|
693
|
-
* infinite
|
|
694
|
-
* >
|
|
695
|
-
* <MediaGallery.MainImage />
|
|
696
|
-
* <MediaGallery.Actions.Previous />
|
|
697
|
-
* <MediaGallery.Actions.Next />
|
|
698
|
-
* </Service.MediaItems>
|
|
699
|
-
*
|
|
700
|
-
* // Full gallery with thumbnails and navigation
|
|
701
|
-
* <Service.MediaItems infinite>
|
|
702
|
-
* <div className="gallery-container">
|
|
703
|
-
* <MediaGallery.MainImage className="main-image" />
|
|
704
|
-
* <div className="controls">
|
|
705
|
-
* <MediaGallery.Actions.Previous>Prev</MediaGallery.Actions.Previous>
|
|
706
|
-
* <MediaGallery.Actions.Next>Next</MediaGallery.Actions.Next>
|
|
707
|
-
* </div>
|
|
708
|
-
* <MediaGallery.Thumbnails className="thumbnails" />
|
|
709
|
-
* </div>
|
|
710
|
-
* </Service.MediaItems>
|
|
711
|
-
* ```
|
|
712
|
-
*/
|
|
713
|
-
export declare const MediaItems: React.ForwardRefExoticComponent<MediaItemsProps & React.RefAttributes<HTMLDivElement>>;
|
|
714
562
|
/**
|
|
715
563
|
* Props for Service Raw component
|
|
716
564
|
*/
|
|
@@ -1210,4 +1058,9 @@ export declare const StaffMembers: typeof StaffMembersBase & {
|
|
|
1210
1058
|
List: typeof StaffMembersList;
|
|
1211
1059
|
StaffMemberRepeater: typeof StaffMemberRepeater;
|
|
1212
1060
|
};
|
|
1213
|
-
export
|
|
1061
|
+
export declare const MainMedia: React.ForwardRefExoticComponent<ServiceMediaModule.MainProps & React.RefAttributes<HTMLImageElement>>;
|
|
1062
|
+
export declare const CoverMedia: React.ForwardRefExoticComponent<ServiceMediaModule.CoverProps & React.RefAttributes<HTMLImageElement>>;
|
|
1063
|
+
export declare const MediaGallery: React.FC<ServiceMediaModule.GalleryProps>;
|
|
1064
|
+
export type { MainProps as MainMediaProps } from './ServiceMedia.js';
|
|
1065
|
+
export type { CoverProps as CoverMediaProps } from './ServiceMedia.js';
|
|
1066
|
+
export type { GalleryProps as MediaGalleryProps } from './ServiceMedia.js';
|