@wix/headless-bookings 0.0.104 → 0.0.106
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/booking-client-service.js +25 -20
- package/cjs/dist/__mocks__/booking/booking-mocks.js +28 -20
- package/cjs/dist/__mocks__/payment/payment-mocks.js +6 -3
- package/cjs/dist/__mocks__/services/services-mocks.js +79 -74
- package/cjs/dist/__mocks__/time-slots/time-slots-client-service.js +39 -33
- package/cjs/dist/__mocks__/time-slots/time-slots-core.js +43 -33
- package/cjs/dist/__mocks__/time-slots/time-slots-mocks.js +18 -13
- package/cjs/dist/api/create-booking/index.js +6 -3
- package/cjs/dist/api/create-checkout/index.js +9 -4
- package/cjs/dist/api/create-order/index.js +6 -3
- package/cjs/dist/api/fetch-availability/index.js +18 -15
- package/cjs/dist/api/index.js +24 -7
- package/cjs/dist/api/query-categories/index.js +6 -3
- package/cjs/dist/api/query-locations/index.js +9 -5
- package/cjs/dist/api/query-services/index.js +24 -17
- package/cjs/dist/react/booking/Book.js +51 -12
- package/cjs/dist/react/booking/Booking.js +68 -26
- package/cjs/dist/react/booking/BookingItem.d.ts +2 -0
- package/cjs/dist/react/booking/BookingItem.js +57 -16
- package/cjs/dist/react/booking-form/BookingForm.js +63 -21
- package/cjs/dist/react/core/booking/Book.js +14 -11
- package/cjs/dist/react/core/booking/Booking.d.ts +3 -1
- package/cjs/dist/react/core/booking/Booking.js +38 -25
- package/cjs/dist/react/core/booking-form/BookingForm.js +63 -26
- package/cjs/dist/react/core/location/Location.js +60 -21
- package/cjs/dist/react/core/location-list/LocationList.js +15 -10
- package/cjs/dist/react/core/payment/Payment.js +41 -30
- package/cjs/dist/react/core/service/Service.js +28 -19
- package/cjs/dist/react/core/service/ServiceMediaCover.js +7 -4
- package/cjs/dist/react/core/service/ServiceMediaGallery.js +7 -4
- package/cjs/dist/react/core/service/ServiceMediaMain.js +7 -4
- package/cjs/dist/react/core/service-list/ServiceList.js +12 -8
- package/cjs/dist/react/core/service-list/ServiceListFilter.js +9 -6
- package/cjs/dist/react/core/staff-member/StaffMember.js +20 -14
- package/cjs/dist/react/core/staff-member-list/StaffMemberList.js +19 -14
- package/cjs/dist/react/core/time-slot-list/TimeSlot.js +41 -28
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +21 -15
- package/cjs/dist/react/index.js +49 -13
- package/cjs/dist/react/location/Location.js +76 -36
- package/cjs/dist/react/location/LocationList.js +70 -31
- package/cjs/dist/react/payment/Payment.js +87 -48
- package/cjs/dist/react/service/Service.js +197 -158
- package/cjs/dist/react/service/ServiceMedia.js +56 -17
- package/cjs/dist/react/service-list/ServiceList.js +71 -32
- package/cjs/dist/react/staff-member/StaffMember.js +61 -20
- package/cjs/dist/react/staff-member/StaffMemberList.js +68 -29
- package/cjs/dist/react/time-slot-list/TimeSlot.js +95 -56
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +87 -48
- package/cjs/dist/services/booking/book-action/bookAction.js +21 -18
- package/cjs/dist/services/booking/book-action/buildBookingRequest.js +18 -15
- package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +8 -5
- package/cjs/dist/services/booking/book-action/canBook.js +4 -1
- package/cjs/dist/services/booking/book-action/index.js +15 -6
- package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +4 -1
- package/cjs/dist/services/booking/book-action/types.js +5 -2
- package/cjs/dist/services/booking/booking.js +11 -8
- package/cjs/dist/services/booking-form/booking-form.js +26 -18
- package/cjs/dist/services/booking-form/utils.js +10 -4
- package/cjs/dist/services/constants.js +6 -3
- package/cjs/dist/services/index.js +48 -10
- package/cjs/dist/services/location-list/location-list.def.js +7 -5
- package/cjs/dist/services/location-list/location-list.js +31 -23
- package/cjs/dist/services/payment/payment.def.js +5 -2
- package/cjs/dist/services/payment/payment.js +22 -17
- package/cjs/dist/services/service/service.js +33 -29
- package/cjs/dist/services/service-list/service-list.js +22 -18
- package/cjs/dist/services/staff-member-list/staff-member-list.def.js +5 -2
- package/cjs/dist/services/staff-member-list/staff-member-list.js +16 -10
- package/cjs/dist/services/time-slot-list/index.js +12 -3
- package/cjs/dist/services/time-slot-list/time-slot-list.def.js +8 -5
- package/cjs/dist/services/time-slot-list/time-slot-list.js +24 -19
- package/cjs/dist/services/time-slot-list/time-slot.js +9 -6
- package/cjs/dist/utils/dateAndTime.js +7 -2
- package/cjs/dist/utils/guid.js +4 -1
- package/cjs/dist/utils/index.js +5 -1
- package/cjs/dist/utils/money.js +6 -2
- package/cjs/dist/utils/navigation.js +6 -3
- package/dist/react/booking/BookingItem.d.ts +2 -0
- package/dist/react/booking/BookingItem.js +2 -2
- package/dist/react/core/booking/Booking.d.ts +3 -1
- package/dist/react/core/booking/Booking.js +3 -2
- package/package.json +3 -3
|
@@ -1,25 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Query Services API
|
|
3
4
|
* Fetches single or multiple services with pagination and sorting
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getServiceBySlug = exports.getServiceById = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = void 0;
|
|
8
|
+
exports.convertPlatformFilterToApiFilter = convertPlatformFilterToApiFilter;
|
|
9
|
+
exports.queryServices = queryServices;
|
|
10
|
+
const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
|
|
11
|
+
const constants_js_1 = require("../../services/constants.js");
|
|
7
12
|
/**
|
|
8
13
|
* Synthetic location ID constants for non-business locations
|
|
9
14
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
exports.SYNTHETIC_CUSTOM_ID = 'custom';
|
|
16
|
+
exports.SYNTHETIC_CUSTOMER_ID = 'customer';
|
|
12
17
|
/**
|
|
13
18
|
* Fetches a service by its ID
|
|
14
19
|
* @param id - The service ID
|
|
15
20
|
* @param appId - Optional app ID, defaults to booking app ID
|
|
16
21
|
* @returns Object containing the service or null if not found
|
|
17
22
|
*/
|
|
18
|
-
|
|
23
|
+
const getServiceById = async (id, appId) => {
|
|
19
24
|
try {
|
|
20
|
-
const finalAppId = appId ?? BOOKING_APP_ID;
|
|
25
|
+
const finalAppId = appId ?? constants_js_1.BOOKING_APP_ID;
|
|
21
26
|
// Query services where _id equals the provided id and appId matches
|
|
22
|
-
const query =
|
|
27
|
+
const query = (0, auto_sdk_bookings_services_1.queryServices)({
|
|
23
28
|
conditionalFields: ['STAFF_MEMBER_DETAILS'],
|
|
24
29
|
});
|
|
25
30
|
const result = await query
|
|
@@ -36,17 +41,18 @@ export const getServiceById = async (id, appId) => {
|
|
|
36
41
|
return { service: null };
|
|
37
42
|
}
|
|
38
43
|
};
|
|
44
|
+
exports.getServiceById = getServiceById;
|
|
39
45
|
/**
|
|
40
46
|
* Fetches a service by its slug
|
|
41
47
|
* @param slug - The service slug
|
|
42
48
|
* @param appId - Optional app ID, defaults to booking app ID
|
|
43
49
|
* @returns Object containing the service or null if not found
|
|
44
50
|
*/
|
|
45
|
-
|
|
51
|
+
const getServiceBySlug = async (slug, appId) => {
|
|
46
52
|
try {
|
|
47
|
-
const finalAppId = appId ?? BOOKING_APP_ID;
|
|
53
|
+
const finalAppId = appId ?? constants_js_1.BOOKING_APP_ID;
|
|
48
54
|
// Query services where mainSlug.name equals the provided slug and appId matches
|
|
49
|
-
const query =
|
|
55
|
+
const query = (0, auto_sdk_bookings_services_1.queryServices)({
|
|
50
56
|
conditionalFields: ['STAFF_MEMBER_DETAILS'],
|
|
51
57
|
});
|
|
52
58
|
const result = await query
|
|
@@ -63,6 +69,7 @@ export const getServiceBySlug = async (slug, appId) => {
|
|
|
63
69
|
return { service: null };
|
|
64
70
|
}
|
|
65
71
|
};
|
|
72
|
+
exports.getServiceBySlug = getServiceBySlug;
|
|
66
73
|
/**
|
|
67
74
|
* Extracts an array of values from a platform Filter field that may use operators like $in or $hasSome.
|
|
68
75
|
* @param fieldValue - The filter field value (can be direct value, array, or operator object)
|
|
@@ -120,7 +127,7 @@ function extractArrayFromFilterField(fieldValue) {
|
|
|
120
127
|
* }
|
|
121
128
|
* ```
|
|
122
129
|
*/
|
|
123
|
-
|
|
130
|
+
function convertPlatformFilterToApiFilter(platformFilter) {
|
|
124
131
|
if (!platformFilter)
|
|
125
132
|
return {};
|
|
126
133
|
const apiFilter = {};
|
|
@@ -135,11 +142,11 @@ export function convertPlatformFilterToApiFilter(platformFilter) {
|
|
|
135
142
|
const syntheticTypes = [];
|
|
136
143
|
const businessLocationIds = [];
|
|
137
144
|
for (const id of locationIds) {
|
|
138
|
-
if (id === SYNTHETIC_CUSTOM_ID) {
|
|
139
|
-
syntheticTypes.push(LocationType.CUSTOM);
|
|
145
|
+
if (id === exports.SYNTHETIC_CUSTOM_ID) {
|
|
146
|
+
syntheticTypes.push(auto_sdk_bookings_services_1.LocationType.CUSTOM);
|
|
140
147
|
}
|
|
141
|
-
else if (id === SYNTHETIC_CUSTOMER_ID) {
|
|
142
|
-
syntheticTypes.push(LocationType.CUSTOMER);
|
|
148
|
+
else if (id === exports.SYNTHETIC_CUSTOMER_ID) {
|
|
149
|
+
syntheticTypes.push(auto_sdk_bookings_services_1.LocationType.CUSTOMER);
|
|
143
150
|
}
|
|
144
151
|
else {
|
|
145
152
|
businessLocationIds.push(id);
|
|
@@ -207,7 +214,7 @@ const buildServicesQueryRequest = ({ appId, filter: platformFilter, paging, sort
|
|
|
207
214
|
* }
|
|
208
215
|
* ```
|
|
209
216
|
*/
|
|
210
|
-
|
|
217
|
+
async function queryServices({ appId, filter, pagingMetadata, sort, }) {
|
|
211
218
|
try {
|
|
212
219
|
const queryRequest = buildServicesQueryRequest({
|
|
213
220
|
appId,
|
|
@@ -217,7 +224,7 @@ export async function queryServices({ appId, filter, pagingMetadata, sort, }) {
|
|
|
217
224
|
});
|
|
218
225
|
// Call queryServices with QueryServicesRequest and execute the query
|
|
219
226
|
// Include conditionalFields to fetch staff member details
|
|
220
|
-
const result = await
|
|
227
|
+
const result = await (0, auto_sdk_bookings_services_1.queryServices)({
|
|
221
228
|
...queryRequest,
|
|
222
229
|
conditionalFields: ['STAFF_MEMBER_DETAILS'],
|
|
223
230
|
}).find();
|
|
@@ -1,13 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Book = exports.TestIds = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
41
|
/**
|
|
3
42
|
* Book - High-level headless component for the book action button
|
|
4
43
|
* Wraps core Book with AsChildSlot pattern for customization
|
|
5
44
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
45
|
+
const react_1 = __importDefault(require("react"));
|
|
46
|
+
const react_2 = require("@wix/headless-utils/react");
|
|
47
|
+
const CoreBook = __importStar(require("../core/booking/Book.js"));
|
|
48
|
+
const navigation_js_1 = require("../../utils/navigation.js");
|
|
49
|
+
exports.TestIds = {
|
|
11
50
|
bookingActionBook: 'booking-action-book',
|
|
12
51
|
};
|
|
13
52
|
/**
|
|
@@ -55,11 +94,11 @@ export const TestIds = {
|
|
|
55
94
|
* </Booking.Actions.Book>
|
|
56
95
|
* ```
|
|
57
96
|
*/
|
|
58
|
-
|
|
97
|
+
exports.Book = react_1.default.forwardRef((props, ref) => {
|
|
59
98
|
const { asChild, children, label, loadingState, disabled, onCheckout, onComplete, onError, onClick, ...rest } = props;
|
|
60
|
-
return (
|
|
99
|
+
return ((0, jsx_runtime_1.jsx)(CoreBook.Book, { onCheckout: (result) => {
|
|
61
100
|
// Create navigateToCheckout with checkoutId captured
|
|
62
|
-
const navigateToCheckout = (options) =>
|
|
101
|
+
const navigateToCheckout = (options) => (0, navigation_js_1.navigateToCheckout)({
|
|
63
102
|
checkoutId: result.checkoutId,
|
|
64
103
|
navigationInfo: { postFlowUrl: options.postFlowUrl },
|
|
65
104
|
});
|
|
@@ -72,12 +111,12 @@ export const Book = React.forwardRef((props, ref) => {
|
|
|
72
111
|
await coreBookProps.onClick();
|
|
73
112
|
onClick?.(coreBookProps);
|
|
74
113
|
};
|
|
75
|
-
return (
|
|
114
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, disabled: coreBookProps.disabled, "data-testid": exports.TestIds.bookingActionBook, "data-in-progress": coreBookProps.isLoading, "data-can-book": coreBookProps.canBook, customElement: children, customElementProps: {
|
|
76
115
|
...coreBookProps,
|
|
77
116
|
onClick: handleClick,
|
|
78
|
-
}, children:
|
|
117
|
+
}, children: (0, jsx_runtime_1.jsx)("button", { onClick: handleClick, children: coreBookProps.isLoading
|
|
79
118
|
? loadingState
|
|
80
119
|
: children || label }) }));
|
|
81
120
|
} }));
|
|
82
121
|
});
|
|
83
|
-
Book.displayName = 'Booking.Actions.Book';
|
|
122
|
+
exports.Book.displayName = 'Booking.Actions.Book';
|
|
@@ -1,18 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.BookingItemRepeater = exports.BookingItems = exports.useBookingItem = exports.Actions = exports.Root = exports.TestIds = void 0;
|
|
40
|
+
exports.Payment = Payment;
|
|
41
|
+
exports.Location = Location;
|
|
42
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
43
|
/**
|
|
3
44
|
* Booking - High-level component for managing bookings
|
|
4
45
|
* Provides root component for booking context and booking item display components
|
|
5
46
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
47
|
+
const react_1 = __importDefault(require("react"));
|
|
48
|
+
const CoreBooking = __importStar(require("../core/booking/Booking.js"));
|
|
49
|
+
const Book_js_1 = require("./Book.js");
|
|
50
|
+
const PaymentComponent = __importStar(require("../payment/Payment.js"));
|
|
51
|
+
const CoreLocation = __importStar(require("../core/location/Location.js"));
|
|
52
|
+
const react_2 = require("@wix/headless-components/react");
|
|
12
53
|
// ============================================================================
|
|
13
54
|
// TestIds
|
|
14
55
|
// ============================================================================
|
|
15
|
-
|
|
56
|
+
exports.TestIds = {
|
|
16
57
|
bookingItemsRoot: 'booking-items-root',
|
|
17
58
|
bookingItems: 'booking-items',
|
|
18
59
|
bookingItem: 'booking-item',
|
|
@@ -40,11 +81,12 @@ export const TestIds = {
|
|
|
40
81
|
* }
|
|
41
82
|
* ```
|
|
42
83
|
*/
|
|
43
|
-
|
|
84
|
+
const Root = (props) => {
|
|
44
85
|
const { children, bookingServiceConfig = {} } = props;
|
|
45
|
-
return (
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.Root, { bookingServiceConfig: bookingServiceConfig, children: children }));
|
|
46
87
|
};
|
|
47
|
-
Root
|
|
88
|
+
exports.Root = Root;
|
|
89
|
+
exports.Root.displayName = 'Booking.Root';
|
|
48
90
|
// ============================================================================
|
|
49
91
|
// Actions Namespace
|
|
50
92
|
// ============================================================================
|
|
@@ -64,8 +106,8 @@ Root.displayName = 'Booking.Root';
|
|
|
64
106
|
* />
|
|
65
107
|
* ```
|
|
66
108
|
*/
|
|
67
|
-
|
|
68
|
-
Book,
|
|
109
|
+
exports.Actions = {
|
|
110
|
+
Book: Book_js_1.Book,
|
|
69
111
|
};
|
|
70
112
|
// ============================================================================
|
|
71
113
|
// BookingItem Context (re-export from core)
|
|
@@ -76,7 +118,7 @@ export const Actions = {
|
|
|
76
118
|
*
|
|
77
119
|
* @throws Error if used outside of BookingItemRepeater context
|
|
78
120
|
*/
|
|
79
|
-
|
|
121
|
+
exports.useBookingItem = CoreBooking.useBookingItemContext;
|
|
80
122
|
/**
|
|
81
123
|
* Container component for booking items with emptyState support.
|
|
82
124
|
* Provides GenericList context and renders items.
|
|
@@ -93,19 +135,19 @@ export const useBookingItem = CoreBooking.useBookingItemContext;
|
|
|
93
135
|
* </Booking.BookingItems>
|
|
94
136
|
* ```
|
|
95
137
|
*/
|
|
96
|
-
|
|
138
|
+
exports.BookingItems = react_1.default.forwardRef((props, ref) => {
|
|
97
139
|
const { children, emptyState, ...otherProps } = props;
|
|
98
|
-
return (
|
|
140
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.ItemsData, { children: ({ items }) => ((0, jsx_runtime_1.jsx)(react_2.GenericList.Root, { ref: ref, items: items.map((item) => ({
|
|
99
141
|
...item,
|
|
100
142
|
id: item.instanceId,
|
|
101
|
-
})), hasMore: false, isLoading: false, "data-testid": TestIds.bookingItems, ...otherProps, children:
|
|
143
|
+
})), hasMore: false, isLoading: false, "data-testid": exports.TestIds.bookingItems, ...otherProps, children: (0, jsx_runtime_1.jsx)(react_2.GenericList.Items, { emptyState: emptyState, children: children }) })) }));
|
|
102
144
|
});
|
|
103
|
-
BookingItems.displayName = 'Booking.BookingItems';
|
|
145
|
+
exports.BookingItems.displayName = 'Booking.BookingItems';
|
|
104
146
|
/**
|
|
105
147
|
* Internal component that wraps each booking item with context provider.
|
|
106
148
|
*/
|
|
107
149
|
const BookingItemWrapper = ({ item, children, }) => {
|
|
108
|
-
return (
|
|
150
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.BookingItemProvider, { item: item, children: children }));
|
|
109
151
|
};
|
|
110
152
|
/**
|
|
111
153
|
* Repeater component that maps over booking items and provides context per item.
|
|
@@ -129,11 +171,11 @@ const BookingItemWrapper = ({ item, children, }) => {
|
|
|
129
171
|
* </Booking.BookingItemRepeater>
|
|
130
172
|
* ```
|
|
131
173
|
*/
|
|
132
|
-
|
|
174
|
+
exports.BookingItemRepeater = react_1.default.forwardRef((props, ref) => {
|
|
133
175
|
const { children } = props;
|
|
134
|
-
return (
|
|
176
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Repeater, { ref: ref, itemWrapper: ({ item }) => ((0, jsx_runtime_1.jsx)(BookingItemWrapper, { item: item, children: children }, item.instanceId)), children: undefined }));
|
|
135
177
|
});
|
|
136
|
-
BookingItemRepeater.displayName = 'Booking.BookingItemRepeater';
|
|
178
|
+
exports.BookingItemRepeater.displayName = 'Booking.BookingItemRepeater';
|
|
137
179
|
/**
|
|
138
180
|
* Wraps Payment.Root with all services from all booking items.
|
|
139
181
|
* Should be used outside of ItemRepeater - it calculates payment for all items.
|
|
@@ -155,9 +197,9 @@ BookingItemRepeater.displayName = 'Booking.BookingItemRepeater';
|
|
|
155
197
|
* </Booking.Payment>
|
|
156
198
|
* ```
|
|
157
199
|
*/
|
|
158
|
-
|
|
200
|
+
function Payment(props) {
|
|
159
201
|
const { children, asChild, className } = props;
|
|
160
|
-
return (
|
|
202
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.PaymentData, { children: ({ pricingServiceSelections }) => ((0, jsx_runtime_1.jsx)(PaymentComponent.Root, { pricingServiceSelections: pricingServiceSelections, asChild: asChild, className: className, children: children })) }));
|
|
161
203
|
}
|
|
162
204
|
/**
|
|
163
205
|
* Wraps Location context with the location from the booking context.
|
|
@@ -174,7 +216,7 @@ export function Payment(props) {
|
|
|
174
216
|
* </Booking.Location>
|
|
175
217
|
* ```
|
|
176
218
|
*/
|
|
177
|
-
|
|
219
|
+
function Location(props) {
|
|
178
220
|
const { children } = props;
|
|
179
|
-
return (
|
|
221
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.Data, { children: ({ location }) => location ? ((0, jsx_runtime_1.jsx)(CoreLocation.Root, { location: location, children: children })) : null }));
|
|
180
222
|
}
|
|
@@ -54,6 +54,8 @@ export interface StaffNameProps extends Omit<React.HTMLAttributes<HTMLElement>,
|
|
|
54
54
|
children?: AsChildChildren<{
|
|
55
55
|
name: string;
|
|
56
56
|
}>;
|
|
57
|
+
/** Label to display when no specific staff member is assigned */
|
|
58
|
+
anyStaffLabel?: string;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* Displays the staff member's name from the current booking item.
|
|
@@ -1,14 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.StaffName = exports.TestIds = void 0;
|
|
40
|
+
exports.Service = Service;
|
|
41
|
+
exports.TimeSlot = TimeSlot;
|
|
42
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
43
|
/**
|
|
3
44
|
* BookingItem - Components for displaying booking item details
|
|
4
45
|
* Must be used within Booking.BookingItemRepeater context
|
|
5
46
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
47
|
+
const react_1 = __importDefault(require("react"));
|
|
48
|
+
const CoreBooking = __importStar(require("../core/booking/Booking.js"));
|
|
49
|
+
const react_2 = require("@wix/headless-utils/react");
|
|
50
|
+
const ServiceComponent = __importStar(require("../service/Service.js"));
|
|
51
|
+
const TimeSlotComponent = __importStar(require("../time-slot-list/TimeSlot.js"));
|
|
52
|
+
exports.TestIds = {
|
|
12
53
|
bookingItemService: 'booking-item-service',
|
|
13
54
|
bookingItemTimeSlot: 'booking-item-time-slot',
|
|
14
55
|
bookingItemStaffName: 'booking-item-staff-name',
|
|
@@ -26,9 +67,9 @@ export const TestIds = {
|
|
|
26
67
|
* </BookingItem.Service>
|
|
27
68
|
* ```
|
|
28
69
|
*/
|
|
29
|
-
|
|
70
|
+
function Service(props) {
|
|
30
71
|
const { children } = props;
|
|
31
|
-
return (
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.BookingItemInfo, { children: ({ service }) => ((0, jsx_runtime_1.jsx)(ServiceComponent.Root, { service: service, children: children })) }));
|
|
32
73
|
}
|
|
33
74
|
Service.displayName = 'BookingItem.Service';
|
|
34
75
|
/**
|
|
@@ -44,9 +85,9 @@ Service.displayName = 'BookingItem.Service';
|
|
|
44
85
|
* </BookingItem.TimeSlot>
|
|
45
86
|
* ```
|
|
46
87
|
*/
|
|
47
|
-
|
|
88
|
+
function TimeSlot(props) {
|
|
48
89
|
const { children } = props;
|
|
49
|
-
return (
|
|
90
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.BookingItemInfo, { children: ({ timeSlot }) => timeSlot ? ((0, jsx_runtime_1.jsx)(TimeSlotComponent.Root, { timeSlot: timeSlot, children: children })) : null }));
|
|
50
91
|
}
|
|
51
92
|
TimeSlot.displayName = 'BookingItem.TimeSlot';
|
|
52
93
|
/**
|
|
@@ -59,12 +100,12 @@ TimeSlot.displayName = 'BookingItem.TimeSlot';
|
|
|
59
100
|
* <BookingItem.StaffName className="text-foreground" />
|
|
60
101
|
* ```
|
|
61
102
|
*/
|
|
62
|
-
|
|
63
|
-
const { asChild, children, ...rest } = props;
|
|
64
|
-
return (
|
|
103
|
+
exports.StaffName = react_1.default.forwardRef((props, ref) => {
|
|
104
|
+
const { asChild, children, anyStaffLabel, ...rest } = props;
|
|
105
|
+
return ((0, jsx_runtime_1.jsx)(CoreBooking.BookingItemInfo, { anyStaffLabel: anyStaffLabel, children: ({ staffName }) => {
|
|
65
106
|
if (!staffName)
|
|
66
107
|
return null;
|
|
67
|
-
return (
|
|
108
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.bookingItemStaffName, customElement: children, customElementProps: { name: staffName }, children: (0, jsx_runtime_1.jsx)("span", { children: staffName }) }));
|
|
68
109
|
} }));
|
|
69
110
|
});
|
|
70
|
-
StaffName.displayName = 'BookingItem.StaffName';
|
|
111
|
+
exports.StaffName.displayName = 'BookingItem.StaffName';
|
|
@@ -1,17 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.BookingFormConfigurationError = exports.isBookingFormConfigurationError = exports.LoadError = exports.Fields = exports.Root = exports.TestIds = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
41
|
/**
|
|
3
42
|
* BookingForm - High-level component for rendering booking forms
|
|
4
43
|
* Provides components for displaying and managing booking form fields
|
|
5
44
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
45
|
+
const react_1 = __importDefault(require("react"));
|
|
46
|
+
const react_2 = require("@wix/headless-utils/react");
|
|
47
|
+
const react_3 = require("@wix/headless-forms/react");
|
|
48
|
+
const CoreBookingForm = __importStar(require("../core/booking-form/BookingForm.js"));
|
|
49
|
+
const booking_form_js_1 = require("../../services/booking-form/booking-form.js");
|
|
11
50
|
/**
|
|
12
51
|
* Internal ErrorBoundary for catching BookingFormConfigurationError
|
|
13
52
|
*/
|
|
14
|
-
class BookingFormErrorBoundary extends
|
|
53
|
+
class BookingFormErrorBoundary extends react_1.default.Component {
|
|
15
54
|
constructor(props) {
|
|
16
55
|
super(props);
|
|
17
56
|
this.state = { error: null };
|
|
@@ -24,7 +63,7 @@ class BookingFormErrorBoundary extends React.Component {
|
|
|
24
63
|
const { children, fallback } = this.props;
|
|
25
64
|
if (error) {
|
|
26
65
|
// If it's a configuration error, render the fallback
|
|
27
|
-
if (error instanceof BookingFormConfigurationError) {
|
|
66
|
+
if (error instanceof booking_form_js_1.BookingFormConfigurationError) {
|
|
28
67
|
if (typeof fallback === 'function') {
|
|
29
68
|
return fallback(error);
|
|
30
69
|
}
|
|
@@ -32,7 +71,7 @@ class BookingFormErrorBoundary extends React.Component {
|
|
|
32
71
|
return fallback;
|
|
33
72
|
}
|
|
34
73
|
// Default fallback UI
|
|
35
|
-
return
|
|
74
|
+
return (0, jsx_runtime_1.jsx)("div", { "data-testid": "booking-form-load-error", children: error.message });
|
|
36
75
|
}
|
|
37
76
|
// Re-throw non-configuration errors
|
|
38
77
|
throw error;
|
|
@@ -40,7 +79,7 @@ class BookingFormErrorBoundary extends React.Component {
|
|
|
40
79
|
return children;
|
|
41
80
|
}
|
|
42
81
|
}
|
|
43
|
-
|
|
82
|
+
exports.TestIds = {
|
|
44
83
|
bookingFormRoot: 'booking-form-root',
|
|
45
84
|
bookingFormFields: 'booking-form-fields',
|
|
46
85
|
bookingFormActionValidateFormSubmission: 'booking-form-action-validate-form-submission',
|
|
@@ -111,29 +150,29 @@ export const TestIds = {
|
|
|
111
150
|
* </BookingForm.Root>
|
|
112
151
|
* ```
|
|
113
152
|
*/
|
|
114
|
-
|
|
153
|
+
exports.Root = react_1.default.forwardRef((props, ref) => {
|
|
115
154
|
const { children, asChild, className, formId, serviceIds, additionalMetadata, fieldMap, rowGapClassname = 'gap-y-4', columnGapClassname = 'gap-x-2', loadErrorFallback, ...otherProps } = props;
|
|
116
|
-
return (
|
|
155
|
+
return ((0, jsx_runtime_1.jsx)(BookingFormErrorBoundary, { fallback: loadErrorFallback, children: (0, jsx_runtime_1.jsx)(CoreBookingForm.Root, { formId: formId, serviceIds: serviceIds, additionalMetadata: additionalMetadata, fieldMap: fieldMap, children: (renderProps) => {
|
|
117
156
|
// If children is a render prop function, call it with the render props
|
|
118
157
|
if (typeof children === 'function') {
|
|
119
158
|
return children(renderProps);
|
|
120
159
|
}
|
|
121
160
|
// Otherwise, use declarative pattern with context
|
|
122
|
-
return (
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)(BookingFormContext.Provider, { value: {
|
|
123
162
|
fields: renderProps.fields,
|
|
124
163
|
rowGapClassname,
|
|
125
164
|
columnGapClassname,
|
|
126
|
-
}, children:
|
|
165
|
+
}, children: (0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": exports.TestIds.bookingFormRoot, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: children ?? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_3.Form.Loading, { className: "flex justify-center p-4 text-foreground" }), (0, jsx_runtime_1.jsx)(react_3.Form.LoadingError, { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-lg mb-4" }), (0, jsx_runtime_1.jsx)(react_3.Form.Fields, { fieldMap: renderProps.fields, rowGapClassname: rowGapClassname, columnGapClassname: columnGapClassname }), (0, jsx_runtime_1.jsx)(react_3.Form.Error, { className: "mt-4 bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-lg" }), (0, jsx_runtime_1.jsx)(react_3.Form.Submitted, { className: "mt-4 bg-green-500/10 border border-green-500/20 text-green-500 px-4 py-3 rounded-lg" })] })) }) }) }));
|
|
127
166
|
} }) }));
|
|
128
167
|
});
|
|
129
|
-
Root.displayName = 'BookingForm.Root';
|
|
130
|
-
const BookingFormContext =
|
|
168
|
+
exports.Root.displayName = 'BookingForm.Root';
|
|
169
|
+
const BookingFormContext = react_1.default.createContext(null);
|
|
131
170
|
/**
|
|
132
171
|
* Hook to access BookingForm context
|
|
133
172
|
* @internal
|
|
134
173
|
*/
|
|
135
174
|
function useBookingFormContext() {
|
|
136
|
-
const context =
|
|
175
|
+
const context = react_1.default.useContext(BookingFormContext);
|
|
137
176
|
if (!context) {
|
|
138
177
|
throw new Error('useBookingFormContext must be used within a BookingForm.Root component');
|
|
139
178
|
}
|
|
@@ -153,16 +192,19 @@ function useBookingFormContext() {
|
|
|
153
192
|
* </BookingForm.Root>
|
|
154
193
|
* ```
|
|
155
194
|
*/
|
|
156
|
-
|
|
195
|
+
exports.Fields = react_1.default.forwardRef((props, ref) => {
|
|
157
196
|
const context = useBookingFormContext();
|
|
158
197
|
const { rowGapClassname = context.rowGapClassname, columnGapClassname = context.columnGapClassname, className, ...otherProps } = props;
|
|
159
|
-
return (
|
|
198
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: className, "data-testid": exports.TestIds.bookingFormFields, ...otherProps, children: (0, jsx_runtime_1.jsx)(react_3.Form.Fields, { fieldMap: context.fields, rowGapClassname: rowGapClassname, columnGapClassname: columnGapClassname }) }));
|
|
160
199
|
});
|
|
161
|
-
Fields.displayName = 'BookingForm.Fields';
|
|
200
|
+
exports.Fields.displayName = 'BookingForm.Fields';
|
|
162
201
|
// ============================================================================
|
|
163
202
|
// Error Handling
|
|
164
203
|
// ============================================================================
|
|
165
204
|
/**
|
|
166
205
|
* Re-export LoadError component and utilities for error handling
|
|
167
206
|
*/
|
|
168
|
-
|
|
207
|
+
var BookingForm_js_1 = require("../core/booking-form/BookingForm.js");
|
|
208
|
+
Object.defineProperty(exports, "LoadError", { enumerable: true, get: function () { return BookingForm_js_1.LoadError; } });
|
|
209
|
+
Object.defineProperty(exports, "isBookingFormConfigurationError", { enumerable: true, get: function () { return BookingForm_js_1.isBookingFormConfigurationError; } });
|
|
210
|
+
Object.defineProperty(exports, "BookingFormConfigurationError", { enumerable: true, get: function () { return BookingForm_js_1.BookingFormConfigurationError; } });
|