@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
|
@@ -7,10 +7,9 @@ import React from 'react';
|
|
|
7
7
|
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
|
-
import { WixMediaImage } from '@wix/headless-media/react';
|
|
11
|
-
import { MediaGallery } from '@wix/headless-media/react';
|
|
12
10
|
import { RateType, } from '@wix/auto_sdk_bookings_services';
|
|
13
11
|
import * as Location from '../location/Location.js';
|
|
12
|
+
import * as ServiceMediaModule from './ServiceMedia.js';
|
|
14
13
|
var TestIds;
|
|
15
14
|
(function (TestIds) {
|
|
16
15
|
TestIds["serviceRoot"] = "service-root";
|
|
@@ -27,10 +26,6 @@ var TestIds;
|
|
|
27
26
|
TestIds["locationRoot"] = "location-root";
|
|
28
27
|
TestIds["serviceStaffMembers"] = "service-staff-members";
|
|
29
28
|
TestIds["serviceStaffMemberRepeater"] = "service-staff-member-repeater";
|
|
30
|
-
TestIds["serviceMedia"] = "service-media";
|
|
31
|
-
TestIds["serviceMainMedia"] = "service-main-media";
|
|
32
|
-
TestIds["serviceCoverMedia"] = "service-cover-media";
|
|
33
|
-
TestIds["serviceMediaItems"] = "service-media-items";
|
|
34
29
|
TestIds["serviceSchedule"] = "service-schedule";
|
|
35
30
|
TestIds["serviceDefaultCapacity"] = "service-default-capacity";
|
|
36
31
|
TestIds["serviceRaw"] = "service-raw";
|
|
@@ -538,148 +533,6 @@ export const StaffMemberRepeater = React.forwardRef((props, ref) => {
|
|
|
538
533
|
return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: staffMemberItemWrapper, asChild: asChild, children: children }));
|
|
539
534
|
});
|
|
540
535
|
StaffMemberRepeater.displayName = 'Service.StaffMembers.StaffMemberRepeater';
|
|
541
|
-
/**
|
|
542
|
-
* Displays the service main media image using WixMediaImage.
|
|
543
|
-
*
|
|
544
|
-
* @component
|
|
545
|
-
* @example
|
|
546
|
-
* ```tsx
|
|
547
|
-
* // Default usage
|
|
548
|
-
* <Service.MainMedia className="w-full h-64 object-cover rounded-lg" />
|
|
549
|
-
* ```
|
|
550
|
-
*
|
|
551
|
-
* @example
|
|
552
|
-
* ```tsx
|
|
553
|
-
* // asChild with primitive img element
|
|
554
|
-
* <Service.MainMedia asChild>
|
|
555
|
-
* <img className="w-full h-64 object-cover shadow-lg" />
|
|
556
|
-
* </Service.MainMedia>
|
|
557
|
-
* ```
|
|
558
|
-
*
|
|
559
|
-
* @example
|
|
560
|
-
* ```tsx
|
|
561
|
-
* // asChild with custom component accessing media data
|
|
562
|
-
* <Service.MainMedia asChild>
|
|
563
|
-
* {React.forwardRef(({media, ...props}, ref) => (
|
|
564
|
-
* <div ref={ref} {...props} className="relative aspect-video">
|
|
565
|
-
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
566
|
-
* <div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/50 p-4">
|
|
567
|
-
* <Service.Name className="text-primary-foreground" />
|
|
568
|
-
* </div>
|
|
569
|
-
* </div>
|
|
570
|
-
* ))}
|
|
571
|
-
* </Service.MainMedia>
|
|
572
|
-
* ```
|
|
573
|
-
*/
|
|
574
|
-
export const MainMedia = React.forwardRef((props, ref) => {
|
|
575
|
-
const { asChild, children, className } = props;
|
|
576
|
-
return (_jsx(CoreService.Info, { children: ({ mainMedia }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceMainMedia, customElement: children, customElementProps: { media: mainMedia }, children: mainMedia?.image ? _jsx(WixMediaImage, { media: mainMedia }) : null })) }));
|
|
577
|
-
});
|
|
578
|
-
MainMedia.displayName = 'Service.MainMedia';
|
|
579
|
-
/**
|
|
580
|
-
* Displays the service cover media image using WixMediaImage.
|
|
581
|
-
* The cover media is typically used as a hero/banner image.
|
|
582
|
-
*
|
|
583
|
-
* @component
|
|
584
|
-
* @example
|
|
585
|
-
* ```tsx
|
|
586
|
-
* // Default usage
|
|
587
|
-
* <Service.CoverMedia className="w-full h-96 object-cover" />
|
|
588
|
-
* ```
|
|
589
|
-
*
|
|
590
|
-
* @example
|
|
591
|
-
* ```tsx
|
|
592
|
-
* // asChild as a background image container
|
|
593
|
-
* <Service.CoverMedia asChild>
|
|
594
|
-
* <div className="w-full h-96 bg-cover bg-center" />
|
|
595
|
-
* </Service.CoverMedia>
|
|
596
|
-
* ```
|
|
597
|
-
*
|
|
598
|
-
* @example
|
|
599
|
-
* ```tsx
|
|
600
|
-
* // asChild with custom component accessing media data
|
|
601
|
-
* <Service.CoverMedia asChild>
|
|
602
|
-
* {React.forwardRef(({media, ...props}, ref) => (
|
|
603
|
-
* <header ref={ref} {...props} className="relative h-96">
|
|
604
|
-
* <WixMediaImage media={media} className="w-full h-full object-cover" />
|
|
605
|
-
* <div className="absolute inset-0 bg-black/40 flex items-center justify-center">
|
|
606
|
-
* <h1 className="text-4xl font-bold text-primary-foreground">
|
|
607
|
-
* <Service.Name />
|
|
608
|
-
* </h1>
|
|
609
|
-
* </div>
|
|
610
|
-
* </header>
|
|
611
|
-
* ))}
|
|
612
|
-
* </Service.CoverMedia>
|
|
613
|
-
* ```
|
|
614
|
-
*/
|
|
615
|
-
export const CoverMedia = React.forwardRef((props, ref) => {
|
|
616
|
-
const { asChild, children, className } = props;
|
|
617
|
-
return (_jsx(CoreService.Info, { children: ({ coverMedia }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceCoverMedia, customElement: children, customElementProps: { media: coverMedia }, children: coverMedia?.image ? _jsx(WixMediaImage, { media: coverMedia }) : null })) }));
|
|
618
|
-
});
|
|
619
|
-
CoverMedia.displayName = 'Service.CoverMedia';
|
|
620
|
-
/**
|
|
621
|
-
* Container for service media items gallery.
|
|
622
|
-
* Renders a MediaGallery.Root with the service media items.
|
|
623
|
-
* Supports autoPlay and infinite scroll options for carousel behavior.
|
|
624
|
-
*
|
|
625
|
-
* @component
|
|
626
|
-
* @example
|
|
627
|
-
* ```tsx
|
|
628
|
-
* // Basic usage with MediaGallery components
|
|
629
|
-
* <Service.MediaItems>
|
|
630
|
-
* <MediaGallery.Thumbnails>
|
|
631
|
-
* <MediaGallery.ThumbnailRepeater>
|
|
632
|
-
* {({ mediaItem, isActive }) => (
|
|
633
|
-
* <img
|
|
634
|
-
* src={mediaItem.url}
|
|
635
|
-
* alt={mediaItem.altText}
|
|
636
|
-
* className={isActive ? 'active' : ''}
|
|
637
|
-
* />
|
|
638
|
-
* )}
|
|
639
|
-
* </MediaGallery.ThumbnailRepeater>
|
|
640
|
-
* </MediaGallery.Thumbnails>
|
|
641
|
-
* </Service.MediaItems>
|
|
642
|
-
*
|
|
643
|
-
* // With autoPlay carousel
|
|
644
|
-
* <Service.MediaItems
|
|
645
|
-
* autoPlay={{ direction: 'forward', intervalMs: 3000 }}
|
|
646
|
-
* infinite
|
|
647
|
-
* >
|
|
648
|
-
* <MediaGallery.MainImage />
|
|
649
|
-
* <MediaGallery.Actions.Previous />
|
|
650
|
-
* <MediaGallery.Actions.Next />
|
|
651
|
-
* </Service.MediaItems>
|
|
652
|
-
*
|
|
653
|
-
* // Full gallery with thumbnails and navigation
|
|
654
|
-
* <Service.MediaItems infinite>
|
|
655
|
-
* <div className="gallery-container">
|
|
656
|
-
* <MediaGallery.MainImage className="main-image" />
|
|
657
|
-
* <div className="controls">
|
|
658
|
-
* <MediaGallery.Actions.Previous>Prev</MediaGallery.Actions.Previous>
|
|
659
|
-
* <MediaGallery.Actions.Next>Next</MediaGallery.Actions.Next>
|
|
660
|
-
* </div>
|
|
661
|
-
* <MediaGallery.Thumbnails className="thumbnails" />
|
|
662
|
-
* </div>
|
|
663
|
-
* </Service.MediaItems>
|
|
664
|
-
* ```
|
|
665
|
-
*/
|
|
666
|
-
export const MediaItems = React.forwardRef((props, ref) => {
|
|
667
|
-
const { children, infinite, autoPlay } = props;
|
|
668
|
-
return (_jsx(CoreService.Info, { children: ({ mediaItems }) => {
|
|
669
|
-
if (!mediaItems || mediaItems.length === 0)
|
|
670
|
-
return null;
|
|
671
|
-
const mediaGalleryServiceConfig = {
|
|
672
|
-
media: mediaItems,
|
|
673
|
-
infinite,
|
|
674
|
-
autoPlay,
|
|
675
|
-
};
|
|
676
|
-
const attributes = {
|
|
677
|
-
'data-testid': TestIds.serviceMediaItems,
|
|
678
|
-
};
|
|
679
|
-
return (_jsx("div", { ...attributes, ref: ref, children: _jsx(MediaGallery.Root, { mediaGalleryServiceConfig: mediaGalleryServiceConfig, children: children }) }));
|
|
680
|
-
} }));
|
|
681
|
-
});
|
|
682
|
-
MediaItems.displayName = 'Service.MediaItems';
|
|
683
536
|
/**
|
|
684
537
|
* Provides direct access to service object. Should be used only in rare cases.
|
|
685
538
|
*
|
|
@@ -1203,3 +1056,10 @@ export const StaffMembers = Object.assign(StaffMembersBase, {
|
|
|
1203
1056
|
List: StaffMembersList,
|
|
1204
1057
|
StaffMemberRepeater,
|
|
1205
1058
|
});
|
|
1059
|
+
// Re-export media components under Service namespace
|
|
1060
|
+
export const MainMedia = ServiceMediaModule.Main;
|
|
1061
|
+
MainMedia.displayName = 'Service.MainMedia';
|
|
1062
|
+
export const CoverMedia = ServiceMediaModule.Cover;
|
|
1063
|
+
CoverMedia.displayName = 'Service.CoverMedia';
|
|
1064
|
+
export const MediaGallery = ServiceMediaModule.Gallery;
|
|
1065
|
+
MediaGallery.displayName = 'Service.MediaGallery';
|
|
@@ -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,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[];
|