@wix/headless-bookings 0.0.53 → 0.0.55
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.js +1 -0
- package/cjs/dist/__mocks__/services.d.ts +38 -1
- package/cjs/dist/__mocks__/services.js +82 -0
- package/cjs/dist/api/query-services/index.js +33 -3
- package/cjs/dist/react/core/location/Location.d.ts +2 -2
- package/cjs/dist/react/core/location/Location.js +1 -1
- package/cjs/dist/react/core/staff-member/StaffMember.d.ts +104 -0
- package/cjs/dist/react/core/staff-member/StaffMember.js +143 -0
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.d.ts +96 -0
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +66 -0
- package/cjs/dist/react/index.d.ts +2 -0
- package/cjs/dist/react/index.js +2 -0
- package/cjs/dist/react/location/LocationList.d.ts +19 -0
- package/cjs/dist/react/location/LocationList.js +52 -1
- package/cjs/dist/react/service/Service.d.ts +51 -44
- package/cjs/dist/react/service/Service.js +56 -37
- package/cjs/dist/react/staff-member/StaffMember.d.ts +119 -0
- package/cjs/dist/react/staff-member/StaffMember.js +147 -0
- package/cjs/dist/react/staff-member/StaffMemberList.d.ts +123 -0
- package/cjs/dist/react/staff-member/StaffMemberList.js +168 -0
- package/cjs/dist/services/booking/booking.d.ts +2 -0
- package/cjs/dist/services/booking/booking.js +15 -0
- package/cjs/dist/services/index.d.ts +1 -0
- package/cjs/dist/services/index.js +1 -0
- package/cjs/dist/services/service-list/service-list.js +41 -9
- package/cjs/dist/services/staff-member-list/staff-member-list.d.ts +85 -0
- package/cjs/dist/services/staff-member-list/staff-member-list.def.d.ts +46 -0
- package/cjs/dist/services/staff-member-list/staff-member-list.def.js +14 -0
- package/cjs/dist/services/staff-member-list/staff-member-list.js +105 -0
- package/dist/__mocks__/booking.js +1 -0
- package/dist/__mocks__/services.d.ts +38 -1
- package/dist/__mocks__/services.js +82 -0
- package/dist/api/query-services/index.js +33 -3
- package/dist/react/core/location/Location.d.ts +2 -2
- package/dist/react/core/location/Location.js +1 -1
- package/dist/react/core/staff-member/StaffMember.d.ts +104 -0
- package/dist/react/core/staff-member/StaffMember.js +143 -0
- package/dist/react/core/staff-member-list/StaffMemberList.d.ts +96 -0
- package/dist/react/core/staff-member-list/StaffMemberList.js +66 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/react/location/LocationList.d.ts +19 -0
- package/dist/react/location/LocationList.js +52 -1
- package/dist/react/service/Service.d.ts +51 -44
- package/dist/react/service/Service.js +56 -37
- package/dist/react/staff-member/StaffMember.d.ts +119 -0
- package/dist/react/staff-member/StaffMember.js +147 -0
- package/dist/react/staff-member/StaffMemberList.d.ts +123 -0
- package/dist/react/staff-member/StaffMemberList.js +168 -0
- package/dist/services/booking/booking.d.ts +2 -0
- package/dist/services/booking/booking.js +15 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/service-list/service-list.js +41 -9
- package/dist/services/staff-member-list/staff-member-list.d.ts +85 -0
- package/dist/services/staff-member-list/staff-member-list.def.d.ts +46 -0
- package/dist/services/staff-member-list/staff-member-list.def.js +14 -0
- package/dist/services/staff-member-list/staff-member-list.js +105 -0
- package/package.json +2 -2
|
@@ -8,6 +8,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { GenericList, } from '@wix/headless-components/react';
|
|
10
10
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
11
|
+
import { useService } from '@wix/services-manager-react';
|
|
12
|
+
import { BookingServiceDefinition } from '../../services/booking/booking.js';
|
|
11
13
|
import * as CoreLocationList from '../core/location-list/LocationList.js';
|
|
12
14
|
import * as Location from './Location.js';
|
|
13
15
|
// ============================================================================
|
|
@@ -18,6 +20,7 @@ var TestIds;
|
|
|
18
20
|
TestIds["locationListRoot"] = "location-list-root";
|
|
19
21
|
TestIds["locationListLocations"] = "location-list-locations";
|
|
20
22
|
TestIds["locationListLocation"] = "location-list-location";
|
|
23
|
+
TestIds["locationListActionClear"] = "location-list-action-clear";
|
|
21
24
|
})(TestIds || (TestIds = {}));
|
|
22
25
|
/**
|
|
23
26
|
* Root component that provides the LocationList service context for rendering locations lists.
|
|
@@ -89,7 +92,7 @@ export const LocationRepeater = React.forwardRef((props, ref) => {
|
|
|
89
92
|
const location = displayLocation.location ?? {
|
|
90
93
|
locationType: displayLocation.type,
|
|
91
94
|
synthetic: true,
|
|
92
|
-
|
|
95
|
+
_id: displayLocation.id,
|
|
93
96
|
};
|
|
94
97
|
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
98
|
};
|
|
@@ -118,3 +121,51 @@ export const Totals = React.forwardRef((props, ref) => {
|
|
|
118
121
|
} }));
|
|
119
122
|
});
|
|
120
123
|
Totals.displayName = 'LocationList.Totals';
|
|
124
|
+
/**
|
|
125
|
+
* Button to clear the location selection.
|
|
126
|
+
* Clears the location from the BookingService.
|
|
127
|
+
*
|
|
128
|
+
* @component
|
|
129
|
+
* @example
|
|
130
|
+
* ```tsx
|
|
131
|
+
* // Default button with "Clear" label
|
|
132
|
+
* <LocationList.Actions.Clear />
|
|
133
|
+
*
|
|
134
|
+
* // With custom label
|
|
135
|
+
* <LocationList.Actions.Clear label="Clear selection" />
|
|
136
|
+
*
|
|
137
|
+
* // With asChild
|
|
138
|
+
* <LocationList.Actions.Clear asChild>
|
|
139
|
+
* <button className="btn-secondary">Clear location</button>
|
|
140
|
+
* </LocationList.Actions.Clear>
|
|
141
|
+
*
|
|
142
|
+
* // Using render prop pattern
|
|
143
|
+
* <LocationList.Actions.Clear>
|
|
144
|
+
* {({ onClick }) => <button onClick={onClick}>Clear selection</button>}
|
|
145
|
+
* </LocationList.Actions.Clear>
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
const Clear = React.forwardRef((props, ref) => {
|
|
149
|
+
const { asChild, children, className, label = 'Clear', onClicked } = props;
|
|
150
|
+
let bookingService = null;
|
|
151
|
+
try {
|
|
152
|
+
bookingService = useService(BookingServiceDefinition);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// BookingService not available - likely no ServiceManagerProvider
|
|
156
|
+
}
|
|
157
|
+
const handleClick = () => {
|
|
158
|
+
bookingService?.actions.clearLocation();
|
|
159
|
+
onClicked?.();
|
|
160
|
+
};
|
|
161
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationListActionClear, customElement: children, customElementProps: {
|
|
162
|
+
onClick: handleClick,
|
|
163
|
+
}, children: _jsx("button", { type: "button", onClick: handleClick, children: label }) }));
|
|
164
|
+
});
|
|
165
|
+
Clear.displayName = 'LocationList.Actions.Clear';
|
|
166
|
+
/**
|
|
167
|
+
* Actions namespace for location list-level actions
|
|
168
|
+
*/
|
|
169
|
+
export const Actions = {
|
|
170
|
+
Clear,
|
|
171
|
+
};
|
|
@@ -514,14 +514,6 @@ export interface LocationRepeaterProps {
|
|
|
514
514
|
* ```
|
|
515
515
|
*/
|
|
516
516
|
export declare const LocationRepeater: React.ForwardRefExoticComponent<LocationRepeaterProps & React.RefAttributes<HTMLElement>>;
|
|
517
|
-
/**
|
|
518
|
-
* Type for staff member
|
|
519
|
-
*/
|
|
520
|
-
type StaffMemberType = {
|
|
521
|
-
name?: string;
|
|
522
|
-
_id?: string;
|
|
523
|
-
id: string;
|
|
524
|
-
};
|
|
525
517
|
/**
|
|
526
518
|
* Props for Service StaffMembers component (Container Level)
|
|
527
519
|
*/
|
|
@@ -534,6 +526,7 @@ export interface StaffMembersProps {
|
|
|
534
526
|
* Container for service staff members list (Container Level).
|
|
535
527
|
* Follows the 3-level List/Options/Repeater pattern.
|
|
536
528
|
* Provides context and doesn't render when there are no staff members.
|
|
529
|
+
* Internally uses StaffMemberList.Root for consistent staff member handling.
|
|
537
530
|
*
|
|
538
531
|
* @component
|
|
539
532
|
* @example
|
|
@@ -542,12 +535,7 @@ export interface StaffMembersProps {
|
|
|
542
535
|
* <Service.StaffMembers>
|
|
543
536
|
* <Service.StaffMembers.List emptyState={<div>No staff assigned</div>}>
|
|
544
537
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
545
|
-
*
|
|
546
|
-
* <div className="staff-card">
|
|
547
|
-
* <img src={staffMember.mainMedia?.image} alt={staffMember.name} />
|
|
548
|
-
* <span>{staffMember.name}</span>
|
|
549
|
-
* </div>
|
|
550
|
-
* )}
|
|
538
|
+
* <StaffMember.Name />
|
|
551
539
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
552
540
|
* </Service.StaffMembers.List>
|
|
553
541
|
* </Service.StaffMembers>
|
|
@@ -557,14 +545,14 @@ export interface StaffMembersProps {
|
|
|
557
545
|
* <ul className="staff-list">
|
|
558
546
|
* <Service.StaffMembers.List>
|
|
559
547
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
560
|
-
*
|
|
548
|
+
* <li><StaffMember.Name /></li>
|
|
561
549
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
562
550
|
* </Service.StaffMembers.List>
|
|
563
551
|
* </ul>
|
|
564
552
|
* </Service.StaffMembers>
|
|
565
553
|
* ```
|
|
566
554
|
*/
|
|
567
|
-
|
|
555
|
+
declare const StaffMembersBase: React.ForwardRefExoticComponent<StaffMembersProps & React.RefAttributes<HTMLElement>>;
|
|
568
556
|
/**
|
|
569
557
|
* Props for Service StaffMembers.List component (List Container Level)
|
|
570
558
|
*/
|
|
@@ -576,6 +564,7 @@ export interface StaffMembersListProps {
|
|
|
576
564
|
/**
|
|
577
565
|
* List container for staff members with empty state support (List Container Level).
|
|
578
566
|
* Renders emptyState when no staff members, otherwise renders children.
|
|
567
|
+
* Internally delegates to StaffMemberList.StaffMembers.
|
|
579
568
|
*
|
|
580
569
|
* @component
|
|
581
570
|
* @example
|
|
@@ -586,47 +575,30 @@ export interface StaffMembersListProps {
|
|
|
586
575
|
* ```
|
|
587
576
|
*/
|
|
588
577
|
export declare const StaffMembersList: React.ForwardRefExoticComponent<StaffMembersListProps & React.RefAttributes<HTMLElement>>;
|
|
589
|
-
/**
|
|
590
|
-
* Render props for StaffMemberRepeater asChild pattern
|
|
591
|
-
*/
|
|
592
|
-
export interface StaffMemberRepeaterRenderProps {
|
|
593
|
-
items: StaffMemberType[];
|
|
594
|
-
itemWrapper: (props: {
|
|
595
|
-
item: StaffMemberType;
|
|
596
|
-
index: number;
|
|
597
|
-
children: React.ReactNode;
|
|
598
|
-
}) => React.ReactNode;
|
|
599
|
-
}
|
|
600
578
|
/**
|
|
601
579
|
* Props for Service StaffMembers.StaffMemberRepeater component
|
|
602
580
|
*/
|
|
603
581
|
export interface StaffMemberRepeaterProps {
|
|
604
|
-
children?: React.ReactNode
|
|
605
|
-
asChild?: boolean;
|
|
582
|
+
children?: React.ReactNode;
|
|
606
583
|
}
|
|
607
584
|
/**
|
|
608
|
-
* Repeater component that renders
|
|
609
|
-
*
|
|
585
|
+
* Repeater component that renders StaffMember.Root for each staff member.
|
|
586
|
+
* Internally delegates to StaffMemberList.StaffMemberRepeater.
|
|
587
|
+
* Children are rendered inside each StaffMember.Root context.
|
|
610
588
|
*
|
|
611
589
|
* @component
|
|
612
590
|
* @example
|
|
613
591
|
* ```tsx
|
|
614
|
-
* // Standard usage - renders staff member
|
|
592
|
+
* // Standard usage - renders StaffMember.Root for each staff member
|
|
615
593
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
616
|
-
* <
|
|
594
|
+
* <StaffMember.Name />
|
|
617
595
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
618
596
|
*
|
|
619
|
-
* //
|
|
620
|
-
* <Service.StaffMembers.StaffMemberRepeater
|
|
621
|
-
*
|
|
622
|
-
* <
|
|
623
|
-
*
|
|
624
|
-
* <li key={item.id}>
|
|
625
|
-
* {index + 1}. {itemWrapper({ item, index, children: null })}
|
|
626
|
-
* </li>
|
|
627
|
-
* ))}
|
|
628
|
-
* </ol>
|
|
629
|
-
* )}
|
|
597
|
+
* // With custom styling
|
|
598
|
+
* <Service.StaffMembers.StaffMemberRepeater>
|
|
599
|
+
* <div className="staff-card">
|
|
600
|
+
* <StaffMember.Name className="font-bold" />
|
|
601
|
+
* </div>
|
|
630
602
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
631
603
|
* ```
|
|
632
604
|
*/
|
|
@@ -1161,6 +1133,41 @@ export interface DefaultCapacityProps {
|
|
|
1161
1133
|
* ```
|
|
1162
1134
|
*/
|
|
1163
1135
|
export declare const DefaultCapacity: React.ForwardRefExoticComponent<DefaultCapacityProps & React.RefAttributes<HTMLElement>>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Props for Service AvailableOnline component
|
|
1138
|
+
*/
|
|
1139
|
+
export interface AvailableOnlineProps {
|
|
1140
|
+
asChild?: boolean;
|
|
1141
|
+
children?: AsChildChildren<{
|
|
1142
|
+
availableOnline: boolean;
|
|
1143
|
+
}>;
|
|
1144
|
+
className?: string;
|
|
1145
|
+
label?: string;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Displays whether the service is available online (conferencing enabled).
|
|
1149
|
+
* Headless component - contains zero formatting logic.
|
|
1150
|
+
*
|
|
1151
|
+
* Maps to: service.conferencing.enabled
|
|
1152
|
+
*
|
|
1153
|
+
* @component
|
|
1154
|
+
* @example
|
|
1155
|
+
* ```tsx
|
|
1156
|
+
* // Default usage - displays label only when available online
|
|
1157
|
+
* <Service.AvailableOnline label="Available Online" className="text-sm text-secondary-foreground" />
|
|
1158
|
+
* ```
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```tsx
|
|
1162
|
+
* // asChild with custom component
|
|
1163
|
+
* <Service.AvailableOnline asChild>
|
|
1164
|
+
* {({ availableOnline }) => availableOnline ? (
|
|
1165
|
+
* <span className="badge bg-green-500">Online</span>
|
|
1166
|
+
* ) : null}
|
|
1167
|
+
* </Service.AvailableOnline>
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
export declare const AvailableOnline: React.ForwardRefExoticComponent<AvailableOnlineProps & React.RefAttributes<HTMLElement>>;
|
|
1164
1171
|
export declare const Locations: typeof LocationsBase & {
|
|
1165
1172
|
List: typeof LocationsList;
|
|
1166
1173
|
LocationRepeater: typeof LocationRepeater;
|
|
@@ -6,11 +6,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import * as CoreService from '../core/service/Service.js';
|
|
8
8
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
9
|
-
import { Money
|
|
9
|
+
import { Money } from '@wix/headless-components/react';
|
|
10
10
|
import { RateType, } from '@wix/auto_sdk_bookings_services';
|
|
11
11
|
import * as LocationList from '../location/LocationList.js';
|
|
12
12
|
// Note: Location components are used inside LocationList.LocationRepeater
|
|
13
13
|
// Users should import { Location } from '@wix/headless-bookings/react' for Location.Name, Location.Address, etc.
|
|
14
|
+
import * as StaffMemberListModule from '../staff-member/StaffMemberList.js';
|
|
15
|
+
// Note: StaffMember components are used inside StaffMemberList.StaffMemberRepeater
|
|
16
|
+
// Users should import { StaffMember } from '@wix/headless-bookings/react' for StaffMember.Name, etc.
|
|
14
17
|
import * as ServiceMediaModule from './ServiceMedia.js';
|
|
15
18
|
var TestIds;
|
|
16
19
|
(function (TestIds) {
|
|
@@ -46,6 +49,8 @@ var TestIds;
|
|
|
46
49
|
TestIds["serviceScheduleFirstSessionStart"] = "service-schedule-first-session-start";
|
|
47
50
|
TestIds["serviceScheduleLastSessionEnd"] = "service-schedule-last-session-end";
|
|
48
51
|
TestIds["serviceScheduleSessionDuration"] = "service-schedule-session-duration";
|
|
52
|
+
// Conferencing component TestIds
|
|
53
|
+
TestIds["serviceAvailableOnline"] = "service-available-online";
|
|
49
54
|
})(TestIds || (TestIds = {}));
|
|
50
55
|
/**
|
|
51
56
|
* Root component that provides service context to the entire app.
|
|
@@ -467,6 +472,7 @@ LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
|
|
|
467
472
|
* Container for service staff members list (Container Level).
|
|
468
473
|
* Follows the 3-level List/Options/Repeater pattern.
|
|
469
474
|
* Provides context and doesn't render when there are no staff members.
|
|
475
|
+
* Internally uses StaffMemberList.Root for consistent staff member handling.
|
|
470
476
|
*
|
|
471
477
|
* @component
|
|
472
478
|
* @example
|
|
@@ -475,12 +481,7 @@ LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
|
|
|
475
481
|
* <Service.StaffMembers>
|
|
476
482
|
* <Service.StaffMembers.List emptyState={<div>No staff assigned</div>}>
|
|
477
483
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
478
|
-
*
|
|
479
|
-
* <div className="staff-card">
|
|
480
|
-
* <img src={staffMember.mainMedia?.image} alt={staffMember.name} />
|
|
481
|
-
* <span>{staffMember.name}</span>
|
|
482
|
-
* </div>
|
|
483
|
-
* )}
|
|
484
|
+
* <StaffMember.Name />
|
|
484
485
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
485
486
|
* </Service.StaffMembers.List>
|
|
486
487
|
* </Service.StaffMembers>
|
|
@@ -490,32 +491,28 @@ LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
|
|
|
490
491
|
* <ul className="staff-list">
|
|
491
492
|
* <Service.StaffMembers.List>
|
|
492
493
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
493
|
-
*
|
|
494
|
+
* <li><StaffMember.Name /></li>
|
|
494
495
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
495
496
|
* </Service.StaffMembers.List>
|
|
496
497
|
* </ul>
|
|
497
498
|
* </Service.StaffMembers>
|
|
498
499
|
* ```
|
|
499
500
|
*/
|
|
500
|
-
|
|
501
|
+
const StaffMembersBase = React.forwardRef((props, ref) => {
|
|
501
502
|
const { asChild, children, className, ...attributes } = props;
|
|
502
503
|
return (_jsx(CoreService.Info, { children: ({ staff }) => {
|
|
503
504
|
// Container level: don't render if no staff members
|
|
504
505
|
if (!staff || staff.length === 0) {
|
|
505
506
|
return null;
|
|
506
507
|
}
|
|
507
|
-
|
|
508
|
-
const items = staff.map((member, index) => ({
|
|
509
|
-
...member,
|
|
510
|
-
id: member._id || String(index),
|
|
511
|
-
}));
|
|
512
|
-
return (_jsx(GenericList.Root, { items: items, children: _jsx(AsChildSlot, { ...attributes, ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceStaffMembers, customElement: children, children: _jsx("div", { children: React.isValidElement(children) ? children : null }) }) }));
|
|
508
|
+
return (_jsx(StaffMemberListModule.Root, { staffMemberListConfig: { staffMembers: staff }, className: className, ref: ref, children: _jsx(AsChildSlot, { ...attributes, asChild: asChild, className: className, "data-testid": TestIds.serviceStaffMembers, customElement: children, children: _jsx("div", { children: children }) }) }));
|
|
513
509
|
} }));
|
|
514
510
|
});
|
|
515
511
|
StaffMembersBase.displayName = 'Service.StaffMembers';
|
|
516
512
|
/**
|
|
517
513
|
* List container for staff members with empty state support (List Container Level).
|
|
518
514
|
* Renders emptyState when no staff members, otherwise renders children.
|
|
515
|
+
* Internally delegates to StaffMemberList.StaffMembers.
|
|
519
516
|
*
|
|
520
517
|
* @component
|
|
521
518
|
* @example
|
|
@@ -527,42 +524,33 @@ StaffMembersBase.displayName = 'Service.StaffMembers';
|
|
|
527
524
|
*/
|
|
528
525
|
export const StaffMembersList = React.forwardRef((props, ref) => {
|
|
529
526
|
const { children, emptyState, className, ...otherProps } = props;
|
|
530
|
-
return (_jsx(
|
|
527
|
+
return (_jsx(StaffMemberListModule.StaffMembers, { ref: ref, emptyState: emptyState, className: className, ...otherProps, children: children }));
|
|
531
528
|
});
|
|
532
529
|
StaffMembersList.displayName = 'Service.StaffMembers.List';
|
|
533
530
|
/**
|
|
534
|
-
* Repeater component that renders
|
|
535
|
-
*
|
|
531
|
+
* Repeater component that renders StaffMember.Root for each staff member.
|
|
532
|
+
* Internally delegates to StaffMemberList.StaffMemberRepeater.
|
|
533
|
+
* Children are rendered inside each StaffMember.Root context.
|
|
536
534
|
*
|
|
537
535
|
* @component
|
|
538
536
|
* @example
|
|
539
537
|
* ```tsx
|
|
540
|
-
* // Standard usage - renders staff member
|
|
538
|
+
* // Standard usage - renders StaffMember.Root for each staff member
|
|
541
539
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
542
|
-
* <
|
|
540
|
+
* <StaffMember.Name />
|
|
543
541
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
544
542
|
*
|
|
545
|
-
* //
|
|
546
|
-
* <Service.StaffMembers.StaffMemberRepeater
|
|
547
|
-
*
|
|
548
|
-
* <
|
|
549
|
-
*
|
|
550
|
-
* <li key={item.id}>
|
|
551
|
-
* {index + 1}. {itemWrapper({ item, index, children: null })}
|
|
552
|
-
* </li>
|
|
553
|
-
* ))}
|
|
554
|
-
* </ol>
|
|
555
|
-
* )}
|
|
543
|
+
* // With custom styling
|
|
544
|
+
* <Service.StaffMembers.StaffMemberRepeater>
|
|
545
|
+
* <div className="staff-card">
|
|
546
|
+
* <StaffMember.Name className="font-bold" />
|
|
547
|
+
* </div>
|
|
556
548
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
557
549
|
* ```
|
|
558
550
|
*/
|
|
559
551
|
export const StaffMemberRepeater = React.forwardRef((props, ref) => {
|
|
560
|
-
const { children
|
|
561
|
-
|
|
562
|
-
const staffMemberItemWrapper = ({ item: member, children: itemChildren, }) => {
|
|
563
|
-
return (_jsxs(React.Fragment, { children: [_jsx("span", { "data-testid": TestIds.serviceStaffMemberRepeater, children: member.name }), itemChildren] }, member.id));
|
|
564
|
-
};
|
|
565
|
-
return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: staffMemberItemWrapper, asChild: asChild, children: children }));
|
|
552
|
+
const { children } = props;
|
|
553
|
+
return (_jsx(StaffMemberListModule.StaffMemberRepeater, { ref: ref, children: children }));
|
|
566
554
|
});
|
|
567
555
|
StaffMemberRepeater.displayName = 'Service.StaffMembers.StaffMemberRepeater';
|
|
568
556
|
/**
|
|
@@ -1097,6 +1085,37 @@ export const DefaultCapacity = React.forwardRef((props, ref) => {
|
|
|
1097
1085
|
} }));
|
|
1098
1086
|
});
|
|
1099
1087
|
DefaultCapacity.displayName = 'Service.DefaultCapacity';
|
|
1088
|
+
/**
|
|
1089
|
+
* Displays whether the service is available online (conferencing enabled).
|
|
1090
|
+
* Headless component - contains zero formatting logic.
|
|
1091
|
+
*
|
|
1092
|
+
* Maps to: service.conferencing.enabled
|
|
1093
|
+
*
|
|
1094
|
+
* @component
|
|
1095
|
+
* @example
|
|
1096
|
+
* ```tsx
|
|
1097
|
+
* // Default usage - displays label only when available online
|
|
1098
|
+
* <Service.AvailableOnline label="Available Online" className="text-sm text-secondary-foreground" />
|
|
1099
|
+
* ```
|
|
1100
|
+
*
|
|
1101
|
+
* @example
|
|
1102
|
+
* ```tsx
|
|
1103
|
+
* // asChild with custom component
|
|
1104
|
+
* <Service.AvailableOnline asChild>
|
|
1105
|
+
* {({ availableOnline }) => availableOnline ? (
|
|
1106
|
+
* <span className="badge bg-green-500">Online</span>
|
|
1107
|
+
* ) : null}
|
|
1108
|
+
* </Service.AvailableOnline>
|
|
1109
|
+
* ```
|
|
1110
|
+
*/
|
|
1111
|
+
export const AvailableOnline = React.forwardRef((props, ref) => {
|
|
1112
|
+
const { asChild, children, className, label } = props;
|
|
1113
|
+
return (_jsx(CoreService.Service, { children: ({ service }) => {
|
|
1114
|
+
const availableOnline = service.conferencing?.enabled ?? false;
|
|
1115
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.serviceAvailableOnline, customElement: children, customElementProps: { availableOnline }, children: availableOnline && label ? _jsx("span", { children: label }) : null }));
|
|
1116
|
+
} }));
|
|
1117
|
+
});
|
|
1118
|
+
AvailableOnline.displayName = 'Service.AvailableOnline';
|
|
1100
1119
|
// Create Locations with nested components
|
|
1101
1120
|
export const Locations = Object.assign(LocationsBase, {
|
|
1102
1121
|
List: LocationsList,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StaffMember - Headless component for displaying staff member information
|
|
3
|
+
* Provides components for displaying staff member name
|
|
4
|
+
*
|
|
5
|
+
* @module React/StaffMember
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import * as CoreStaffMember from '../core/staff-member/StaffMember.js';
|
|
9
|
+
import { type AsChildChildren } from '@wix/headless-utils/react';
|
|
10
|
+
export { useStaffMemberContext } from '../core/staff-member/StaffMember.js';
|
|
11
|
+
export type { StaffMemberData, StaffMemberRenderProps, } from '../core/staff-member/StaffMember.js';
|
|
12
|
+
/**
|
|
13
|
+
* Props for StaffMember.Root component
|
|
14
|
+
*/
|
|
15
|
+
export interface RootProps {
|
|
16
|
+
/** Raw staff member data */
|
|
17
|
+
staffMember?: CoreStaffMember.StaffMemberData;
|
|
18
|
+
/** Use asChild pattern */
|
|
19
|
+
asChild?: boolean;
|
|
20
|
+
/** Children - ReactNode or render function with all StaffMemberRenderProps */
|
|
21
|
+
children?: React.ReactNode | AsChildChildren<CoreStaffMember.StaffMemberRenderProps>;
|
|
22
|
+
/** CSS class name */
|
|
23
|
+
className?: string;
|
|
24
|
+
/** Data attributes */
|
|
25
|
+
[key: `data-${string}`]: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Root component that provides staff member context and handles data parsing.
|
|
29
|
+
*
|
|
30
|
+
* @component
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // With staff member data
|
|
34
|
+
* <StaffMember.Root staffMember={staffMemberData}>
|
|
35
|
+
* <StaffMember.Name className="font-bold" />
|
|
36
|
+
* </StaffMember.Root>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // With asChild to access all staff member data
|
|
42
|
+
* <StaffMember.Root staffMember={staffMember} asChild>
|
|
43
|
+
* {({ name, rawStaffMember }) => (
|
|
44
|
+
* <div>
|
|
45
|
+
* <span>{name}</span>
|
|
46
|
+
* </div>
|
|
47
|
+
* )}
|
|
48
|
+
* </StaffMember.Root>
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLElement>>;
|
|
52
|
+
/**
|
|
53
|
+
* Props for StaffMember.Name component
|
|
54
|
+
*/
|
|
55
|
+
export interface NameProps {
|
|
56
|
+
asChild?: boolean;
|
|
57
|
+
children?: React.ReactNode | AsChildChildren<{
|
|
58
|
+
name: string | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
className?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Displays the staff member name.
|
|
64
|
+
*
|
|
65
|
+
* @component
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <StaffMember.Name className="font-bold" />
|
|
69
|
+
*
|
|
70
|
+
* // With asChild
|
|
71
|
+
* <StaffMember.Name asChild>
|
|
72
|
+
* {({ name }) => <h3>{name || 'Unknown Staff'}</h3>}
|
|
73
|
+
* </StaffMember.Name>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare const Name: React.ForwardRefExoticComponent<NameProps & React.RefAttributes<HTMLElement>>;
|
|
77
|
+
/**
|
|
78
|
+
* Props for StaffMember.Raw component
|
|
79
|
+
*/
|
|
80
|
+
export interface RawProps {
|
|
81
|
+
children: (props: CoreStaffMember.StaffMemberRenderProps) => React.ReactNode;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Exposes all raw staff member data via render prop.
|
|
85
|
+
* Use only when you need full access to staff member data.
|
|
86
|
+
*
|
|
87
|
+
* @component
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <StaffMember.Raw>
|
|
91
|
+
* {({ rawStaffMember, name }) => (
|
|
92
|
+
* <pre>{JSON.stringify(rawStaffMember, null, 2)}</pre>
|
|
93
|
+
* )}
|
|
94
|
+
* </StaffMember.Raw>
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare const Raw: React.FC<RawProps>;
|
|
98
|
+
/**
|
|
99
|
+
* Props for StaffMember.Actions.Select component
|
|
100
|
+
*/
|
|
101
|
+
export interface SelectProps {
|
|
102
|
+
asChild?: boolean;
|
|
103
|
+
children?: React.ReactNode | AsChildChildren<{
|
|
104
|
+
onClick: () => void;
|
|
105
|
+
selected: boolean;
|
|
106
|
+
staffMember: CoreStaffMember.StaffMemberData | null;
|
|
107
|
+
}>;
|
|
108
|
+
/** Callback fired after staff member is selected - receives the staff member */
|
|
109
|
+
onClicked?: (staffMember: CoreStaffMember.StaffMemberData) => void;
|
|
110
|
+
/** Label for the button */
|
|
111
|
+
label?: string;
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Actions namespace for staff member-related actions
|
|
116
|
+
*/
|
|
117
|
+
export declare const Actions: {
|
|
118
|
+
Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
119
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* StaffMember - Headless component for displaying staff member information
|
|
4
|
+
* Provides components for displaying staff member name
|
|
5
|
+
*
|
|
6
|
+
* @module React/StaffMember
|
|
7
|
+
*/
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import * as CoreStaffMember from '../core/staff-member/StaffMember.js';
|
|
10
|
+
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
11
|
+
// Re-export useStaffMemberContext from core
|
|
12
|
+
export { useStaffMemberContext } from '../core/staff-member/StaffMember.js';
|
|
13
|
+
// ==========================================
|
|
14
|
+
// TestIds Enum
|
|
15
|
+
// ==========================================
|
|
16
|
+
var TestIds;
|
|
17
|
+
(function (TestIds) {
|
|
18
|
+
TestIds["staffMemberRoot"] = "staff-member-root";
|
|
19
|
+
TestIds["staffMemberName"] = "staff-member-name";
|
|
20
|
+
TestIds["staffMemberRaw"] = "staff-member-raw";
|
|
21
|
+
TestIds["staffMemberActionSelect"] = "staff-member-action-select";
|
|
22
|
+
})(TestIds || (TestIds = {}));
|
|
23
|
+
// ==========================================
|
|
24
|
+
// Type Definitions
|
|
25
|
+
// ==========================================
|
|
26
|
+
// Use the core's context hook
|
|
27
|
+
const useStaffMemberContext = CoreStaffMember.useStaffMemberContext;
|
|
28
|
+
// ==========================================
|
|
29
|
+
// Root Component
|
|
30
|
+
// ==========================================
|
|
31
|
+
/**
|
|
32
|
+
* Root component that provides staff member context and handles data parsing.
|
|
33
|
+
*
|
|
34
|
+
* @component
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* // With staff member data
|
|
38
|
+
* <StaffMember.Root staffMember={staffMemberData}>
|
|
39
|
+
* <StaffMember.Name className="font-bold" />
|
|
40
|
+
* </StaffMember.Root>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* // With asChild to access all staff member data
|
|
46
|
+
* <StaffMember.Root staffMember={staffMember} asChild>
|
|
47
|
+
* {({ name, rawStaffMember }) => (
|
|
48
|
+
* <div>
|
|
49
|
+
* <span>{name}</span>
|
|
50
|
+
* </div>
|
|
51
|
+
* )}
|
|
52
|
+
* </StaffMember.Root>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export const Root = React.forwardRef((props, ref) => {
|
|
56
|
+
const { staffMember, asChild, children, className, ...attrs } = props;
|
|
57
|
+
// Extract data-* attributes
|
|
58
|
+
const dataAttrs = Object.fromEntries(Object.entries(attrs).filter(([key]) => key.startsWith('data-')));
|
|
59
|
+
return (_jsx(CoreStaffMember.Root, { staffMember: staffMember, children: _jsx(CoreStaffMember.Data, { children: (renderProps) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.staffMemberRoot, customElement: children, customElementProps: renderProps, ...dataAttrs, children: children })) }) }));
|
|
60
|
+
});
|
|
61
|
+
Root.displayName = 'StaffMember.Root';
|
|
62
|
+
/**
|
|
63
|
+
* Displays the staff member name.
|
|
64
|
+
*
|
|
65
|
+
* @component
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <StaffMember.Name className="font-bold" />
|
|
69
|
+
*
|
|
70
|
+
* // With asChild
|
|
71
|
+
* <StaffMember.Name asChild>
|
|
72
|
+
* {({ name }) => <h3>{name || 'Unknown Staff'}</h3>}
|
|
73
|
+
* </StaffMember.Name>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export const Name = React.forwardRef((props, ref) => {
|
|
77
|
+
const { asChild, children, className, ...attrs } = props;
|
|
78
|
+
const { name } = useStaffMemberContext();
|
|
79
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.staffMemberName, customElement: children, customElementProps: { name }, ...attrs, children: name ? _jsx("span", { children: name }) : null }));
|
|
80
|
+
});
|
|
81
|
+
Name.displayName = 'StaffMember.Name';
|
|
82
|
+
/**
|
|
83
|
+
* Exposes all raw staff member data via render prop.
|
|
84
|
+
* Use only when you need full access to staff member data.
|
|
85
|
+
*
|
|
86
|
+
* @component
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* <StaffMember.Raw>
|
|
90
|
+
* {({ rawStaffMember, name }) => (
|
|
91
|
+
* <pre>{JSON.stringify(rawStaffMember, null, 2)}</pre>
|
|
92
|
+
* )}
|
|
93
|
+
* </StaffMember.Raw>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export const Raw = (props) => {
|
|
97
|
+
const context = useStaffMemberContext();
|
|
98
|
+
return _jsx(_Fragment, { children: props.children(context) });
|
|
99
|
+
};
|
|
100
|
+
Raw.displayName = 'StaffMember.Raw';
|
|
101
|
+
/**
|
|
102
|
+
* Selection action component for choosing a staff member.
|
|
103
|
+
*
|
|
104
|
+
* @component
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* <StaffMember.Actions.Select label="Choose Staff Member" />
|
|
108
|
+
*
|
|
109
|
+
* // With onClicked callback
|
|
110
|
+
* <StaffMember.Actions.Select
|
|
111
|
+
* label="Select"
|
|
112
|
+
* onClicked={(staffMember) => console.log('Selected:', staffMember.name)}
|
|
113
|
+
* />
|
|
114
|
+
*
|
|
115
|
+
* // With asChild
|
|
116
|
+
* <StaffMember.Actions.Select asChild>
|
|
117
|
+
* {({ onClick, selected }) => (
|
|
118
|
+
* <Button onClick={onClick} variant={selected ? 'primary' : 'outline'}>
|
|
119
|
+
* {selected ? 'Selected' : 'Select'}
|
|
120
|
+
* </Button>
|
|
121
|
+
* )}
|
|
122
|
+
* </StaffMember.Actions.Select>
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
const Select = React.forwardRef((props, ref) => {
|
|
126
|
+
const { asChild, children, onClicked, label = 'Select', className, ...attrs } = props;
|
|
127
|
+
return (_jsx(CoreStaffMember.Actions, { children: ({ select, selected, rawStaffMember }) => {
|
|
128
|
+
const handleClick = () => {
|
|
129
|
+
select();
|
|
130
|
+
if (onClicked && rawStaffMember) {
|
|
131
|
+
onClicked(rawStaffMember);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.staffMemberActionSelect, "data-selected": selected, customElement: children, customElementProps: {
|
|
135
|
+
onClick: handleClick,
|
|
136
|
+
selected,
|
|
137
|
+
staffMember: rawStaffMember,
|
|
138
|
+
}, ...attrs, children: _jsx("button", { type: "button", onClick: handleClick, children: label }) }));
|
|
139
|
+
} }));
|
|
140
|
+
});
|
|
141
|
+
Select.displayName = 'StaffMember.Actions.Select';
|
|
142
|
+
/**
|
|
143
|
+
* Actions namespace for staff member-related actions
|
|
144
|
+
*/
|
|
145
|
+
export const Actions = {
|
|
146
|
+
Select,
|
|
147
|
+
};
|