@wix/headless-bookings 0.0.105 → 0.0.107
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.js +56 -15
- 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.js +35 -23
- 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/package.json +4 -4
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Root = Root;
|
|
7
|
+
exports.useStaffMemberContext = useStaffMemberContext;
|
|
8
|
+
exports.StaffMemberProvider = StaffMemberProvider;
|
|
9
|
+
exports.Info = Info;
|
|
10
|
+
exports.Actions = Actions;
|
|
11
|
+
exports.StaffMembers = StaffMembers;
|
|
12
|
+
exports.StaffMemberInfo = StaffMemberInfo;
|
|
13
|
+
exports.StaffMemberActions = StaffMemberActions;
|
|
14
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
15
|
/**
|
|
3
16
|
* Core TimeSlot Components
|
|
4
17
|
* Provides low-level access to TimeSlot data via render props
|
|
@@ -6,12 +19,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
19
|
* Note: These components must be used within TimeSlotList.TimeSlotRepeater
|
|
7
20
|
* which provides the TimeSlotProvider context.
|
|
8
21
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
24
|
+
const services_manager_1 = require("@wix/services-manager");
|
|
25
|
+
const time_slot_list_def_js_1 = require("../../../services/time-slot-list/time-slot-list.def.js");
|
|
26
|
+
const booking_js_1 = require("../../../services/booking/booking.js");
|
|
27
|
+
const time_slot_js_1 = require("../../../services/time-slot-list/time-slot.js");
|
|
15
28
|
/**
|
|
16
29
|
* Root component that provides TimeSlot context.
|
|
17
30
|
*
|
|
@@ -23,16 +36,16 @@ import { TimeSlotServiceDefinition, TimeSlotService, } from '../../../services/t
|
|
|
23
36
|
* </TimeSlot.Root>
|
|
24
37
|
* ```
|
|
25
38
|
*/
|
|
26
|
-
|
|
27
|
-
return (
|
|
39
|
+
function Root(props) {
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(time_slot_js_1.TimeSlotServiceDefinition, time_slot_js_1.TimeSlotService, props.config), disposeOnUnmount: true, children: props.children }));
|
|
28
41
|
}
|
|
29
|
-
const StaffMemberContext =
|
|
42
|
+
const StaffMemberContext = react_1.default.createContext(null);
|
|
30
43
|
/**
|
|
31
44
|
* Hook to access StaffMember context
|
|
32
45
|
* @throws Error if used outside of StaffMemberProvider
|
|
33
46
|
*/
|
|
34
|
-
|
|
35
|
-
const context =
|
|
47
|
+
function useStaffMemberContext() {
|
|
48
|
+
const context = react_1.default.useContext(StaffMemberContext);
|
|
36
49
|
if (!context) {
|
|
37
50
|
throw new Error('StaffMember components must be used within StaffMemberProvider');
|
|
38
51
|
}
|
|
@@ -42,9 +55,9 @@ export function useStaffMemberContext() {
|
|
|
42
55
|
* Provider component used by StaffMemberRepeater to provide context.
|
|
43
56
|
* Not used directly by consumers - only by TimeSlot.StaffMemberRepeater.
|
|
44
57
|
*/
|
|
45
|
-
|
|
58
|
+
function StaffMemberProvider(props) {
|
|
46
59
|
const { children, staffMember } = props;
|
|
47
|
-
const service = useService(TimeSlotListServiceDefinition);
|
|
60
|
+
const service = (0, services_manager_react_1.useService)(time_slot_list_def_js_1.TimeSlotListServiceDefinition);
|
|
48
61
|
const selectStaffMember = () => {
|
|
49
62
|
service.actions.selectStaffMember(staffMember.id);
|
|
50
63
|
};
|
|
@@ -52,7 +65,7 @@ export function StaffMemberProvider(props) {
|
|
|
52
65
|
staffMember,
|
|
53
66
|
selectStaffMember,
|
|
54
67
|
};
|
|
55
|
-
return (
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(StaffMemberContext.Provider, { value: contextValue, children: children }));
|
|
56
69
|
}
|
|
57
70
|
/**
|
|
58
71
|
* Core component that provides access to time slot info via render props.
|
|
@@ -71,10 +84,10 @@ export function StaffMemberProvider(props) {
|
|
|
71
84
|
* </TimeSlot.Info>
|
|
72
85
|
* ```
|
|
73
86
|
*/
|
|
74
|
-
|
|
75
|
-
const timeSlotService = useService(TimeSlotServiceDefinition);
|
|
87
|
+
function Info(props) {
|
|
88
|
+
const timeSlotService = (0, services_manager_react_1.useService)(time_slot_js_1.TimeSlotServiceDefinition);
|
|
76
89
|
const timeSlot = timeSlotService.timeSlotSignal.get();
|
|
77
|
-
const bookingService = useService(BookingServiceDefinition);
|
|
90
|
+
const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
|
|
78
91
|
const selectedTimeSlot = bookingService.serviceSelections.get()[0]?.timeSlot;
|
|
79
92
|
const isSelected = selectedTimeSlot?.startDate === timeSlot.localStartDate &&
|
|
80
93
|
selectedTimeSlot?.location?._id === timeSlot.location?._id;
|
|
@@ -113,11 +126,11 @@ export function Info(props) {
|
|
|
113
126
|
* </TimeSlot.Actions>
|
|
114
127
|
* ```
|
|
115
128
|
*/
|
|
116
|
-
|
|
117
|
-
const timeSlotService = useService(TimeSlotServiceDefinition);
|
|
129
|
+
function Actions(props) {
|
|
130
|
+
const timeSlotService = (0, services_manager_react_1.useService)(time_slot_js_1.TimeSlotServiceDefinition);
|
|
118
131
|
const timeSlot = timeSlotService.timeSlotSignal.get();
|
|
119
|
-
const service = useService(TimeSlotListServiceDefinition);
|
|
120
|
-
const bookingService = useService(BookingServiceDefinition);
|
|
132
|
+
const service = (0, services_manager_react_1.useService)(time_slot_list_def_js_1.TimeSlotListServiceDefinition);
|
|
133
|
+
const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
|
|
121
134
|
const selectedTimeSlot = bookingService.serviceSelections.get()[0]?.timeSlot;
|
|
122
135
|
const isSelected = selectedTimeSlot?.startDate === timeSlot.localStartDate &&
|
|
123
136
|
selectedTimeSlot?.location?._id === timeSlot.location?._id;
|
|
@@ -158,11 +171,11 @@ export function Actions(props) {
|
|
|
158
171
|
* </CoreTimeSlot.StaffMembers>
|
|
159
172
|
* ```
|
|
160
173
|
*/
|
|
161
|
-
|
|
162
|
-
const timeSlotService = useService(TimeSlotServiceDefinition);
|
|
174
|
+
function StaffMembers(props) {
|
|
175
|
+
const timeSlotService = (0, services_manager_react_1.useService)(time_slot_js_1.TimeSlotServiceDefinition);
|
|
163
176
|
const timeSlot = timeSlotService.timeSlotSignal.get();
|
|
164
|
-
const service = useService(TimeSlotListServiceDefinition);
|
|
165
|
-
const bookingService = useService(BookingServiceDefinition);
|
|
177
|
+
const service = (0, services_manager_react_1.useService)(time_slot_list_def_js_1.TimeSlotListServiceDefinition);
|
|
178
|
+
const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
|
|
166
179
|
const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.timeSlot?.resources?.[0]?._id;
|
|
167
180
|
const staffMembers = timeSlot.availableResources[0].resources;
|
|
168
181
|
if (staffMembers.length <= 1) {
|
|
@@ -192,7 +205,7 @@ export function StaffMembers(props) {
|
|
|
192
205
|
* </StaffMemberInfo>
|
|
193
206
|
* ```
|
|
194
207
|
*/
|
|
195
|
-
|
|
208
|
+
function StaffMemberInfo(props) {
|
|
196
209
|
const { staffMember } = useStaffMemberContext();
|
|
197
210
|
return props.children({
|
|
198
211
|
name: staffMember.name,
|
|
@@ -216,7 +229,7 @@ export function StaffMemberInfo(props) {
|
|
|
216
229
|
* </StaffMemberActions>
|
|
217
230
|
* ```
|
|
218
231
|
*/
|
|
219
|
-
|
|
232
|
+
function StaffMemberActions(props) {
|
|
220
233
|
const { staffMember, selectStaffMember } = useStaffMemberContext();
|
|
221
234
|
return props.children({
|
|
222
235
|
selectStaffMember,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Root = Root;
|
|
4
|
+
exports.Timezone = Timezone;
|
|
5
|
+
exports.ListData = ListData;
|
|
6
|
+
exports.DateRange = DateRange;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
9
|
+
const services_manager_1 = require("@wix/services-manager");
|
|
10
|
+
const index_js_1 = require("../../../services/time-slot-list/index.js");
|
|
11
|
+
const booking_js_1 = require("../../../services/booking/booking.js");
|
|
6
12
|
/**
|
|
7
13
|
* Root component that provides TimeSlotListService context to its children.
|
|
8
14
|
*
|
|
@@ -14,8 +20,8 @@ import { BookingServiceDefinition } from '../../../services/booking/booking.js';
|
|
|
14
20
|
* </Root>
|
|
15
21
|
* ```
|
|
16
22
|
*/
|
|
17
|
-
|
|
18
|
-
return (
|
|
23
|
+
function Root(props) {
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(index_js_1.TimeSlotListServiceDefinition, index_js_1.TimeSlotListService, props.config), disposeOnUnmount: true, children: props.children }));
|
|
19
25
|
}
|
|
20
26
|
// ============================================================================
|
|
21
27
|
// Timezone Component
|
|
@@ -54,8 +60,8 @@ function getTimezoneDisplayName(timezone) {
|
|
|
54
60
|
* </Timezone>
|
|
55
61
|
* ```
|
|
56
62
|
*/
|
|
57
|
-
|
|
58
|
-
const bookingService = useService(BookingServiceDefinition);
|
|
63
|
+
function Timezone(props) {
|
|
64
|
+
const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
|
|
59
65
|
const timezone = bookingService.timezone.get();
|
|
60
66
|
const displayName = getTimezoneDisplayName(timezone);
|
|
61
67
|
return props.children({ timezone, displayName });
|
|
@@ -76,9 +82,9 @@ export function Timezone(props) {
|
|
|
76
82
|
* </ListData>
|
|
77
83
|
* ```
|
|
78
84
|
*/
|
|
79
|
-
|
|
80
|
-
const service = useService(TimeSlotListServiceDefinition);
|
|
81
|
-
const bookingService = useService(BookingServiceDefinition);
|
|
85
|
+
function ListData(props) {
|
|
86
|
+
const service = (0, services_manager_react_1.useService)(index_js_1.TimeSlotListServiceDefinition);
|
|
87
|
+
const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
|
|
82
88
|
const selectedTimeSlot = bookingService.serviceSelections.get()[0]?.timeSlot;
|
|
83
89
|
return props.children({
|
|
84
90
|
timeSlots: service.timeSlots.get(),
|
|
@@ -107,9 +113,9 @@ export function ListData(props) {
|
|
|
107
113
|
* </DateRange>
|
|
108
114
|
* ```
|
|
109
115
|
*/
|
|
110
|
-
|
|
111
|
-
const service = useService(TimeSlotListServiceDefinition);
|
|
112
|
-
const bookingService = useService(BookingServiceDefinition);
|
|
116
|
+
function DateRange(props) {
|
|
117
|
+
const service = (0, services_manager_react_1.useService)(index_js_1.TimeSlotListServiceDefinition);
|
|
118
|
+
const bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
|
|
113
119
|
const dateRange = service.dateRange.get();
|
|
114
120
|
const timezone = bookingService.timezone.get();
|
|
115
121
|
return props.children({
|
package/cjs/dist/react/index.js
CHANGED
|
@@ -1,13 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Payment = exports.StaffMemberList = exports.StaffMember = exports.LocationList = exports.Location = exports.ServiceList = exports.TimeSlot = exports.TimeSlotList = exports.ServiceMedia = exports.Service = exports.BookingForm = exports.BookingItem = exports.Booking = void 0;
|
|
37
|
+
exports.Booking = __importStar(require("./booking/Booking.js"));
|
|
38
|
+
exports.BookingItem = __importStar(require("./booking/BookingItem.js"));
|
|
39
|
+
exports.BookingForm = __importStar(require("./booking-form/BookingForm.js"));
|
|
40
|
+
exports.Service = __importStar(require("./service/Service.js"));
|
|
41
|
+
exports.ServiceMedia = __importStar(require("./service/ServiceMedia.js"));
|
|
42
|
+
exports.TimeSlotList = __importStar(require("./time-slot-list/TimeSlotList.js"));
|
|
43
|
+
exports.TimeSlot = __importStar(require("./time-slot-list/TimeSlot.js"));
|
|
44
|
+
exports.ServiceList = __importStar(require("./service-list/ServiceList.js"));
|
|
45
|
+
exports.Location = __importStar(require("./location/Location.js"));
|
|
46
|
+
exports.LocationList = __importStar(require("./location/LocationList.js"));
|
|
47
|
+
exports.StaffMember = __importStar(require("./staff-member/StaffMember.js"));
|
|
48
|
+
exports.StaffMemberList = __importStar(require("./staff-member/StaffMemberList.js"));
|
|
49
|
+
exports.Payment = __importStar(require("./payment/Payment.js"));
|
|
@@ -1,20 +1,60 @@
|
|
|
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.Actions = exports.Raw = exports.Email = exports.Phone = exports.Address = exports.LocationAddress = exports.Type = exports.Name = exports.Root = exports.TestIds = exports.useLocationContext = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
41
|
/**
|
|
3
42
|
* Location - Headless component for displaying service location information
|
|
4
43
|
* Provides components for displaying location type, name, address, phone, email
|
|
5
44
|
*
|
|
6
45
|
* @module React/Location
|
|
7
46
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
47
|
+
const react_1 = __importDefault(require("react"));
|
|
48
|
+
const CoreLocation = __importStar(require("../core/location/Location.js"));
|
|
49
|
+
const react_2 = require("@wix/headless-utils/react");
|
|
50
|
+
const react_3 = require("@wix/headless-components/react");
|
|
12
51
|
// Re-export useLocationContext from core
|
|
13
|
-
|
|
52
|
+
var Location_js_1 = require("../core/location/Location.js");
|
|
53
|
+
Object.defineProperty(exports, "useLocationContext", { enumerable: true, get: function () { return Location_js_1.useLocationContext; } });
|
|
14
54
|
// ==========================================
|
|
15
55
|
// TestIds Enum
|
|
16
56
|
// ==========================================
|
|
17
|
-
|
|
57
|
+
exports.TestIds = {
|
|
18
58
|
locationRoot: 'location-root',
|
|
19
59
|
locationName: 'location-name',
|
|
20
60
|
locationType: 'location-type',
|
|
@@ -61,15 +101,15 @@ const useLocationContext = CoreLocation.useLocationContext;
|
|
|
61
101
|
* </Location.Root>
|
|
62
102
|
* ```
|
|
63
103
|
*/
|
|
64
|
-
|
|
104
|
+
exports.Root = react_1.default.forwardRef((props, ref) => {
|
|
65
105
|
const { location, asChild, children, className, ...attrs } = props;
|
|
66
106
|
// Extract data-* attributes
|
|
67
107
|
const dataAttrs = Object.fromEntries(Object.entries(attrs).filter(([key]) => key.startsWith('data-')));
|
|
68
108
|
// Note: customLocationLabel and customerLocationLabel are deprecated on Root.
|
|
69
109
|
// Use them on Location.Name instead for label fallbacks.
|
|
70
|
-
return (
|
|
110
|
+
return ((0, jsx_runtime_1.jsx)(CoreLocation.Root, { location: location, children: (0, jsx_runtime_1.jsx)(CoreLocation.Data, { children: (renderProps) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": exports.TestIds.locationRoot, "data-location-type": renderProps.locationType, customElement: children, customElementProps: renderProps, ...dataAttrs, children: children })) }) }));
|
|
71
111
|
});
|
|
72
|
-
Root.displayName = 'Location.Root';
|
|
112
|
+
exports.Root.displayName = 'Location.Root';
|
|
73
113
|
/**
|
|
74
114
|
* Displays the location name.
|
|
75
115
|
* The name is pre-computed with label fallbacks in CoreLocation.Root:
|
|
@@ -91,12 +131,12 @@ Root.displayName = 'Location.Root';
|
|
|
91
131
|
* </Location.Name>
|
|
92
132
|
* ```
|
|
93
133
|
*/
|
|
94
|
-
|
|
134
|
+
exports.Name = react_1.default.forwardRef((props, ref) => {
|
|
95
135
|
const { asChild, children, ...rest } = props;
|
|
96
136
|
const { name } = useLocationContext();
|
|
97
|
-
return (
|
|
137
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.locationName, customElement: children, customElementProps: { name: name ?? '' }, children: name ? (0, jsx_runtime_1.jsx)("span", { children: name }) : null }));
|
|
98
138
|
});
|
|
99
|
-
Name.displayName = 'Location.Name';
|
|
139
|
+
exports.Name.displayName = 'Location.Name';
|
|
100
140
|
/**
|
|
101
141
|
* Displays the location type.
|
|
102
142
|
*
|
|
@@ -115,16 +155,16 @@ Name.displayName = 'Location.Name';
|
|
|
115
155
|
* </Location.Type>
|
|
116
156
|
* ```
|
|
117
157
|
*/
|
|
118
|
-
|
|
158
|
+
exports.Type = react_1.default.forwardRef((props, ref) => {
|
|
119
159
|
const { asChild, children, ...rest } = props;
|
|
120
160
|
const { locationType, isCustomerLocation, isCustomLocation } = useLocationContext();
|
|
121
|
-
return (
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.locationType, customElement: children, customElementProps: {
|
|
122
162
|
locationType,
|
|
123
163
|
isCustomerLocation,
|
|
124
164
|
isCustomLocation,
|
|
125
|
-
}, children: locationType ?
|
|
165
|
+
}, children: locationType ? (0, jsx_runtime_1.jsx)("span", { children: locationType }) : null }));
|
|
126
166
|
});
|
|
127
|
-
Type.displayName = 'Location.Type';
|
|
167
|
+
exports.Type.displayName = 'Location.Type';
|
|
128
168
|
/**
|
|
129
169
|
* Displays the location address.
|
|
130
170
|
* Returns null for CUSTOMER locations (consumer provides label).
|
|
@@ -148,14 +188,13 @@ Type.displayName = 'Location.Type';
|
|
|
148
188
|
* </Location.Address>
|
|
149
189
|
* ```
|
|
150
190
|
*/
|
|
151
|
-
|
|
191
|
+
exports.LocationAddress = react_1.default.forwardRef((props, ref) => {
|
|
152
192
|
const { asChild, children, ...rest } = props;
|
|
153
193
|
const { address } = useLocationContext();
|
|
154
|
-
return (
|
|
194
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.locationAddress, customElement: children, customElementProps: { address }, children: address ? ((0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(react_3.Address.Root, { address: address, children: (0, jsx_runtime_1.jsx)(react_3.Address.Formatted, {}) }) })) : null }));
|
|
155
195
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
export { LocationAddress as Address };
|
|
196
|
+
exports.Address = exports.LocationAddress;
|
|
197
|
+
exports.LocationAddress.displayName = 'Location.Address';
|
|
159
198
|
/**
|
|
160
199
|
* Displays the location phone number.
|
|
161
200
|
* Only renders for BUSINESS locations (phone only exists on BusinessLocationOptions).
|
|
@@ -171,12 +210,12 @@ export { LocationAddress as Address };
|
|
|
171
210
|
* </Location.Phone>
|
|
172
211
|
* ```
|
|
173
212
|
*/
|
|
174
|
-
|
|
213
|
+
exports.Phone = react_1.default.forwardRef((props, ref) => {
|
|
175
214
|
const { asChild, children, ...rest } = props;
|
|
176
215
|
const { phone } = useLocationContext();
|
|
177
|
-
return (
|
|
216
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.locationPhone, customElement: children, customElementProps: { phone }, children: phone ? (0, jsx_runtime_1.jsx)("span", { children: phone }) : null }));
|
|
178
217
|
});
|
|
179
|
-
Phone.displayName = 'Location.Phone';
|
|
218
|
+
exports.Phone.displayName = 'Location.Phone';
|
|
180
219
|
/**
|
|
181
220
|
* Displays the location email address.
|
|
182
221
|
* Only renders for BUSINESS locations (email only exists on BusinessLocationOptions).
|
|
@@ -192,12 +231,12 @@ Phone.displayName = 'Location.Phone';
|
|
|
192
231
|
* </Location.Email>
|
|
193
232
|
* ```
|
|
194
233
|
*/
|
|
195
|
-
|
|
234
|
+
exports.Email = react_1.default.forwardRef((props, ref) => {
|
|
196
235
|
const { asChild, children, ...rest } = props;
|
|
197
236
|
const { email } = useLocationContext();
|
|
198
|
-
return (
|
|
237
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.locationEmail, customElement: children, customElementProps: { email }, children: email ? (0, jsx_runtime_1.jsx)("span", { children: email }) : null }));
|
|
199
238
|
});
|
|
200
|
-
Email.displayName = 'Location.Email';
|
|
239
|
+
exports.Email.displayName = 'Location.Email';
|
|
201
240
|
/**
|
|
202
241
|
* Exposes all raw location data via render prop.
|
|
203
242
|
* Use only when you need full access to location data.
|
|
@@ -212,11 +251,12 @@ Email.displayName = 'Location.Email';
|
|
|
212
251
|
* </Location.Raw>
|
|
213
252
|
* ```
|
|
214
253
|
*/
|
|
215
|
-
|
|
254
|
+
const Raw = (props) => {
|
|
216
255
|
const context = useLocationContext();
|
|
217
|
-
return
|
|
256
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props.children(context) });
|
|
218
257
|
};
|
|
219
|
-
Raw
|
|
258
|
+
exports.Raw = Raw;
|
|
259
|
+
exports.Raw.displayName = 'Location.Raw';
|
|
220
260
|
/**
|
|
221
261
|
* Selection action component for choosing a location.
|
|
222
262
|
* Sets the location in BookingService when clicked (like Service.Actions.Select).
|
|
@@ -242,26 +282,26 @@ Raw.displayName = 'Location.Raw';
|
|
|
242
282
|
* </Location.Actions.Select>
|
|
243
283
|
* ```
|
|
244
284
|
*/
|
|
245
|
-
const Select =
|
|
285
|
+
const Select = react_1.default.forwardRef((props, ref) => {
|
|
246
286
|
const { asChild, children, onClick, label, className, ...rest } = props;
|
|
247
|
-
return (
|
|
287
|
+
return ((0, jsx_runtime_1.jsx)(CoreLocation.Actions, { children: ({ select, selected, rawLocation }) => {
|
|
248
288
|
const handleClick = () => {
|
|
249
289
|
select();
|
|
250
290
|
if (rawLocation) {
|
|
251
291
|
onClick?.(rawLocation);
|
|
252
292
|
}
|
|
253
293
|
};
|
|
254
|
-
return (
|
|
294
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": exports.TestIds.locationActionSelect, "data-selected": selected, customElement: children, customElementProps: {
|
|
255
295
|
onClick: handleClick,
|
|
256
296
|
selected,
|
|
257
297
|
location: rawLocation,
|
|
258
|
-
}, children:
|
|
298
|
+
}, children: (0, jsx_runtime_1.jsx)("button", { onClick: handleClick, children: children || label }) }));
|
|
259
299
|
} }));
|
|
260
300
|
});
|
|
261
301
|
Select.displayName = 'Location.Actions.Select';
|
|
262
302
|
/**
|
|
263
303
|
* Actions namespace for location-related actions
|
|
264
304
|
*/
|
|
265
|
-
|
|
305
|
+
exports.Actions = {
|
|
266
306
|
Select,
|
|
267
307
|
};
|