@wix/headless-bookings 0.0.53 → 0.0.54
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 +5 -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 +51 -0
- package/cjs/dist/react/service/Service.d.ts +16 -44
- package/cjs/dist/react/service/Service.js +23 -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/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 +5 -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 +51 -0
- package/dist/react/service/Service.d.ts +16 -44
- package/dist/react/service/Service.js +23 -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/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
|
@@ -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
|
*/
|
|
@@ -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) {
|
|
@@ -467,6 +470,7 @@ LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
|
|
|
467
470
|
* Container for service staff members list (Container Level).
|
|
468
471
|
* Follows the 3-level List/Options/Repeater pattern.
|
|
469
472
|
* Provides context and doesn't render when there are no staff members.
|
|
473
|
+
* Internally uses StaffMemberList.Root for consistent staff member handling.
|
|
470
474
|
*
|
|
471
475
|
* @component
|
|
472
476
|
* @example
|
|
@@ -475,12 +479,7 @@ LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
|
|
|
475
479
|
* <Service.StaffMembers>
|
|
476
480
|
* <Service.StaffMembers.List emptyState={<div>No staff assigned</div>}>
|
|
477
481
|
* <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
|
-
* )}
|
|
482
|
+
* <StaffMember.Name />
|
|
484
483
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
485
484
|
* </Service.StaffMembers.List>
|
|
486
485
|
* </Service.StaffMembers>
|
|
@@ -490,32 +489,28 @@ LocationRepeater.displayName = 'Service.Locations.LocationRepeater';
|
|
|
490
489
|
* <ul className="staff-list">
|
|
491
490
|
* <Service.StaffMembers.List>
|
|
492
491
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
493
|
-
*
|
|
492
|
+
* <li><StaffMember.Name /></li>
|
|
494
493
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
495
494
|
* </Service.StaffMembers.List>
|
|
496
495
|
* </ul>
|
|
497
496
|
* </Service.StaffMembers>
|
|
498
497
|
* ```
|
|
499
498
|
*/
|
|
500
|
-
|
|
499
|
+
const StaffMembersBase = React.forwardRef((props, ref) => {
|
|
501
500
|
const { asChild, children, className, ...attributes } = props;
|
|
502
501
|
return (_jsx(CoreService.Info, { children: ({ staff }) => {
|
|
503
502
|
// Container level: don't render if no staff members
|
|
504
503
|
if (!staff || staff.length === 0) {
|
|
505
504
|
return null;
|
|
506
505
|
}
|
|
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 }) }) }));
|
|
506
|
+
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
507
|
} }));
|
|
514
508
|
});
|
|
515
509
|
StaffMembersBase.displayName = 'Service.StaffMembers';
|
|
516
510
|
/**
|
|
517
511
|
* List container for staff members with empty state support (List Container Level).
|
|
518
512
|
* Renders emptyState when no staff members, otherwise renders children.
|
|
513
|
+
* Internally delegates to StaffMemberList.StaffMembers.
|
|
519
514
|
*
|
|
520
515
|
* @component
|
|
521
516
|
* @example
|
|
@@ -527,42 +522,33 @@ StaffMembersBase.displayName = 'Service.StaffMembers';
|
|
|
527
522
|
*/
|
|
528
523
|
export const StaffMembersList = React.forwardRef((props, ref) => {
|
|
529
524
|
const { children, emptyState, className, ...otherProps } = props;
|
|
530
|
-
return (_jsx(
|
|
525
|
+
return (_jsx(StaffMemberListModule.StaffMembers, { ref: ref, emptyState: emptyState, className: className, ...otherProps, children: children }));
|
|
531
526
|
});
|
|
532
527
|
StaffMembersList.displayName = 'Service.StaffMembers.List';
|
|
533
528
|
/**
|
|
534
|
-
* Repeater component that renders
|
|
535
|
-
*
|
|
529
|
+
* Repeater component that renders StaffMember.Root for each staff member.
|
|
530
|
+
* Internally delegates to StaffMemberList.StaffMemberRepeater.
|
|
531
|
+
* Children are rendered inside each StaffMember.Root context.
|
|
536
532
|
*
|
|
537
533
|
* @component
|
|
538
534
|
* @example
|
|
539
535
|
* ```tsx
|
|
540
|
-
* // Standard usage - renders staff member
|
|
536
|
+
* // Standard usage - renders StaffMember.Root for each staff member
|
|
541
537
|
* <Service.StaffMembers.StaffMemberRepeater>
|
|
542
|
-
* <
|
|
538
|
+
* <StaffMember.Name />
|
|
543
539
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
544
540
|
*
|
|
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
|
-
* )}
|
|
541
|
+
* // With custom styling
|
|
542
|
+
* <Service.StaffMembers.StaffMemberRepeater>
|
|
543
|
+
* <div className="staff-card">
|
|
544
|
+
* <StaffMember.Name className="font-bold" />
|
|
545
|
+
* </div>
|
|
556
546
|
* </Service.StaffMembers.StaffMemberRepeater>
|
|
557
547
|
* ```
|
|
558
548
|
*/
|
|
559
549
|
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 }));
|
|
550
|
+
const { children } = props;
|
|
551
|
+
return (_jsx(StaffMemberListModule.StaffMemberRepeater, { ref: ref, children: children }));
|
|
566
552
|
});
|
|
567
553
|
StaffMemberRepeater.displayName = 'Service.StaffMembers.StaffMemberRepeater';
|
|
568
554
|
/**
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StaffMemberList - High-level component for displaying staff member lists
|
|
3
|
+
* Follows the pattern from LocationList.tsx
|
|
4
|
+
*
|
|
5
|
+
* @module React/StaffMemberList
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { GenericListRepeaterProps, type ListVariant } from '@wix/headless-components/react';
|
|
9
|
+
import { type AsChildChildren } from '@wix/headless-utils/react';
|
|
10
|
+
import type { StaffMemberListServiceConfig } from '../../services/staff-member-list/staff-member-list.js';
|
|
11
|
+
import type { StaffMemberData } from '../../services/staff-member-list/staff-member-list.def.js';
|
|
12
|
+
/**
|
|
13
|
+
* Staff member with id for list rendering
|
|
14
|
+
* Uses staffMemberId as the id (which equals resource id)
|
|
15
|
+
*/
|
|
16
|
+
interface StaffMemberWithId extends StaffMemberData {
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Props for the StaffMemberList root component
|
|
21
|
+
*/
|
|
22
|
+
export interface RootProps {
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
staffMemberListConfig?: StaffMemberListServiceConfig;
|
|
25
|
+
className?: string;
|
|
26
|
+
variant?: ListVariant;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Root component that provides the StaffMemberList service context for rendering staff member lists.
|
|
30
|
+
*
|
|
31
|
+
* @component
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* import { StaffMemberList, StaffMember } from '@wix/bookings/react';
|
|
35
|
+
*
|
|
36
|
+
* function StaffMembersPage({ staffMemberListConfig }) {
|
|
37
|
+
* return (
|
|
38
|
+
* <StaffMemberList.Root staffMemberListConfig={staffMemberListConfig}>
|
|
39
|
+
* <StaffMemberList.StaffMembers emptyState={<div>No staff members available</div>}>
|
|
40
|
+
* <StaffMemberList.StaffMemberRepeater>
|
|
41
|
+
* <StaffMember.Name />
|
|
42
|
+
* </StaffMemberList.StaffMemberRepeater>
|
|
43
|
+
* </StaffMemberList.StaffMembers>
|
|
44
|
+
* </StaffMemberList.Root>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLElement>>;
|
|
50
|
+
/**
|
|
51
|
+
* Props for StaffMemberList.StaffMembers component
|
|
52
|
+
*/
|
|
53
|
+
export interface StaffMembersProps {
|
|
54
|
+
children: React.ReactNode;
|
|
55
|
+
emptyState?: React.ReactNode;
|
|
56
|
+
className?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Container for the staff members list with empty state support.
|
|
60
|
+
* Wraps GenericList.Items internally (no separate Items export).
|
|
61
|
+
*
|
|
62
|
+
* @component
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* <StaffMemberList.StaffMembers emptyState={<div>No staff members available</div>}>
|
|
66
|
+
* <StaffMemberList.StaffMemberRepeater>
|
|
67
|
+
* <StaffMember.Name />
|
|
68
|
+
* </StaffMemberList.StaffMemberRepeater>
|
|
69
|
+
* </StaffMemberList.StaffMembers>
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const StaffMembers: React.ForwardRefExoticComponent<StaffMembersProps & React.RefAttributes<HTMLElement>>;
|
|
73
|
+
/**
|
|
74
|
+
* Props for StaffMemberList.StaffMemberRepeater component
|
|
75
|
+
*/
|
|
76
|
+
export type StaffMemberRepeaterProps = GenericListRepeaterProps<StaffMemberWithId>;
|
|
77
|
+
export declare const StaffMemberRepeater: React.ForwardRefExoticComponent<StaffMemberRepeaterProps & React.RefAttributes<HTMLElement>>;
|
|
78
|
+
/**
|
|
79
|
+
* Props for StaffMemberList.Totals component
|
|
80
|
+
*/
|
|
81
|
+
export interface TotalsProps {
|
|
82
|
+
asChild?: boolean;
|
|
83
|
+
children?: React.ReactNode | AsChildChildren<{
|
|
84
|
+
count: number;
|
|
85
|
+
hasStaffMembers: boolean;
|
|
86
|
+
}>;
|
|
87
|
+
className?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Displays the total count of staff members.
|
|
91
|
+
*
|
|
92
|
+
* @component
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <StaffMemberList.Totals />
|
|
96
|
+
*
|
|
97
|
+
* // With asChild
|
|
98
|
+
* <StaffMemberList.Totals asChild>
|
|
99
|
+
* {({ count }) => <span>{count} staff members available</span>}
|
|
100
|
+
* </StaffMemberList.Totals>
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare const Totals: React.ForwardRefExoticComponent<TotalsProps & React.RefAttributes<HTMLElement>>;
|
|
104
|
+
/**
|
|
105
|
+
* Props for StaffMemberList.Actions.Clear component
|
|
106
|
+
*/
|
|
107
|
+
export interface ClearProps {
|
|
108
|
+
asChild?: boolean;
|
|
109
|
+
children?: React.ReactNode | ((props: {
|
|
110
|
+
onClick: () => void;
|
|
111
|
+
}) => React.ReactNode);
|
|
112
|
+
className?: string;
|
|
113
|
+
label?: string;
|
|
114
|
+
/** Callback fired when the clear button is clicked */
|
|
115
|
+
onClicked?: () => void;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Actions namespace for staff member list-level actions
|
|
119
|
+
*/
|
|
120
|
+
export declare const Actions: {
|
|
121
|
+
Clear: React.ForwardRefExoticComponent<ClearProps & React.RefAttributes<HTMLButtonElement>>;
|
|
122
|
+
};
|
|
123
|
+
export {};
|