@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
|
@@ -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';
|
|
@@ -6,6 +6,20 @@ import React from 'react';
|
|
|
6
6
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
7
7
|
import { MoneyData } from '@wix/headless-components/react';
|
|
8
8
|
import type { PaymentServiceConfig, PricingServiceSelection } from '../../services/payment/payment.js';
|
|
9
|
+
export declare const TestIds: {
|
|
10
|
+
readonly paymentRoot: "payment-root";
|
|
11
|
+
readonly paymentSubtotal: "payment-subtotal";
|
|
12
|
+
readonly paymentTax: "payment-tax";
|
|
13
|
+
readonly paymentTotal: "payment-total";
|
|
14
|
+
readonly paymentPayNow: "payment-pay-now";
|
|
15
|
+
readonly paymentPayLater: "payment-pay-later";
|
|
16
|
+
readonly paymentLineItems: "payment-line-items";
|
|
17
|
+
readonly paymentLineItemsList: "payment-line-items-list";
|
|
18
|
+
readonly paymentLineItemRepeater: "payment-line-item-repeater";
|
|
19
|
+
readonly paymentLineItemTotal: "payment-line-item-total";
|
|
20
|
+
readonly paymentLineItemSubtotal: "payment-line-item-subtotal";
|
|
21
|
+
readonly paymentLineItemDeposit: "payment-line-item-deposit";
|
|
22
|
+
};
|
|
9
23
|
/**
|
|
10
24
|
* Props for Payment.Root component
|
|
11
25
|
*/
|
|
@@ -59,13 +73,12 @@ export declare const Root: React.ForwardRefExoticComponent<RootProps & React.Ref
|
|
|
59
73
|
/**
|
|
60
74
|
* Props for Payment.Subtotal component
|
|
61
75
|
*/
|
|
62
|
-
export interface SubtotalProps {
|
|
76
|
+
export interface SubtotalProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
63
77
|
asChild?: boolean;
|
|
64
78
|
children?: AsChildChildren<{
|
|
65
79
|
subtotal: MoneyData | null;
|
|
66
80
|
customPrice: string | null;
|
|
67
81
|
}>;
|
|
68
|
-
className?: string;
|
|
69
82
|
}
|
|
70
83
|
/**
|
|
71
84
|
* Displays the payment subtotal.
|
|
@@ -91,12 +104,11 @@ export declare const Subtotal: React.ForwardRefExoticComponent<SubtotalProps & R
|
|
|
91
104
|
/**
|
|
92
105
|
* Props for Payment.Tax component
|
|
93
106
|
*/
|
|
94
|
-
export interface TaxProps {
|
|
107
|
+
export interface TaxProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
95
108
|
asChild?: boolean;
|
|
96
109
|
children?: AsChildChildren<{
|
|
97
110
|
tax: MoneyData | null;
|
|
98
111
|
}>;
|
|
99
|
-
className?: string;
|
|
100
112
|
}
|
|
101
113
|
/**
|
|
102
114
|
* Displays the payment tax.
|
|
@@ -112,13 +124,12 @@ export declare const Tax: React.ForwardRefExoticComponent<TaxProps & React.RefAt
|
|
|
112
124
|
/**
|
|
113
125
|
* Props for Payment.Total component
|
|
114
126
|
*/
|
|
115
|
-
export interface TotalProps {
|
|
127
|
+
export interface TotalProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
116
128
|
asChild?: boolean;
|
|
117
129
|
children?: AsChildChildren<{
|
|
118
130
|
total: MoneyData | null;
|
|
119
131
|
customPrice: string | null;
|
|
120
132
|
}>;
|
|
121
|
-
className?: string;
|
|
122
133
|
}
|
|
123
134
|
/**
|
|
124
135
|
* Displays the payment total.
|
|
@@ -144,13 +155,12 @@ export declare const Total: React.ForwardRefExoticComponent<TotalProps & React.R
|
|
|
144
155
|
/**
|
|
145
156
|
* Props for Payment.PayNow component
|
|
146
157
|
*/
|
|
147
|
-
export interface PayNowProps {
|
|
158
|
+
export interface PayNowProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
148
159
|
asChild?: boolean;
|
|
149
160
|
children?: AsChildChildren<{
|
|
150
161
|
payNow: MoneyData | null;
|
|
151
162
|
isDeposit: boolean;
|
|
152
163
|
}>;
|
|
153
|
-
className?: string;
|
|
154
164
|
}
|
|
155
165
|
/**
|
|
156
166
|
* Displays the pay now amount (amount to pay upfront in deposit scenarios).
|
|
@@ -166,13 +176,12 @@ export declare const PayNow: React.ForwardRefExoticComponent<PayNowProps & React
|
|
|
166
176
|
/**
|
|
167
177
|
* Props for Payment.PayLater component
|
|
168
178
|
*/
|
|
169
|
-
export interface PayLaterProps {
|
|
179
|
+
export interface PayLaterProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
170
180
|
asChild?: boolean;
|
|
171
181
|
children?: AsChildChildren<{
|
|
172
182
|
payLater: MoneyData | null;
|
|
173
183
|
isDeposit: boolean;
|
|
174
184
|
}>;
|
|
175
|
-
className?: string;
|
|
176
185
|
}
|
|
177
186
|
/**
|
|
178
187
|
* Displays the pay later amount (for deposit scenarios).
|
|
@@ -266,13 +275,12 @@ export declare const LineItemRepeater: React.ForwardRefExoticComponent<LineItemR
|
|
|
266
275
|
/**
|
|
267
276
|
* Props for Payment.LineItemTotal component
|
|
268
277
|
*/
|
|
269
|
-
export interface LineItemTotalProps {
|
|
278
|
+
export interface LineItemTotalProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
270
279
|
asChild?: boolean;
|
|
271
280
|
children?: AsChildChildren<{
|
|
272
281
|
totalPrice: MoneyData | null;
|
|
273
282
|
customPrice: string | null;
|
|
274
283
|
}>;
|
|
275
|
-
className?: string;
|
|
276
284
|
}
|
|
277
285
|
/**
|
|
278
286
|
* Displays the line item total (total price after tax).
|
|
@@ -288,13 +296,12 @@ export declare const LineItemTotal: React.ForwardRefExoticComponent<LineItemTota
|
|
|
288
296
|
/**
|
|
289
297
|
* Props for Payment.LineItemSubtotal component
|
|
290
298
|
*/
|
|
291
|
-
export interface LineItemSubtotalProps {
|
|
299
|
+
export interface LineItemSubtotalProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
292
300
|
asChild?: boolean;
|
|
293
301
|
children?: AsChildChildren<{
|
|
294
302
|
subtotal: MoneyData | null;
|
|
295
303
|
customPrice: string | null;
|
|
296
304
|
}>;
|
|
297
|
-
className?: string;
|
|
298
305
|
}
|
|
299
306
|
/**
|
|
300
307
|
* Displays the line item subtotal (full price before discounts).
|
|
@@ -310,12 +317,11 @@ export declare const LineItemSubtotal: React.ForwardRefExoticComponent<LineItemS
|
|
|
310
317
|
/**
|
|
311
318
|
* Props for Payment.LineItemDeposit component
|
|
312
319
|
*/
|
|
313
|
-
export interface LineItemDepositProps {
|
|
320
|
+
export interface LineItemDepositProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
314
321
|
asChild?: boolean;
|
|
315
322
|
children?: AsChildChildren<{
|
|
316
323
|
deposit: MoneyData | null;
|
|
317
324
|
}>;
|
|
318
|
-
className?: string;
|
|
319
325
|
}
|
|
320
326
|
/**
|
|
321
327
|
* Displays the line item deposit amount.
|
|
@@ -7,21 +7,20 @@ import React from 'react';
|
|
|
7
7
|
import * as CorePayment from '../core/payment/Payment.js';
|
|
8
8
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
9
9
|
import { Money, GenericList } from '@wix/headless-components/react';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})(TestIds || (TestIds = {}));
|
|
10
|
+
export const TestIds = {
|
|
11
|
+
paymentRoot: 'payment-root',
|
|
12
|
+
paymentSubtotal: 'payment-subtotal',
|
|
13
|
+
paymentTax: 'payment-tax',
|
|
14
|
+
paymentTotal: 'payment-total',
|
|
15
|
+
paymentPayNow: 'payment-pay-now',
|
|
16
|
+
paymentPayLater: 'payment-pay-later',
|
|
17
|
+
paymentLineItems: 'payment-line-items',
|
|
18
|
+
paymentLineItemsList: 'payment-line-items-list',
|
|
19
|
+
paymentLineItemRepeater: 'payment-line-item-repeater',
|
|
20
|
+
paymentLineItemTotal: 'payment-line-item-total',
|
|
21
|
+
paymentLineItemSubtotal: 'payment-line-item-subtotal',
|
|
22
|
+
paymentLineItemDeposit: 'payment-line-item-deposit',
|
|
23
|
+
};
|
|
25
24
|
/**
|
|
26
25
|
* Root component that provides payment context to the entire app.
|
|
27
26
|
* Supports 3 modes:
|
|
@@ -83,10 +82,10 @@ Root.displayName = 'Payment.Root';
|
|
|
83
82
|
*/
|
|
84
83
|
export const Subtotal = React.forwardRef((props, ref) => {
|
|
85
84
|
const { asChild, children, className } = props;
|
|
86
|
-
return (_jsx(CorePayment.Data, { children: ({ subtotal, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className,
|
|
85
|
+
return (_jsx(CorePayment.Data, { children: ({ subtotal, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: {
|
|
87
86
|
subtotal,
|
|
88
87
|
customPrice,
|
|
89
|
-
}, children: subtotal && _jsx(Money, { money: subtotal }) })) }));
|
|
88
|
+
}, "data-testid": TestIds.paymentSubtotal, "data-has-custom-price": !!customPrice, children: subtotal && _jsx(Money, { money: subtotal }) })) }));
|
|
90
89
|
});
|
|
91
90
|
Subtotal.displayName = 'Payment.Subtotal';
|
|
92
91
|
/**
|
|
@@ -101,7 +100,7 @@ Subtotal.displayName = 'Payment.Subtotal';
|
|
|
101
100
|
*/
|
|
102
101
|
export const Tax = React.forwardRef((props, ref) => {
|
|
103
102
|
const { asChild, children, className } = props;
|
|
104
|
-
return (_jsx(CorePayment.Data, { children: ({ tax, hasTax }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentTax, "data-has-tax": hasTax,
|
|
103
|
+
return (_jsx(CorePayment.Data, { children: ({ tax, hasTax }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { tax }, "data-testid": TestIds.paymentTax, "data-has-tax": hasTax, children: hasTax && _jsx(Money, { money: tax }) })) }));
|
|
105
104
|
});
|
|
106
105
|
Tax.displayName = 'Payment.Tax';
|
|
107
106
|
/**
|
|
@@ -126,10 +125,10 @@ Tax.displayName = 'Payment.Tax';
|
|
|
126
125
|
*/
|
|
127
126
|
export const Total = React.forwardRef((props, ref) => {
|
|
128
127
|
const { asChild, children, className } = props;
|
|
129
|
-
return (_jsx(CorePayment.Data, { children: ({ total, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className,
|
|
128
|
+
return (_jsx(CorePayment.Data, { children: ({ total, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: {
|
|
130
129
|
total,
|
|
131
130
|
customPrice,
|
|
132
|
-
}, children: total && _jsx(Money, { money: total }) })) }));
|
|
131
|
+
}, "data-testid": TestIds.paymentTotal, "data-has-custom-price": !!customPrice, children: total && _jsx(Money, { money: total }) })) }));
|
|
133
132
|
});
|
|
134
133
|
Total.displayName = 'Payment.Total';
|
|
135
134
|
/**
|
|
@@ -144,7 +143,7 @@ Total.displayName = 'Payment.Total';
|
|
|
144
143
|
*/
|
|
145
144
|
export const PayNow = React.forwardRef((props, ref) => {
|
|
146
145
|
const { asChild, children, className } = props;
|
|
147
|
-
return (_jsx(CorePayment.Data, { children: ({ payNow, isDeposit }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentPayNow, "data-has-deposit": isDeposit,
|
|
146
|
+
return (_jsx(CorePayment.Data, { children: ({ payNow, isDeposit }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { payNow, isDeposit }, "data-testid": TestIds.paymentPayNow, "data-has-deposit": isDeposit, children: isDeposit && payNow && payNow.amount > 0 && (_jsx(Money, { money: payNow })) })) }));
|
|
148
147
|
});
|
|
149
148
|
PayNow.displayName = 'Payment.PayNow';
|
|
150
149
|
/**
|
|
@@ -159,7 +158,7 @@ PayNow.displayName = 'Payment.PayNow';
|
|
|
159
158
|
*/
|
|
160
159
|
export const PayLater = React.forwardRef((props, ref) => {
|
|
161
160
|
const { asChild, children, className } = props;
|
|
162
|
-
return (_jsx(CorePayment.Data, { children: ({ payLater, isDeposit }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentPayLater, "data-has-deposit": isDeposit,
|
|
161
|
+
return (_jsx(CorePayment.Data, { children: ({ payLater, isDeposit }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { payLater, isDeposit }, "data-testid": TestIds.paymentPayLater, "data-has-deposit": isDeposit, children: isDeposit && payLater && payLater.amount > 0 && (_jsx(Money, { money: payLater })) })) }));
|
|
163
162
|
});
|
|
164
163
|
PayLater.displayName = 'Payment.PayLater';
|
|
165
164
|
/**
|
|
@@ -184,8 +183,8 @@ PayLater.displayName = 'Payment.PayLater';
|
|
|
184
183
|
* ```
|
|
185
184
|
*/
|
|
186
185
|
export const LineItems = React.forwardRef((props, ref) => {
|
|
187
|
-
const { asChild, children, className, ...
|
|
188
|
-
return (_jsx(CorePayment.LineItems, { children: ({ lineItems, currency, isLoading, error }) => (_jsx(GenericList.Root, { items: lineItems, isLoading: isLoading, error: error, children: _jsx(LineItemsContext.Provider, { value: { currency }, children: _jsx(AsChildSlot, { ...
|
|
186
|
+
const { asChild, children, className, ...rest } = props;
|
|
187
|
+
return (_jsx(CorePayment.LineItems, { children: ({ lineItems, currency, isLoading, error }) => (_jsx(GenericList.Root, { items: lineItems, isLoading: isLoading, error: error, children: _jsx(LineItemsContext.Provider, { value: { currency }, children: _jsx(AsChildSlot, { ...rest, ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItems, "data-loading": isLoading, "data-error": !!error, customElement: children, customElementProps: { lineItems, currency, isLoading, error }, children: _jsx("div", { children: React.isValidElement(children) ? children : null }) }) }) })) }));
|
|
189
188
|
});
|
|
190
189
|
LineItems.displayName = 'Payment.LineItems';
|
|
191
190
|
// Context for line items currency
|
|
@@ -252,8 +251,8 @@ LineItemRepeater.displayName = 'Payment.LineItemRepeater';
|
|
|
252
251
|
* ```
|
|
253
252
|
*/
|
|
254
253
|
export const LineItemTotal = React.forwardRef((props, ref) => {
|
|
255
|
-
const { asChild, children,
|
|
256
|
-
return (_jsx(CorePayment.LineItemInfo, { children: ({ totalPrice, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
254
|
+
const { asChild, children, ...rest } = props;
|
|
255
|
+
return (_jsx(CorePayment.LineItemInfo, { children: ({ totalPrice, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.paymentLineItemTotal, "data-has-custom-price": !!customPrice, customElement: children, customElementProps: { totalPrice, customPrice }, children: customPrice ? (_jsx("span", { children: customPrice })) : (totalPrice && _jsx(Money, { money: totalPrice })) })) }));
|
|
257
256
|
});
|
|
258
257
|
LineItemTotal.displayName = 'Payment.LineItemTotal';
|
|
259
258
|
/**
|
|
@@ -267,8 +266,8 @@ LineItemTotal.displayName = 'Payment.LineItemTotal';
|
|
|
267
266
|
* ```
|
|
268
267
|
*/
|
|
269
268
|
export const LineItemSubtotal = React.forwardRef((props, ref) => {
|
|
270
|
-
const { asChild, children,
|
|
271
|
-
return (_jsx(CorePayment.LineItemInfo, { children: ({ subtotal, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild,
|
|
269
|
+
const { asChild, children, ...rest } = props;
|
|
270
|
+
return (_jsx(CorePayment.LineItemInfo, { children: ({ subtotal, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": TestIds.paymentLineItemSubtotal, "data-has-custom-price": !!customPrice, customElement: children, customElementProps: { subtotal, customPrice }, children: customPrice ? (_jsx("span", { children: customPrice })) : (subtotal && _jsx(Money, { money: subtotal })) })) }));
|
|
272
271
|
});
|
|
273
272
|
LineItemSubtotal.displayName = 'Payment.LineItemSubtotal';
|
|
274
273
|
/**
|
|
@@ -283,6 +282,6 @@ LineItemSubtotal.displayName = 'Payment.LineItemSubtotal';
|
|
|
283
282
|
*/
|
|
284
283
|
export const LineItemDeposit = React.forwardRef((props, ref) => {
|
|
285
284
|
const { asChild, children, className } = props;
|
|
286
|
-
return (_jsx(CorePayment.LineItemInfo, { children: ({ deposit, hasDeposit }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemDeposit, "data-has-deposit": hasDeposit,
|
|
285
|
+
return (_jsx(CorePayment.LineItemInfo, { children: ({ deposit, hasDeposit }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { deposit }, "data-testid": TestIds.paymentLineItemDeposit, "data-has-deposit": hasDeposit, children: hasDeposit && _jsx(Money, { money: deposit }) })) }));
|
|
287
286
|
});
|
|
288
287
|
LineItemDeposit.displayName = 'Payment.LineItemDeposit';
|