@wix/headless-bookings 0.0.29 → 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/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/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,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ServiceMedia - Compound component for displaying service media
|
|
3
|
+
* Provides components for displaying main media, cover media, and media galleries
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
7
|
+
/**
|
|
8
|
+
* Props for ServiceMedia.Main component
|
|
9
|
+
*/
|
|
10
|
+
export interface MainProps {
|
|
11
|
+
/** Whether to render as a child component */
|
|
12
|
+
asChild?: boolean;
|
|
13
|
+
/** Custom render function when using asChild */
|
|
14
|
+
children?: AsChildChildren<{
|
|
15
|
+
media: {
|
|
16
|
+
image?: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
/** CSS class name */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Displays the service main media image using WixMediaImage.
|
|
24
|
+
*
|
|
25
|
+
* @component
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // Default usage
|
|
29
|
+
* <ServiceMedia.Main className="w-full h-64 object-cover rounded-lg" />
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* // asChild with primitive img element
|
|
35
|
+
* <ServiceMedia.Main asChild>
|
|
36
|
+
* <img className="w-full h-64 object-cover shadow-lg" />
|
|
37
|
+
* </ServiceMedia.Main>
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // asChild with custom component accessing media data
|
|
43
|
+
* <ServiceMedia.Main asChild>
|
|
44
|
+
* {React.forwardRef(({media, ...props}, ref) => (
|
|
45
|
+
* <div ref={ref} {...props} className="relative aspect-video">
|
|
46
|
+
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
47
|
+
* <div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 p-4">
|
|
48
|
+
* <Service.Name className="text-primary-foreground" />
|
|
49
|
+
* </div>
|
|
50
|
+
* </div>
|
|
51
|
+
* ))}
|
|
52
|
+
* </ServiceMedia.Main>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const Main: React.ForwardRefExoticComponent<MainProps & React.RefAttributes<HTMLImageElement>>;
|
|
56
|
+
/**
|
|
57
|
+
* Props for ServiceMedia.Cover component
|
|
58
|
+
*/
|
|
59
|
+
export interface CoverProps {
|
|
60
|
+
/** Whether to render as a child component */
|
|
61
|
+
asChild?: boolean;
|
|
62
|
+
/** Custom render function when using asChild */
|
|
63
|
+
children?: AsChildChildren<{
|
|
64
|
+
media: {
|
|
65
|
+
image?: string;
|
|
66
|
+
};
|
|
67
|
+
}>;
|
|
68
|
+
/** CSS class name */
|
|
69
|
+
className?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Displays the service cover media image using WixMediaImage.
|
|
73
|
+
* The cover media is typically used as a hero/banner image.
|
|
74
|
+
*
|
|
75
|
+
* @component
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* // Default usage
|
|
79
|
+
* <ServiceMedia.Cover className="w-full h-96 object-cover" />
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* // asChild as a background image container
|
|
85
|
+
* <ServiceMedia.Cover asChild>
|
|
86
|
+
* <div className="w-full h-96 bg-cover bg-center" />
|
|
87
|
+
* </ServiceMedia.Cover>
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* // asChild with custom component accessing media data
|
|
93
|
+
* <ServiceMedia.Cover asChild>
|
|
94
|
+
* {React.forwardRef(({media, ...props}, ref) => (
|
|
95
|
+
* <header ref={ref} {...props} className="relative h-96">
|
|
96
|
+
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
97
|
+
* <div className="absolute inset-0 bg-black/40 flex items-center justify-center">
|
|
98
|
+
* <h1 className="text-4xl font-bold text-primary-foreground">
|
|
99
|
+
* <Service.Name />
|
|
100
|
+
* </h1>
|
|
101
|
+
* </div>
|
|
102
|
+
* </header>
|
|
103
|
+
* ))}
|
|
104
|
+
* </ServiceMedia.Cover>
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare const Cover: React.ForwardRefExoticComponent<CoverProps & React.RefAttributes<HTMLImageElement>>;
|
|
108
|
+
/**
|
|
109
|
+
* Props for ServiceMedia.Gallery component
|
|
110
|
+
*/
|
|
111
|
+
export interface GalleryProps {
|
|
112
|
+
/** Child components to render within the gallery (MediaGallery components) */
|
|
113
|
+
children: React.ReactNode;
|
|
114
|
+
/** Whether the gallery should loop infinitely */
|
|
115
|
+
infinite?: boolean;
|
|
116
|
+
/** Auto-play configuration for the gallery */
|
|
117
|
+
autoPlay?: {
|
|
118
|
+
/** Direction of auto-play */
|
|
119
|
+
direction?: 'forward' | 'backward';
|
|
120
|
+
/** Interval between slides in milliseconds */
|
|
121
|
+
intervalMs?: number;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Container for service media items gallery.
|
|
126
|
+
* Renders a MediaGallery.Root with the service media items.
|
|
127
|
+
* Supports autoPlay and infinite scroll options for carousel behavior.
|
|
128
|
+
*
|
|
129
|
+
* @component
|
|
130
|
+
* @example
|
|
131
|
+
* ```tsx
|
|
132
|
+
* // Basic usage with MediaGallery components
|
|
133
|
+
* <ServiceMedia.Gallery>
|
|
134
|
+
* <MediaGallery.Thumbnails>
|
|
135
|
+
* <MediaGallery.ThumbnailRepeater>
|
|
136
|
+
* <MediaGallery.ThumbnailItem />
|
|
137
|
+
* </MediaGallery.ThumbnailRepeater>
|
|
138
|
+
* </MediaGallery.Thumbnails>
|
|
139
|
+
* </ServiceMedia.Gallery>
|
|
140
|
+
*
|
|
141
|
+
* // With autoPlay carousel
|
|
142
|
+
* <ServiceMedia.Gallery
|
|
143
|
+
* autoPlay={{ direction: 'forward', intervalMs: 3000 }}
|
|
144
|
+
* infinite
|
|
145
|
+
* >
|
|
146
|
+
* <MediaGallery.Viewport />
|
|
147
|
+
* <MediaGallery.Previous />
|
|
148
|
+
* <MediaGallery.Next />
|
|
149
|
+
* </ServiceMedia.Gallery>
|
|
150
|
+
*
|
|
151
|
+
* // Full gallery with thumbnails and navigation
|
|
152
|
+
* <ServiceMedia.Gallery infinite>
|
|
153
|
+
* <div className="gallery-container">
|
|
154
|
+
* <MediaGallery.Viewport className="main-image" />
|
|
155
|
+
* <div className="controls">
|
|
156
|
+
* <MediaGallery.Previous>Prev</MediaGallery.Previous>
|
|
157
|
+
* <MediaGallery.Next>Next</MediaGallery.Next>
|
|
158
|
+
* </div>
|
|
159
|
+
* <MediaGallery.Thumbnails>
|
|
160
|
+
* <MediaGallery.ThumbnailRepeater>
|
|
161
|
+
* <MediaGallery.ThumbnailItem />
|
|
162
|
+
* </MediaGallery.ThumbnailRepeater>
|
|
163
|
+
* </MediaGallery.Thumbnails>
|
|
164
|
+
* </div>
|
|
165
|
+
* </ServiceMedia.Gallery>
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export declare const Gallery: React.FC<GalleryProps>;
|
|
169
|
+
/**
|
|
170
|
+
* ServiceMedia compound component for displaying service media
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```tsx
|
|
174
|
+
* import { Service, ServiceMedia } from '@wix/headless-bookings/react';
|
|
175
|
+
*
|
|
176
|
+
* function ServiceCard({ service }) {
|
|
177
|
+
* return (
|
|
178
|
+
* <Service.Root serviceServiceConfig={{ service }}>
|
|
179
|
+
* <ServiceMedia.Main className="w-full h-48 object-cover" />
|
|
180
|
+
* <Service.Name />
|
|
181
|
+
* </Service.Root>
|
|
182
|
+
* );
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare const ServiceMedia: {
|
|
187
|
+
Main: React.ForwardRefExoticComponent<MainProps & React.RefAttributes<HTMLImageElement>>;
|
|
188
|
+
Cover: React.ForwardRefExoticComponent<CoverProps & React.RefAttributes<HTMLImageElement>>;
|
|
189
|
+
Gallery: React.FC<GalleryProps>;
|
|
190
|
+
};
|
|
191
|
+
export default ServiceMedia;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* ServiceMedia - Compound component for displaying service media
|
|
4
|
+
* Provides components for displaying main media, cover media, and media galleries
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
8
|
+
import { WixMediaImage } from '@wix/headless-media/react';
|
|
9
|
+
import { MediaGallery } from '@wix/headless-media/react';
|
|
10
|
+
import * as CoreServiceMediaMain from '../core/service/ServiceMediaMain.js';
|
|
11
|
+
import * as CoreServiceMediaCover from '../core/service/ServiceMediaCover.js';
|
|
12
|
+
import * as CoreServiceMediaGallery from '../core/service/ServiceMediaGallery.js';
|
|
13
|
+
var TestIds;
|
|
14
|
+
(function (TestIds) {
|
|
15
|
+
TestIds["serviceMediaMain"] = "service-media-main";
|
|
16
|
+
TestIds["serviceMediaCover"] = "service-media-cover";
|
|
17
|
+
})(TestIds || (TestIds = {}));
|
|
18
|
+
/**
|
|
19
|
+
* Displays the service main media image using WixMediaImage.
|
|
20
|
+
*
|
|
21
|
+
* @component
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // Default usage
|
|
25
|
+
* <ServiceMedia.Main className="w-full h-64 object-cover rounded-lg" />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // asChild with primitive img element
|
|
31
|
+
* <ServiceMedia.Main asChild>
|
|
32
|
+
* <img className="w-full h-64 object-cover shadow-lg" />
|
|
33
|
+
* </ServiceMedia.Main>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // asChild with custom component accessing media data
|
|
39
|
+
* <ServiceMedia.Main asChild>
|
|
40
|
+
* {React.forwardRef(({media, ...props}, ref) => (
|
|
41
|
+
* <div ref={ref} {...props} className="relative aspect-video">
|
|
42
|
+
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
43
|
+
* <div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 p-4">
|
|
44
|
+
* <Service.Name className="text-primary-foreground" />
|
|
45
|
+
* </div>
|
|
46
|
+
* </div>
|
|
47
|
+
* ))}
|
|
48
|
+
* </ServiceMedia.Main>
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export const Main = React.forwardRef((props, ref) => {
|
|
52
|
+
const { asChild, children, className } = props;
|
|
53
|
+
return (_jsx(CoreServiceMediaMain.MainMedia, { children: ({ mainMedia }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceMediaMain, customElement: children, customElementProps: { media: mainMedia }, children: mainMedia?.image ? _jsx(WixMediaImage, { media: mainMedia }) : null })) }));
|
|
54
|
+
});
|
|
55
|
+
Main.displayName = 'ServiceMedia.Main';
|
|
56
|
+
/**
|
|
57
|
+
* Displays the service cover media image using WixMediaImage.
|
|
58
|
+
* The cover media is typically used as a hero/banner image.
|
|
59
|
+
*
|
|
60
|
+
* @component
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* // Default usage
|
|
64
|
+
* <ServiceMedia.Cover className="w-full h-96 object-cover" />
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* // asChild as a background image container
|
|
70
|
+
* <ServiceMedia.Cover asChild>
|
|
71
|
+
* <div className="w-full h-96 bg-cover bg-center" />
|
|
72
|
+
* </ServiceMedia.Cover>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* // asChild with custom component accessing media data
|
|
78
|
+
* <ServiceMedia.Cover asChild>
|
|
79
|
+
* {React.forwardRef(({media, ...props}, ref) => (
|
|
80
|
+
* <header ref={ref} {...props} className="relative h-96">
|
|
81
|
+
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
82
|
+
* <div className="absolute inset-0 bg-black/40 flex items-center justify-center">
|
|
83
|
+
* <h1 className="text-4xl font-bold text-primary-foreground">
|
|
84
|
+
* <Service.Name />
|
|
85
|
+
* </h1>
|
|
86
|
+
* </div>
|
|
87
|
+
* </header>
|
|
88
|
+
* ))}
|
|
89
|
+
* </ServiceMedia.Cover>
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export const Cover = React.forwardRef((props, ref) => {
|
|
93
|
+
const { asChild, children, className } = props;
|
|
94
|
+
return (_jsx(CoreServiceMediaCover.CoverMedia, { children: ({ coverMedia }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceMediaCover, customElement: children, customElementProps: { media: coverMedia }, children: coverMedia?.image ? _jsx(WixMediaImage, { media: coverMedia }) : null })) }));
|
|
95
|
+
});
|
|
96
|
+
Cover.displayName = 'ServiceMedia.Cover';
|
|
97
|
+
/**
|
|
98
|
+
* Container for service media items gallery.
|
|
99
|
+
* Renders a MediaGallery.Root with the service media items.
|
|
100
|
+
* Supports autoPlay and infinite scroll options for carousel behavior.
|
|
101
|
+
*
|
|
102
|
+
* @component
|
|
103
|
+
* @example
|
|
104
|
+
* ```tsx
|
|
105
|
+
* // Basic usage with MediaGallery components
|
|
106
|
+
* <ServiceMedia.Gallery>
|
|
107
|
+
* <MediaGallery.Thumbnails>
|
|
108
|
+
* <MediaGallery.ThumbnailRepeater>
|
|
109
|
+
* <MediaGallery.ThumbnailItem />
|
|
110
|
+
* </MediaGallery.ThumbnailRepeater>
|
|
111
|
+
* </MediaGallery.Thumbnails>
|
|
112
|
+
* </ServiceMedia.Gallery>
|
|
113
|
+
*
|
|
114
|
+
* // With autoPlay carousel
|
|
115
|
+
* <ServiceMedia.Gallery
|
|
116
|
+
* autoPlay={{ direction: 'forward', intervalMs: 3000 }}
|
|
117
|
+
* infinite
|
|
118
|
+
* >
|
|
119
|
+
* <MediaGallery.Viewport />
|
|
120
|
+
* <MediaGallery.Previous />
|
|
121
|
+
* <MediaGallery.Next />
|
|
122
|
+
* </ServiceMedia.Gallery>
|
|
123
|
+
*
|
|
124
|
+
* // Full gallery with thumbnails and navigation
|
|
125
|
+
* <ServiceMedia.Gallery infinite>
|
|
126
|
+
* <div className="gallery-container">
|
|
127
|
+
* <MediaGallery.Viewport className="main-image" />
|
|
128
|
+
* <div className="controls">
|
|
129
|
+
* <MediaGallery.Previous>Prev</MediaGallery.Previous>
|
|
130
|
+
* <MediaGallery.Next>Next</MediaGallery.Next>
|
|
131
|
+
* </div>
|
|
132
|
+
* <MediaGallery.Thumbnails>
|
|
133
|
+
* <MediaGallery.ThumbnailRepeater>
|
|
134
|
+
* <MediaGallery.ThumbnailItem />
|
|
135
|
+
* </MediaGallery.ThumbnailRepeater>
|
|
136
|
+
* </MediaGallery.Thumbnails>
|
|
137
|
+
* </div>
|
|
138
|
+
* </ServiceMedia.Gallery>
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export const Gallery = (props) => {
|
|
142
|
+
const { children, infinite, autoPlay } = props;
|
|
143
|
+
return (_jsx(CoreServiceMediaGallery.MediaGallery, { children: ({ mediaItems }) => {
|
|
144
|
+
const mediaGalleryServiceConfig = {
|
|
145
|
+
media: mediaItems,
|
|
146
|
+
infinite,
|
|
147
|
+
autoPlay,
|
|
148
|
+
};
|
|
149
|
+
return (_jsx(MediaGallery.Root, { mediaGalleryServiceConfig: mediaGalleryServiceConfig, children: children }));
|
|
150
|
+
} }));
|
|
151
|
+
};
|
|
152
|
+
Gallery.displayName = 'ServiceMedia.Gallery';
|
|
153
|
+
/**
|
|
154
|
+
* ServiceMedia compound component for displaying service media
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```tsx
|
|
158
|
+
* import { Service, ServiceMedia } from '@wix/headless-bookings/react';
|
|
159
|
+
*
|
|
160
|
+
* function ServiceCard({ service }) {
|
|
161
|
+
* return (
|
|
162
|
+
* <Service.Root serviceServiceConfig={{ service }}>
|
|
163
|
+
* <ServiceMedia.Main className="w-full h-48 object-cover" />
|
|
164
|
+
* <Service.Name />
|
|
165
|
+
* </Service.Root>
|
|
166
|
+
* );
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export const ServiceMedia = {
|
|
171
|
+
Main,
|
|
172
|
+
Cover,
|
|
173
|
+
Gallery,
|
|
174
|
+
};
|
|
175
|
+
export default ServiceMedia;
|
|
@@ -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
|
+
}
|
package/dist/react/index.d.ts
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';
|
package/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';
|