@wix/headless-bookings 0.0.92 → 0.0.94
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__/services.d.ts +0 -4
- package/cjs/dist/__mocks__/services.js +1 -4
- package/cjs/dist/api/fetch-availability/index.js +3 -3
- package/cjs/dist/api/query-services/index.js +1 -4
- package/cjs/dist/react/booking/Book.d.ts +4 -1
- package/cjs/dist/react/booking/Book.js +12 -10
- package/cjs/dist/react/booking/Booking.d.ts +10 -0
- package/cjs/dist/react/booking/Booking.js +10 -11
- package/cjs/dist/react/booking/BookingItem.d.ts +6 -2
- package/cjs/dist/react/booking/BookingItem.js +7 -8
- package/cjs/dist/react/booking-form/BookingForm.d.ts +5 -0
- package/cjs/dist/react/booking-form/BookingForm.js +8 -9
- package/cjs/dist/react/core/staff-member/StaffMember.js +1 -2
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.d.ts +2 -0
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +11 -0
- package/cjs/dist/react/location/Location.d.ts +12 -4
- package/cjs/dist/react/location/Location.js +24 -25
- package/cjs/dist/react/location/LocationList.d.ts +8 -2
- package/cjs/dist/react/location/LocationList.js +12 -12
- package/cjs/dist/react/payment/Payment.d.ts +22 -16
- package/cjs/dist/react/payment/Payment.js +28 -29
- package/cjs/dist/react/service/Service.d.ts +41 -16
- package/cjs/dist/react/service/Service.js +62 -63
- package/cjs/dist/react/service/ServiceMedia.d.ts +4 -0
- package/cjs/dist/react/service/ServiceMedia.js +4 -5
- package/cjs/dist/react/service-list/ServiceList.d.ts +7 -0
- package/cjs/dist/react/service-list/ServiceList.js +7 -8
- package/cjs/dist/react/staff-member/StaffMember.d.ts +7 -8
- package/cjs/dist/react/staff-member/StaffMember.js +11 -12
- package/cjs/dist/react/staff-member/StaffMemberList.d.ts +9 -8
- package/cjs/dist/react/staff-member/StaffMemberList.js +14 -24
- package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +16 -20
- package/cjs/dist/react/time-slot-list/TimeSlot.js +31 -32
- package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +10 -12
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +18 -18
- package/cjs/dist/services/booking/book-action/buildBookingRequest.js +1 -2
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +2 -2
- package/cjs/dist/services/constants.d.ts +9 -0
- package/cjs/dist/services/constants.js +9 -0
- package/cjs/dist/services/payment/payment.js +2 -5
- package/cjs/dist/services/service/service.js +1 -1
- package/cjs/dist/services/service-list/service-list.js +1 -4
- package/dist/__mocks__/services.d.ts +0 -4
- package/dist/__mocks__/services.js +1 -4
- package/dist/api/fetch-availability/index.js +3 -3
- package/dist/api/query-services/index.js +1 -4
- package/dist/react/booking/Book.d.ts +4 -1
- package/dist/react/booking/Book.js +12 -10
- package/dist/react/booking/Booking.d.ts +10 -0
- package/dist/react/booking/Booking.js +10 -11
- package/dist/react/booking/BookingItem.d.ts +6 -2
- package/dist/react/booking/BookingItem.js +7 -8
- package/dist/react/booking-form/BookingForm.d.ts +5 -0
- package/dist/react/booking-form/BookingForm.js +8 -9
- package/dist/react/core/staff-member/StaffMember.js +1 -2
- package/dist/react/core/staff-member-list/StaffMemberList.d.ts +2 -0
- package/dist/react/core/staff-member-list/StaffMemberList.js +11 -0
- package/dist/react/location/Location.d.ts +12 -4
- package/dist/react/location/Location.js +24 -25
- package/dist/react/location/LocationList.d.ts +8 -2
- package/dist/react/location/LocationList.js +12 -12
- package/dist/react/payment/Payment.d.ts +22 -16
- package/dist/react/payment/Payment.js +28 -29
- package/dist/react/service/Service.d.ts +41 -16
- package/dist/react/service/Service.js +62 -63
- package/dist/react/service/ServiceMedia.d.ts +4 -0
- package/dist/react/service/ServiceMedia.js +4 -5
- package/dist/react/service-list/ServiceList.d.ts +7 -0
- package/dist/react/service-list/ServiceList.js +7 -8
- package/dist/react/staff-member/StaffMember.d.ts +7 -8
- package/dist/react/staff-member/StaffMember.js +11 -12
- package/dist/react/staff-member/StaffMemberList.d.ts +9 -8
- package/dist/react/staff-member/StaffMemberList.js +14 -24
- package/dist/react/time-slot-list/TimeSlot.d.ts +16 -20
- package/dist/react/time-slot-list/TimeSlot.js +31 -32
- package/dist/react/time-slot-list/TimeSlotList.d.ts +10 -12
- package/dist/react/time-slot-list/TimeSlotList.js +18 -18
- package/dist/services/booking/book-action/buildBookingRequest.js +1 -2
- package/dist/services/booking/book-action/buildCheckoutRequest.js +2 -2
- package/dist/services/constants.d.ts +9 -0
- package/dist/services/constants.js +9 -0
- package/dist/services/payment/payment.js +2 -5
- package/dist/services/service/service.js +1 -1
- package/dist/services/service-list/service-list.js +1 -4
- package/package.json +2 -2
|
@@ -7,10 +7,6 @@ import type { ServiceListServiceConfig } from '../services/service-list/service-
|
|
|
7
7
|
import type { StaffMemberListServiceConfig } from '../services/staff-member-list/staff-member-list.js';
|
|
8
8
|
import type { PagingMetadata } from '../api/query-services/index.js';
|
|
9
9
|
import type { Category } from '../api/query-categories/index.js';
|
|
10
|
-
/**
|
|
11
|
-
* Booking app ID constant
|
|
12
|
-
*/
|
|
13
|
-
export declare const BOOKING_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
|
|
14
10
|
/**
|
|
15
11
|
* Base mock service with all fields populated (APPOINTMENT type, FIXED pricing)
|
|
16
12
|
*/
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* Shared mock data for booking service tests
|
|
3
3
|
*/
|
|
4
4
|
import { RateType, ServiceType } from '@wix/auto_sdk_bookings_services';
|
|
5
|
-
|
|
6
|
-
* Booking app ID constant
|
|
7
|
-
*/
|
|
8
|
-
export const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
5
|
+
import { BOOKING_APP_ID } from '../services/constants.js';
|
|
9
6
|
/**
|
|
10
7
|
* Base mock service with all fields populated (APPOINTMENT type, FIXED pricing)
|
|
11
8
|
*/
|
|
@@ -7,6 +7,7 @@ import { listEventTimeSlots } from '@wix/auto_sdk_bookings_event-time-slots';
|
|
|
7
7
|
import { ServiceType } from '@wix/auto_sdk_bookings_services';
|
|
8
8
|
import { format } from 'date-fns';
|
|
9
9
|
import { ViewMode, } from '../../services/time-slot-list/time-slot-list.def.js';
|
|
10
|
+
import { STAFF_MEMBER_RESOURCE_TYPE_ID } from '../../services/constants.js';
|
|
10
11
|
// ============================================================================
|
|
11
12
|
// Internal Types
|
|
12
13
|
// ============================================================================
|
|
@@ -16,7 +17,6 @@ var FlowType;
|
|
|
16
17
|
FlowType["MULTI_SERVICE"] = "multi_service";
|
|
17
18
|
FlowType["CLASS"] = "class";
|
|
18
19
|
})(FlowType || (FlowType = {}));
|
|
19
|
-
const STAFF_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
|
|
20
20
|
// ============================================================================
|
|
21
21
|
// Helpers
|
|
22
22
|
// ============================================================================
|
|
@@ -87,14 +87,14 @@ export async function fetchAvailability({ services: selectedServices, viewMode =
|
|
|
87
87
|
const resourceTypes = staffMemberIds?.length
|
|
88
88
|
? [
|
|
89
89
|
{
|
|
90
|
-
resourceTypeId:
|
|
90
|
+
resourceTypeId: STAFF_MEMBER_RESOURCE_TYPE_ID,
|
|
91
91
|
resourceIds: staffMemberIds,
|
|
92
92
|
},
|
|
93
93
|
]
|
|
94
94
|
: undefined;
|
|
95
95
|
const includeResourceTypeIds = isFetchAvailabileDays
|
|
96
96
|
? undefined
|
|
97
|
-
: [
|
|
97
|
+
: [STAFF_MEMBER_RESOURCE_TYPE_ID];
|
|
98
98
|
const locations = location
|
|
99
99
|
? [{ _id: location.id, locationType: location.locationType }]
|
|
100
100
|
: undefined;
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
* Fetches single or multiple services with pagination and sorting
|
|
4
4
|
*/
|
|
5
5
|
import { queryServices as queryServicesApi, LocationType, } from '@wix/auto_sdk_bookings_services';
|
|
6
|
-
|
|
7
|
-
* Booking app ID constant
|
|
8
|
-
*/
|
|
9
|
-
const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
|
|
6
|
+
import { BOOKING_APP_ID } from '../../services/constants.js';
|
|
10
7
|
/**
|
|
11
8
|
* Synthetic location ID constants for non-business locations
|
|
12
9
|
*/
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import type { BookChildProps, BookingError } from '../../services/booking/book-action/types.js';
|
|
7
|
+
export declare const TestIds: {
|
|
8
|
+
readonly bookingActionBook: "booking-action-book";
|
|
9
|
+
};
|
|
7
10
|
/**
|
|
8
11
|
* Props for the high-level Book component
|
|
9
12
|
*/
|
|
@@ -11,7 +14,7 @@ export interface BookProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonEle
|
|
|
11
14
|
asChild?: boolean;
|
|
12
15
|
children?: React.ReactNode | ((props: BookChildProps) => React.ReactNode);
|
|
13
16
|
label?: string;
|
|
14
|
-
loadingState?:
|
|
17
|
+
loadingState?: React.ReactNode;
|
|
15
18
|
disabled?: boolean;
|
|
16
19
|
/**
|
|
17
20
|
* Called when checkout is required for payment.
|
|
@@ -7,10 +7,9 @@ import React from 'react';
|
|
|
7
7
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
8
8
|
import * as CoreBook from '../core/booking/Book.js';
|
|
9
9
|
import { navigateToCheckout as navigateToCheckoutUtil } from '../../utils/navigation.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})(TestIds || (TestIds = {}));
|
|
10
|
+
export const TestIds = {
|
|
11
|
+
bookingActionBook: 'booking-action-book',
|
|
12
|
+
};
|
|
14
13
|
/**
|
|
15
14
|
* Book action button component with AsChildSlot pattern.
|
|
16
15
|
*
|
|
@@ -57,7 +56,7 @@ var TestIds;
|
|
|
57
56
|
* ```
|
|
58
57
|
*/
|
|
59
58
|
export const Book = React.forwardRef((props, ref) => {
|
|
60
|
-
const { asChild, children,
|
|
59
|
+
const { asChild, children, label, loadingState, disabled, onCheckout, onComplete, onError, onClick, ...rest } = props;
|
|
61
60
|
return (_jsx(CoreBook.Book, { onCheckout: (result) => {
|
|
62
61
|
// Create navigateToCheckout with checkoutId captured
|
|
63
62
|
const navigateToCheckout = (options) => navigateToCheckoutUtil({
|
|
@@ -68,12 +67,15 @@ export const Book = React.forwardRef((props, ref) => {
|
|
|
68
67
|
return onCheckout?.(navigateToCheckout);
|
|
69
68
|
}, onComplete: (result) => {
|
|
70
69
|
return onComplete?.({ orderId: result.orderId });
|
|
71
|
-
}, onError: onError, disabled: disabled, children: (
|
|
72
|
-
const handleClick = () => {
|
|
73
|
-
|
|
74
|
-
onClick?.(
|
|
70
|
+
}, onError: onError, disabled: disabled, children: (coreBookProps) => {
|
|
71
|
+
const handleClick = async () => {
|
|
72
|
+
await coreBookProps.onClick();
|
|
73
|
+
onClick?.(coreBookProps);
|
|
75
74
|
};
|
|
76
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
75
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, disabled: coreBookProps.disabled, "data-testid": TestIds.bookingActionBook, "data-in-progress": coreBookProps.isLoading, "data-can-book": coreBookProps.canBook, customElement: children, customElementProps: {
|
|
76
|
+
...coreBookProps,
|
|
77
|
+
onClick: handleClick,
|
|
78
|
+
}, children: _jsx("button", { onClick: handleClick, children: coreBookProps.isLoading
|
|
77
79
|
? loadingState
|
|
78
80
|
: children || label }) }));
|
|
79
81
|
} }));
|
|
@@ -6,6 +6,16 @@ import React from 'react';
|
|
|
6
6
|
import * as CoreBooking from '../core/booking/Booking.js';
|
|
7
7
|
import type { BookingServiceConfig } from '../../services/booking/booking.js';
|
|
8
8
|
export type { BookingData, DataProps, BookingItem, } from '../core/booking/Booking.js';
|
|
9
|
+
export declare const TestIds: {
|
|
10
|
+
readonly bookingItemsRoot: "booking-items-root";
|
|
11
|
+
readonly bookingItems: "booking-items";
|
|
12
|
+
readonly bookingItem: "booking-item";
|
|
13
|
+
readonly bookingItemService: "booking-item-service";
|
|
14
|
+
readonly bookingItemTimeSlot: "booking-item-time-slot";
|
|
15
|
+
readonly bookingItemPayment: "booking-item-payment";
|
|
16
|
+
readonly bookingLocation: "booking-location";
|
|
17
|
+
readonly bookingStaffName: "booking-staff-name";
|
|
18
|
+
};
|
|
9
19
|
/**
|
|
10
20
|
* Props for Booking.Root component
|
|
11
21
|
*/
|
|
@@ -12,17 +12,16 @@ import { GenericList } from '@wix/headless-components/react';
|
|
|
12
12
|
// ============================================================================
|
|
13
13
|
// TestIds
|
|
14
14
|
// ============================================================================
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})(TestIds || (TestIds = {}));
|
|
15
|
+
export const TestIds = {
|
|
16
|
+
bookingItemsRoot: 'booking-items-root',
|
|
17
|
+
bookingItems: 'booking-items',
|
|
18
|
+
bookingItem: 'booking-item',
|
|
19
|
+
bookingItemService: 'booking-item-service',
|
|
20
|
+
bookingItemTimeSlot: 'booking-item-time-slot',
|
|
21
|
+
bookingItemPayment: 'booking-item-payment',
|
|
22
|
+
bookingLocation: 'booking-location',
|
|
23
|
+
bookingStaffName: 'booking-staff-name',
|
|
24
|
+
};
|
|
26
25
|
/**
|
|
27
26
|
* Root component that provides booking context to the entire app.
|
|
28
27
|
*
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { type AsChildChildren } from '@wix/headless-utils/react';
|
|
7
|
+
export declare const TestIds: {
|
|
8
|
+
readonly bookingItemService: "booking-item-service";
|
|
9
|
+
readonly bookingItemTimeSlot: "booking-item-time-slot";
|
|
10
|
+
readonly bookingItemStaffName: "booking-item-staff-name";
|
|
11
|
+
};
|
|
7
12
|
export interface ServiceProps {
|
|
8
13
|
children: React.ReactNode;
|
|
9
14
|
}
|
|
@@ -44,12 +49,11 @@ export declare function TimeSlot(props: TimeSlotProps): React.ReactNode;
|
|
|
44
49
|
export declare namespace TimeSlot {
|
|
45
50
|
var displayName: string;
|
|
46
51
|
}
|
|
47
|
-
export interface StaffNameProps {
|
|
52
|
+
export interface StaffNameProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
48
53
|
asChild?: boolean;
|
|
49
54
|
children?: AsChildChildren<{
|
|
50
55
|
name: string;
|
|
51
56
|
}>;
|
|
52
|
-
className?: string;
|
|
53
57
|
}
|
|
54
58
|
/**
|
|
55
59
|
* Displays the staff member's name from the current booking item.
|
|
@@ -8,12 +8,11 @@ import * as CoreBooking from '../core/booking/Booking.js';
|
|
|
8
8
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
9
9
|
import * as ServiceComponent from '../service/Service.js';
|
|
10
10
|
import * as TimeSlotComponent from '../time-slot-list/TimeSlot.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})(TestIds || (TestIds = {}));
|
|
11
|
+
export const TestIds = {
|
|
12
|
+
bookingItemService: 'booking-item-service',
|
|
13
|
+
bookingItemTimeSlot: 'booking-item-time-slot',
|
|
14
|
+
bookingItemStaffName: 'booking-item-staff-name',
|
|
15
|
+
};
|
|
17
16
|
/**
|
|
18
17
|
* Wraps Service.Root with the service from the current booking item context.
|
|
19
18
|
* Must be used within Booking.BookingItemRepeater.
|
|
@@ -61,11 +60,11 @@ TimeSlot.displayName = 'BookingItem.TimeSlot';
|
|
|
61
60
|
* ```
|
|
62
61
|
*/
|
|
63
62
|
export const StaffName = React.forwardRef((props, ref) => {
|
|
64
|
-
const { asChild, children,
|
|
63
|
+
const { asChild, children, ...rest } = props;
|
|
65
64
|
return (_jsx(CoreBooking.BookingItemInfo, { children: ({ staffName }) => {
|
|
66
65
|
if (!staffName)
|
|
67
66
|
return null;
|
|
68
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
67
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.bookingItemStaffName, customElement: children, customElementProps: { name: staffName }, children: _jsx("span", { children: staffName }) }));
|
|
69
68
|
} }));
|
|
70
69
|
});
|
|
71
70
|
StaffName.displayName = 'BookingItem.StaffName';
|
|
@@ -6,6 +6,11 @@ import React from 'react';
|
|
|
6
6
|
import { Form } from '@wix/headless-forms/react';
|
|
7
7
|
import * as CoreBookingForm from '../core/booking-form/BookingForm.js';
|
|
8
8
|
type FieldMap = Parameters<typeof Form.Fields>[0]['fieldMap'];
|
|
9
|
+
export declare const TestIds: {
|
|
10
|
+
readonly bookingFormRoot: "booking-form-root";
|
|
11
|
+
readonly bookingFormFields: "booking-form-fields";
|
|
12
|
+
readonly bookingFormActionValidateFormSubmission: "booking-form-action-validate-form-submission";
|
|
13
|
+
};
|
|
9
14
|
/**
|
|
10
15
|
* Props for BookingForm.Root component
|
|
11
16
|
*/
|
|
@@ -40,12 +40,11 @@ class BookingFormErrorBoundary extends React.Component {
|
|
|
40
40
|
return children;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})(TestIds || (TestIds = {}));
|
|
43
|
+
export const TestIds = {
|
|
44
|
+
bookingFormRoot: 'booking-form-root',
|
|
45
|
+
bookingFormFields: 'booking-form-fields',
|
|
46
|
+
bookingFormActionValidateFormSubmission: 'booking-form-action-validate-form-submission',
|
|
47
|
+
};
|
|
49
48
|
/**
|
|
50
49
|
* Root component for booking form that wraps CoreBookingForm.Root.
|
|
51
50
|
* Automatically loads form and handles submission in standalone mode.
|
|
@@ -171,7 +170,7 @@ Fields.displayName = 'BookingForm.Fields';
|
|
|
171
170
|
* ```
|
|
172
171
|
*/
|
|
173
172
|
export const ValidateFormSubmission = React.forwardRef((props, ref) => {
|
|
174
|
-
const { asChild, children,
|
|
173
|
+
const { asChild, children, label, onValidationComplete, onClick, ...rest } = props;
|
|
175
174
|
const [valid, setValid] = React.useState(null);
|
|
176
175
|
const [validationFailures, setValidationFailures] = React.useState([]);
|
|
177
176
|
return (_jsx(CoreBookingForm.Actions, { children: ({ validateFormSubmission }) => {
|
|
@@ -184,11 +183,11 @@ export const ValidateFormSubmission = React.forwardRef((props, ref) => {
|
|
|
184
183
|
}
|
|
185
184
|
onClick?.(result);
|
|
186
185
|
};
|
|
187
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
186
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.bookingFormActionValidateFormSubmission, "data-valid": valid, customElement: children, customElementProps: {
|
|
188
187
|
onClick: handleClick,
|
|
189
188
|
valid,
|
|
190
189
|
validationFailures,
|
|
191
|
-
}, children: _jsx("button", {
|
|
190
|
+
}, children: _jsx("button", { onClick: handleClick, children: children || label }) }));
|
|
192
191
|
} }));
|
|
193
192
|
});
|
|
194
193
|
ValidateFormSubmission.displayName =
|
|
@@ -8,8 +8,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
8
8
|
import { createContext, useContext } from 'react';
|
|
9
9
|
import { useService } from '@wix/services-manager-react';
|
|
10
10
|
import { BookingServiceDefinition } from '../../../services/booking/booking.js';
|
|
11
|
-
|
|
12
|
-
const STAFF_MEMBER_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
|
|
11
|
+
import { STAFF_MEMBER_RESOURCE_TYPE_ID } from '../../../services/constants.js';
|
|
13
12
|
// ==========================================
|
|
14
13
|
// Context
|
|
15
14
|
// ==========================================
|
|
@@ -71,6 +71,8 @@ export interface ActionsRenderProps {
|
|
|
71
71
|
select: (staffMember: StaffMemberData) => void;
|
|
72
72
|
/** Currently selected staff member */
|
|
73
73
|
selectedStaffMember: StaffMemberData | null;
|
|
74
|
+
/** Clear the staff member resource from BookingService */
|
|
75
|
+
clear: () => void;
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
76
78
|
* Props for Actions render prop component
|
|
@@ -2,6 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { WixServices, useService } from '@wix/services-manager-react';
|
|
3
3
|
import { createServicesMap } from '@wix/services-manager';
|
|
4
4
|
import { StaffMemberListServiceDefinition, StaffMemberListService, } from '../../../services/staff-member-list/staff-member-list.js';
|
|
5
|
+
import { BookingServiceDefinition } from '../../../services/booking/booking.js';
|
|
6
|
+
import { STAFF_MEMBER_RESOURCE_TYPE_ID } from '../../../services/constants.js';
|
|
5
7
|
/**
|
|
6
8
|
* Root component that provides StaffMemberList service context
|
|
7
9
|
*
|
|
@@ -59,8 +61,17 @@ export function StaffMembers(props) {
|
|
|
59
61
|
*/
|
|
60
62
|
export function Actions(props) {
|
|
61
63
|
const service = useService(StaffMemberListServiceDefinition);
|
|
64
|
+
let bookingService = null;
|
|
65
|
+
try {
|
|
66
|
+
bookingService = useService(BookingServiceDefinition);
|
|
67
|
+
}
|
|
68
|
+
catch { }
|
|
69
|
+
const clear = () => {
|
|
70
|
+
bookingService?.actions.clearResourceByType(STAFF_MEMBER_RESOURCE_TYPE_ID);
|
|
71
|
+
};
|
|
62
72
|
return props.children({
|
|
63
73
|
select: service.actions.select,
|
|
64
74
|
selectedStaffMember: service.selectedStaffMember.get(),
|
|
75
|
+
clear,
|
|
65
76
|
});
|
|
66
77
|
}
|
|
@@ -9,6 +9,16 @@ import * as CoreLocation from '../core/location/Location.js';
|
|
|
9
9
|
import { type AsChildChildren } from '@wix/headless-utils/react';
|
|
10
10
|
import { LocationType } from '../../services/location-list/location-list.def.js';
|
|
11
11
|
export { useLocationContext } from '../core/location/Location.js';
|
|
12
|
+
export declare const TestIds: {
|
|
13
|
+
readonly locationRoot: "location-root";
|
|
14
|
+
readonly locationName: "location-name";
|
|
15
|
+
readonly locationType: "location-type";
|
|
16
|
+
readonly locationAddress: "location-address";
|
|
17
|
+
readonly locationPhone: "location-phone";
|
|
18
|
+
readonly locationEmail: "location-email";
|
|
19
|
+
readonly locationRaw: "location-raw";
|
|
20
|
+
readonly locationActionSelect: "location-action-select";
|
|
21
|
+
};
|
|
12
22
|
export type { AddressData, Location, LocationRenderProps, } from '../core/location/Location.js';
|
|
13
23
|
/**
|
|
14
24
|
* Props for Location.Root component
|
|
@@ -58,12 +68,11 @@ export declare const Root: React.ForwardRefExoticComponent<RootProps & React.Ref
|
|
|
58
68
|
/**
|
|
59
69
|
* Props for Location.Name component
|
|
60
70
|
*/
|
|
61
|
-
export interface NameProps {
|
|
71
|
+
export interface NameProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
62
72
|
asChild?: boolean;
|
|
63
73
|
children?: React.ReactNode | AsChildChildren<{
|
|
64
74
|
name: string;
|
|
65
75
|
}>;
|
|
66
|
-
className?: string;
|
|
67
76
|
}
|
|
68
77
|
/**
|
|
69
78
|
* Displays the location name.
|
|
@@ -90,14 +99,13 @@ export declare const Name: React.ForwardRefExoticComponent<NameProps & React.Ref
|
|
|
90
99
|
/**
|
|
91
100
|
* Props for Location.Type component
|
|
92
101
|
*/
|
|
93
|
-
export interface TypeProps {
|
|
102
|
+
export interface TypeProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
94
103
|
asChild?: boolean;
|
|
95
104
|
children?: React.ReactNode | AsChildChildren<{
|
|
96
105
|
locationType: LocationType;
|
|
97
106
|
isCustomerLocation: boolean;
|
|
98
107
|
isCustomLocation: boolean;
|
|
99
108
|
}>;
|
|
100
|
-
className?: string;
|
|
101
109
|
}
|
|
102
110
|
/**
|
|
103
111
|
* Displays the location type.
|
|
@@ -14,17 +14,16 @@ export { useLocationContext } from '../core/location/Location.js';
|
|
|
14
14
|
// ==========================================
|
|
15
15
|
// TestIds Enum
|
|
16
16
|
// ==========================================
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})(TestIds || (TestIds = {}));
|
|
17
|
+
export const TestIds = {
|
|
18
|
+
locationRoot: 'location-root',
|
|
19
|
+
locationName: 'location-name',
|
|
20
|
+
locationType: 'location-type',
|
|
21
|
+
locationAddress: 'location-address',
|
|
22
|
+
locationPhone: 'location-phone',
|
|
23
|
+
locationEmail: 'location-email',
|
|
24
|
+
locationRaw: 'location-raw',
|
|
25
|
+
locationActionSelect: 'location-action-select',
|
|
26
|
+
};
|
|
28
27
|
// ==========================================
|
|
29
28
|
// Type Definitions
|
|
30
29
|
// ==========================================
|
|
@@ -93,9 +92,9 @@ Root.displayName = 'Location.Root';
|
|
|
93
92
|
* ```
|
|
94
93
|
*/
|
|
95
94
|
export const Name = React.forwardRef((props, ref) => {
|
|
96
|
-
const { asChild, children,
|
|
95
|
+
const { asChild, children, ...rest } = props;
|
|
97
96
|
const { name } = useLocationContext();
|
|
98
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
97
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.locationName, customElement: children, customElementProps: { name: name ?? '' }, children: name ? _jsx("span", { children: name }) : null }));
|
|
99
98
|
});
|
|
100
99
|
Name.displayName = 'Location.Name';
|
|
101
100
|
/**
|
|
@@ -117,13 +116,13 @@ Name.displayName = 'Location.Name';
|
|
|
117
116
|
* ```
|
|
118
117
|
*/
|
|
119
118
|
export const Type = React.forwardRef((props, ref) => {
|
|
120
|
-
const { asChild, children,
|
|
119
|
+
const { asChild, children, ...rest } = props;
|
|
121
120
|
const { locationType, isCustomerLocation, isCustomLocation } = useLocationContext();
|
|
122
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
121
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.locationType, customElement: children, customElementProps: {
|
|
123
122
|
locationType,
|
|
124
123
|
isCustomerLocation,
|
|
125
124
|
isCustomLocation,
|
|
126
|
-
},
|
|
125
|
+
}, children: locationType ? _jsx("span", { children: locationType }) : null }));
|
|
127
126
|
});
|
|
128
127
|
Type.displayName = 'Location.Type';
|
|
129
128
|
/**
|
|
@@ -150,9 +149,9 @@ Type.displayName = 'Location.Type';
|
|
|
150
149
|
* ```
|
|
151
150
|
*/
|
|
152
151
|
export const LocationAddress = React.forwardRef((props, ref) => {
|
|
153
|
-
const { asChild, children,
|
|
152
|
+
const { asChild, children, ...rest } = props;
|
|
154
153
|
const { address } = useLocationContext();
|
|
155
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
154
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.locationAddress, customElement: children, customElementProps: { address }, children: address ? (_jsx("span", { children: _jsx(Address.Root, { address: address, children: _jsx(Address.Formatted, {}) }) })) : null }));
|
|
156
155
|
});
|
|
157
156
|
LocationAddress.displayName = 'Location.Address';
|
|
158
157
|
// Export as Address (avoiding name collision with imported Address)
|
|
@@ -173,9 +172,9 @@ export { LocationAddress as Address };
|
|
|
173
172
|
* ```
|
|
174
173
|
*/
|
|
175
174
|
export const Phone = React.forwardRef((props, ref) => {
|
|
176
|
-
const { asChild, children,
|
|
175
|
+
const { asChild, children, ...rest } = props;
|
|
177
176
|
const { phone } = useLocationContext();
|
|
178
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
177
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.locationPhone, customElement: children, customElementProps: { phone }, children: phone ? _jsx("span", { children: phone }) : null }));
|
|
179
178
|
});
|
|
180
179
|
Phone.displayName = 'Location.Phone';
|
|
181
180
|
/**
|
|
@@ -194,9 +193,9 @@ Phone.displayName = 'Location.Phone';
|
|
|
194
193
|
* ```
|
|
195
194
|
*/
|
|
196
195
|
export const Email = React.forwardRef((props, ref) => {
|
|
197
|
-
const { asChild, children,
|
|
196
|
+
const { asChild, children, ...rest } = props;
|
|
198
197
|
const { email } = useLocationContext();
|
|
199
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
198
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.locationEmail, customElement: children, customElementProps: { email }, children: email ? _jsx("span", { children: email }) : null }));
|
|
200
199
|
});
|
|
201
200
|
Email.displayName = 'Location.Email';
|
|
202
201
|
/**
|
|
@@ -244,7 +243,7 @@ Raw.displayName = 'Location.Raw';
|
|
|
244
243
|
* ```
|
|
245
244
|
*/
|
|
246
245
|
const Select = React.forwardRef((props, ref) => {
|
|
247
|
-
const { asChild, children, onClick, label, className, ...
|
|
246
|
+
const { asChild, children, onClick, label, className, ...rest } = props;
|
|
248
247
|
return (_jsx(CoreLocation.Actions, { children: ({ select, selected, rawLocation }) => {
|
|
249
248
|
const handleClick = () => {
|
|
250
249
|
select();
|
|
@@ -252,11 +251,11 @@ const Select = React.forwardRef((props, ref) => {
|
|
|
252
251
|
onClick?.(rawLocation);
|
|
253
252
|
}
|
|
254
253
|
};
|
|
255
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationActionSelect, "data-selected": selected, customElement: children, customElementProps: {
|
|
254
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": TestIds.locationActionSelect, "data-selected": selected, customElement: children, customElementProps: {
|
|
256
255
|
onClick: handleClick,
|
|
257
256
|
selected,
|
|
258
257
|
location: rawLocation,
|
|
259
|
-
}, children: _jsx("button", {
|
|
258
|
+
}, children: _jsx("button", { onClick: handleClick, children: children || label }) }));
|
|
260
259
|
} }));
|
|
261
260
|
});
|
|
262
261
|
Select.displayName = 'Location.Actions.Select';
|
|
@@ -9,6 +9,13 @@ import { GenericListRepeaterProps, type ListVariant } from '@wix/headless-compon
|
|
|
9
9
|
import { type AsChildChildren } from '@wix/headless-utils/react';
|
|
10
10
|
import type { LocationListServiceConfig } from '../../services/location-list/location-list.js';
|
|
11
11
|
import { type Location } from '../../services/location-list/location-list.def.js';
|
|
12
|
+
export declare const TestIds: {
|
|
13
|
+
readonly locationListRoot: "location-list-root";
|
|
14
|
+
readonly locationListLocations: "location-list-locations";
|
|
15
|
+
readonly locationListLocation: "location-list-location";
|
|
16
|
+
readonly locationListActionClear: "location-list-action-clear";
|
|
17
|
+
readonly locationListTotals: "location-list-totals";
|
|
18
|
+
};
|
|
12
19
|
/**
|
|
13
20
|
* Props for the LocationList root component
|
|
14
21
|
*/
|
|
@@ -77,13 +84,12 @@ export declare const LocationRepeater: React.ForwardRefExoticComponent<LocationR
|
|
|
77
84
|
/**
|
|
78
85
|
* Props for LocationList.Totals component
|
|
79
86
|
*/
|
|
80
|
-
export interface TotalsProps {
|
|
87
|
+
export interface TotalsProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
81
88
|
asChild?: boolean;
|
|
82
89
|
children?: React.ReactNode | AsChildChildren<{
|
|
83
90
|
count: number;
|
|
84
91
|
hasLocations: boolean;
|
|
85
92
|
}>;
|
|
86
|
-
className?: string;
|
|
87
93
|
}
|
|
88
94
|
/**
|
|
89
95
|
* Displays the total count of locations.
|
|
@@ -37,13 +37,13 @@ function getLocationType(location) {
|
|
|
37
37
|
// ============================================================================
|
|
38
38
|
// TestIds
|
|
39
39
|
// ============================================================================
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
40
|
+
export const TestIds = {
|
|
41
|
+
locationListRoot: 'location-list-root',
|
|
42
|
+
locationListLocations: 'location-list-locations',
|
|
43
|
+
locationListLocation: 'location-list-location',
|
|
44
|
+
locationListActionClear: 'location-list-action-clear',
|
|
45
|
+
locationListTotals: 'location-list-totals',
|
|
46
|
+
};
|
|
47
47
|
/**
|
|
48
48
|
* Root component that provides the LocationList service context for rendering locations lists.
|
|
49
49
|
*
|
|
@@ -133,10 +133,10 @@ LocationRepeater.displayName = 'LocationList.LocationRepeater';
|
|
|
133
133
|
* ```
|
|
134
134
|
*/
|
|
135
135
|
export const Totals = React.forwardRef((props, ref) => {
|
|
136
|
-
const { asChild, children,
|
|
136
|
+
const { asChild, children, ...rest } = props;
|
|
137
137
|
return (_jsx(CoreLocationList.Locations, { children: ({ displayLocations, hasLocations }) => {
|
|
138
138
|
const count = displayLocations.length;
|
|
139
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
139
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.locationListTotals, customElement: children, customElementProps: { count, hasLocations }, children: _jsx("span", { children: count }) }));
|
|
140
140
|
} }));
|
|
141
141
|
});
|
|
142
142
|
Totals.displayName = 'LocationList.Totals';
|
|
@@ -170,7 +170,7 @@ Totals.displayName = 'LocationList.Totals';
|
|
|
170
170
|
* ```
|
|
171
171
|
*/
|
|
172
172
|
const Clear = React.forwardRef((props, ref) => {
|
|
173
|
-
const { asChild, children, className, label, onClick, ...
|
|
173
|
+
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
174
174
|
return (_jsx(CoreLocationList.Actions, { children: ({ selectedLocation }) => {
|
|
175
175
|
let bookingService = null;
|
|
176
176
|
try {
|
|
@@ -183,9 +183,9 @@ const Clear = React.forwardRef((props, ref) => {
|
|
|
183
183
|
bookingService?.actions.clearLocation();
|
|
184
184
|
onClick?.(selectedLocation);
|
|
185
185
|
};
|
|
186
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationListActionClear, customElement: children, customElementProps: {
|
|
186
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": TestIds.locationListActionClear, customElement: children, customElementProps: {
|
|
187
187
|
onClick: handleClick,
|
|
188
|
-
}, children: _jsx("button", {
|
|
188
|
+
}, children: _jsx("button", { onClick: handleClick, children: children || label }) }));
|
|
189
189
|
} }));
|
|
190
190
|
});
|
|
191
191
|
Clear.displayName = 'LocationList.Actions.Clear';
|