@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,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.Actions = exports.Totals = exports.LocationRepeater = exports.Locations = exports.Root = exports.TestIds = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
41
|
/**
|
|
3
42
|
* LocationList - High-level component for displaying locations list
|
|
4
43
|
* Follows the pattern from ServiceList.tsx
|
|
5
44
|
*
|
|
6
45
|
* @module React/LocationList
|
|
7
46
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
47
|
+
const react_1 = __importDefault(require("react"));
|
|
48
|
+
const react_2 = require("@wix/headless-components/react");
|
|
49
|
+
const react_3 = require("@wix/headless-utils/react");
|
|
50
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
51
|
+
const booking_js_1 = require("../../services/booking/booking.js");
|
|
52
|
+
const CoreLocationList = __importStar(require("../core/location-list/LocationList.js"));
|
|
53
|
+
const LocationComponent = __importStar(require("./Location.js"));
|
|
15
54
|
// ============================================================================
|
|
16
55
|
// Helper Functions
|
|
17
56
|
// ============================================================================
|
|
@@ -37,7 +76,7 @@ function getLocationType(location) {
|
|
|
37
76
|
// ============================================================================
|
|
38
77
|
// TestIds
|
|
39
78
|
// ============================================================================
|
|
40
|
-
|
|
79
|
+
exports.TestIds = {
|
|
41
80
|
locationListRoot: 'location-list-root',
|
|
42
81
|
locationListLocations: 'location-list-locations',
|
|
43
82
|
locationListLocation: 'location-list-location',
|
|
@@ -66,7 +105,7 @@ export const TestIds = {
|
|
|
66
105
|
* }
|
|
67
106
|
* ```
|
|
68
107
|
*/
|
|
69
|
-
|
|
108
|
+
exports.Root = react_1.default.forwardRef((props, ref) => {
|
|
70
109
|
const { children, locationListConfig, className, variant, customLocationLabel, customerLocationLabel, } = props;
|
|
71
110
|
// Merge labels into service config
|
|
72
111
|
const config = {
|
|
@@ -74,15 +113,15 @@ export const Root = React.forwardRef((props, ref) => {
|
|
|
74
113
|
customLocationLabel,
|
|
75
114
|
customerLocationLabel,
|
|
76
115
|
};
|
|
77
|
-
return (
|
|
116
|
+
return ((0, jsx_runtime_1.jsx)(CoreLocationList.Root, { locationListServiceConfig: config, children: (0, jsx_runtime_1.jsx)(RootContent, { className: className, ref: ref, variant: variant, children: children }) }));
|
|
78
117
|
});
|
|
79
|
-
Root.displayName = 'LocationList.Root';
|
|
118
|
+
exports.Root.displayName = 'LocationList.Root';
|
|
80
119
|
/**
|
|
81
120
|
* Internal component to handle the Root content with service access
|
|
82
121
|
*/
|
|
83
|
-
const RootContent =
|
|
122
|
+
const RootContent = react_1.default.forwardRef((props, ref) => {
|
|
84
123
|
const { children, className, variant } = props;
|
|
85
|
-
return (
|
|
124
|
+
return ((0, jsx_runtime_1.jsx)(CoreLocationList.Locations, { children: ({ displayLocations, isLoading }) => ((0, jsx_runtime_1.jsx)(react_2.GenericList.Root, { items: displayLocations, hasMore: false, isLoading: isLoading, className: className, ref: ref, "data-testid": exports.TestIds.locationListRoot, variant: variant, children: children })) }));
|
|
86
125
|
});
|
|
87
126
|
RootContent.displayName = 'LocationList.RootContent';
|
|
88
127
|
/**
|
|
@@ -100,12 +139,12 @@ RootContent.displayName = 'LocationList.RootContent';
|
|
|
100
139
|
* </LocationList.Locations>
|
|
101
140
|
* ```
|
|
102
141
|
*/
|
|
103
|
-
|
|
142
|
+
exports.Locations = react_1.default.forwardRef((props, ref) => {
|
|
104
143
|
const { children, ...otherProps } = props;
|
|
105
|
-
return (
|
|
144
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Items, { ref: ref, "data-testid": exports.TestIds.locationListLocations, ...otherProps, children: children }));
|
|
106
145
|
});
|
|
107
|
-
Locations.displayName = 'LocationList.Locations';
|
|
108
|
-
|
|
146
|
+
exports.Locations.displayName = 'LocationList.Locations';
|
|
147
|
+
exports.LocationRepeater = react_1.default.forwardRef((props, ref) => {
|
|
109
148
|
const { children } = props;
|
|
110
149
|
// Custom itemWrapper that wraps each item in LocationComponent.Root
|
|
111
150
|
// Note: Labels are now handled by Location.Name component, not here
|
|
@@ -113,11 +152,11 @@ export const LocationRepeater = React.forwardRef((props, ref) => {
|
|
|
113
152
|
const locationId = getLocationId(item);
|
|
114
153
|
const locationType = getLocationType(item);
|
|
115
154
|
const isSynthetic = !hasLocationData(item);
|
|
116
|
-
return (
|
|
155
|
+
return ((0, jsx_runtime_1.jsx)(LocationComponent.Root, { location: item, "data-testid": exports.TestIds.locationListLocation, "data-location-id": locationId, "data-location-type": locationType, "data-synthetic": isSynthetic, "data-item-id": locationId, children: itemChildren }, locationId));
|
|
117
156
|
};
|
|
118
|
-
return (
|
|
157
|
+
return ((0, jsx_runtime_1.jsx)(react_2.GenericList.Repeater, { ref: ref, itemWrapper: locationItemWrapper, children: children }));
|
|
119
158
|
});
|
|
120
|
-
LocationRepeater.displayName = 'LocationList.LocationRepeater';
|
|
159
|
+
exports.LocationRepeater.displayName = 'LocationList.LocationRepeater';
|
|
121
160
|
/**
|
|
122
161
|
* Displays the total count of locations.
|
|
123
162
|
*
|
|
@@ -132,14 +171,14 @@ LocationRepeater.displayName = 'LocationList.LocationRepeater';
|
|
|
132
171
|
* </LocationList.Totals>
|
|
133
172
|
* ```
|
|
134
173
|
*/
|
|
135
|
-
|
|
174
|
+
exports.Totals = react_1.default.forwardRef((props, ref) => {
|
|
136
175
|
const { asChild, children, ...rest } = props;
|
|
137
|
-
return (
|
|
176
|
+
return ((0, jsx_runtime_1.jsx)(CoreLocationList.Locations, { children: ({ displayLocations, hasLocations }) => {
|
|
138
177
|
const count = displayLocations.length;
|
|
139
|
-
return (
|
|
178
|
+
return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.locationListTotals, customElement: children, customElementProps: { count, hasLocations }, children: (0, jsx_runtime_1.jsx)("span", { children: count }) }));
|
|
140
179
|
} }));
|
|
141
180
|
});
|
|
142
|
-
Totals.displayName = 'LocationList.Totals';
|
|
181
|
+
exports.Totals.displayName = 'LocationList.Totals';
|
|
143
182
|
/**
|
|
144
183
|
* Button to clear the location selection.
|
|
145
184
|
* Clears the location from the BookingService.
|
|
@@ -169,12 +208,12 @@ Totals.displayName = 'LocationList.Totals';
|
|
|
169
208
|
* </LocationList.Actions.Clear>
|
|
170
209
|
* ```
|
|
171
210
|
*/
|
|
172
|
-
const Clear =
|
|
211
|
+
const Clear = react_1.default.forwardRef((props, ref) => {
|
|
173
212
|
const { asChild, children, className, label, onClick, ...rest } = props;
|
|
174
|
-
return (
|
|
213
|
+
return ((0, jsx_runtime_1.jsx)(CoreLocationList.Actions, { children: ({ selectedLocation }) => {
|
|
175
214
|
let bookingService = null;
|
|
176
215
|
try {
|
|
177
|
-
bookingService = useService(BookingServiceDefinition);
|
|
216
|
+
bookingService = (0, services_manager_react_1.useService)(booking_js_1.BookingServiceDefinition);
|
|
178
217
|
}
|
|
179
218
|
catch {
|
|
180
219
|
// BookingService not available - likely no ServiceManagerProvider
|
|
@@ -183,15 +222,15 @@ const Clear = React.forwardRef((props, ref) => {
|
|
|
183
222
|
bookingService?.actions.clearLocation();
|
|
184
223
|
onClick?.(selectedLocation);
|
|
185
224
|
};
|
|
186
|
-
return (
|
|
225
|
+
return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, ...rest, className: className, "data-testid": exports.TestIds.locationListActionClear, customElement: children, customElementProps: {
|
|
187
226
|
onClick: handleClick,
|
|
188
|
-
}, children:
|
|
227
|
+
}, children: (0, jsx_runtime_1.jsx)("button", { onClick: handleClick, children: children || label }) }));
|
|
189
228
|
} }));
|
|
190
229
|
});
|
|
191
230
|
Clear.displayName = 'LocationList.Actions.Clear';
|
|
192
231
|
/**
|
|
193
232
|
* Actions namespace for location list-level actions
|
|
194
233
|
*/
|
|
195
|
-
|
|
234
|
+
exports.Actions = {
|
|
196
235
|
Clear,
|
|
197
236
|
};
|
|
@@ -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.LineItemDeposit = exports.LineItemSubtotal = exports.LineItemTotal = exports.LineItemRepeater = exports.LineItemsList = exports.LineItems = exports.PayLater = exports.PayNow = exports.Total = exports.Tax = exports.Subtotal = exports.Root = exports.TestIds = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
41
|
/**
|
|
3
42
|
* Payment - High-level component for displaying payment information
|
|
4
43
|
* Provides components for displaying payment summary, totals, and line items
|
|
5
44
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
45
|
+
const react_1 = __importDefault(require("react"));
|
|
46
|
+
const CorePayment = __importStar(require("../core/payment/Payment.js"));
|
|
47
|
+
const react_2 = require("@wix/headless-utils/react");
|
|
48
|
+
const react_3 = require("@wix/headless-components/react");
|
|
49
|
+
exports.TestIds = {
|
|
11
50
|
paymentRoot: 'payment-root',
|
|
12
51
|
paymentSubtotal: 'payment-subtotal',
|
|
13
52
|
paymentTax: 'payment-tax',
|
|
@@ -53,13 +92,13 @@ export const TestIds = {
|
|
|
53
92
|
* }
|
|
54
93
|
* ```
|
|
55
94
|
*/
|
|
56
|
-
|
|
95
|
+
exports.Root = react_1.default.forwardRef((props, ref) => {
|
|
57
96
|
const { children, paymentServiceConfig, pricingServiceSelections, totalParticipants, asChild, className, ...attrs } = props;
|
|
58
|
-
return (
|
|
59
|
-
return (
|
|
97
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.Root, { paymentServiceConfig: paymentServiceConfig, pricingServiceSelections: pricingServiceSelections, totalParticipants: totalParticipants, children: ({ isLoading, hasError }) => {
|
|
98
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": exports.TestIds.paymentRoot, "data-loading": isLoading, "data-has-error": hasError, customElement: children, customElementProps: { isLoading, hasError }, ...attrs, children: children }));
|
|
60
99
|
} }));
|
|
61
100
|
});
|
|
62
|
-
Root.displayName = 'Payment.Root';
|
|
101
|
+
exports.Root.displayName = 'Payment.Root';
|
|
63
102
|
/**
|
|
64
103
|
* Displays the payment subtotal.
|
|
65
104
|
* Always displays the monetary value. Exposes customPrice for custom rendering.
|
|
@@ -80,14 +119,14 @@ Root.displayName = 'Payment.Root';
|
|
|
80
119
|
* </Payment.Subtotal>
|
|
81
120
|
* ```
|
|
82
121
|
*/
|
|
83
|
-
|
|
122
|
+
exports.Subtotal = react_1.default.forwardRef((props, ref) => {
|
|
84
123
|
const { asChild, children, className } = props;
|
|
85
|
-
return (
|
|
124
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.Data, { children: ({ subtotal, customPrice }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: {
|
|
86
125
|
subtotal,
|
|
87
126
|
customPrice,
|
|
88
|
-
}, "data-testid": TestIds.paymentSubtotal, "data-has-custom-price": !!customPrice, children: subtotal &&
|
|
127
|
+
}, "data-testid": exports.TestIds.paymentSubtotal, "data-has-custom-price": !!customPrice, children: subtotal && (0, jsx_runtime_1.jsx)(react_3.Money, { money: subtotal }) })) }));
|
|
89
128
|
});
|
|
90
|
-
Subtotal.displayName = 'Payment.Subtotal';
|
|
129
|
+
exports.Subtotal.displayName = 'Payment.Subtotal';
|
|
91
130
|
/**
|
|
92
131
|
* Displays the payment tax.
|
|
93
132
|
* Uses data-has-tax attribute for conditional visibility.
|
|
@@ -98,11 +137,11 @@ Subtotal.displayName = 'Payment.Subtotal';
|
|
|
98
137
|
* <Payment.Tax className="text-secondary-foreground" />
|
|
99
138
|
* ```
|
|
100
139
|
*/
|
|
101
|
-
|
|
140
|
+
exports.Tax = react_1.default.forwardRef((props, ref) => {
|
|
102
141
|
const { asChild, children, className } = props;
|
|
103
|
-
return (
|
|
142
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.Data, { children: ({ tax, hasTax }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { tax }, "data-testid": exports.TestIds.paymentTax, "data-has-tax": hasTax, children: hasTax && (0, jsx_runtime_1.jsx)(react_3.Money, { money: tax }) })) }));
|
|
104
143
|
});
|
|
105
|
-
Tax.displayName = 'Payment.Tax';
|
|
144
|
+
exports.Tax.displayName = 'Payment.Tax';
|
|
106
145
|
/**
|
|
107
146
|
* Displays the payment total.
|
|
108
147
|
* Always displays the monetary value. Exposes customPrice for custom rendering.
|
|
@@ -123,14 +162,14 @@ Tax.displayName = 'Payment.Tax';
|
|
|
123
162
|
* </Payment.Total>
|
|
124
163
|
* ```
|
|
125
164
|
*/
|
|
126
|
-
|
|
165
|
+
exports.Total = react_1.default.forwardRef((props, ref) => {
|
|
127
166
|
const { asChild, children, className } = props;
|
|
128
|
-
return (
|
|
167
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.Data, { children: ({ total, customPrice }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: {
|
|
129
168
|
total,
|
|
130
169
|
customPrice,
|
|
131
|
-
}, "data-testid": TestIds.paymentTotal, "data-has-custom-price": !!customPrice, children: total &&
|
|
170
|
+
}, "data-testid": exports.TestIds.paymentTotal, "data-has-custom-price": !!customPrice, children: total && (0, jsx_runtime_1.jsx)(react_3.Money, { money: total }) })) }));
|
|
132
171
|
});
|
|
133
|
-
Total.displayName = 'Payment.Total';
|
|
172
|
+
exports.Total.displayName = 'Payment.Total';
|
|
134
173
|
/**
|
|
135
174
|
* Displays the pay now amount (amount to pay upfront in deposit scenarios).
|
|
136
175
|
* Only renders in deposit mode when payNow has a valid amount.
|
|
@@ -141,11 +180,11 @@ Total.displayName = 'Payment.Total';
|
|
|
141
180
|
* <Payment.PayNow className="font-semibold" />
|
|
142
181
|
* ```
|
|
143
182
|
*/
|
|
144
|
-
|
|
183
|
+
exports.PayNow = react_1.default.forwardRef((props, ref) => {
|
|
145
184
|
const { asChild, children, className } = props;
|
|
146
|
-
return (
|
|
185
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.Data, { children: ({ payNow, isDeposit }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { payNow, isDeposit }, "data-testid": exports.TestIds.paymentPayNow, "data-has-deposit": isDeposit, children: isDeposit && payNow && payNow.amount > 0 && ((0, jsx_runtime_1.jsx)(react_3.Money, { money: payNow })) })) }));
|
|
147
186
|
});
|
|
148
|
-
PayNow.displayName = 'Payment.PayNow';
|
|
187
|
+
exports.PayNow.displayName = 'Payment.PayNow';
|
|
149
188
|
/**
|
|
150
189
|
* Displays the pay later amount (for deposit scenarios).
|
|
151
190
|
* Only renders when in deposit mode and payLater has a valid amount.
|
|
@@ -156,11 +195,11 @@ PayNow.displayName = 'Payment.PayNow';
|
|
|
156
195
|
* <Payment.PayLater className="text-secondary-foreground" />
|
|
157
196
|
* ```
|
|
158
197
|
*/
|
|
159
|
-
|
|
198
|
+
exports.PayLater = react_1.default.forwardRef((props, ref) => {
|
|
160
199
|
const { asChild, children, className } = props;
|
|
161
|
-
return (
|
|
200
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.Data, { children: ({ payLater, isDeposit }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { payLater, isDeposit }, "data-testid": exports.TestIds.paymentPayLater, "data-has-deposit": isDeposit, children: isDeposit && payLater && payLater.amount > 0 && ((0, jsx_runtime_1.jsx)(react_3.Money, { money: payLater })) })) }));
|
|
162
201
|
});
|
|
163
|
-
PayLater.displayName = 'Payment.PayLater';
|
|
202
|
+
exports.PayLater.displayName = 'Payment.PayLater';
|
|
164
203
|
/**
|
|
165
204
|
* Container component for line items.
|
|
166
205
|
* Follows the 3-level List/Options/Repeater pattern.
|
|
@@ -182,15 +221,15 @@ PayLater.displayName = 'Payment.PayLater';
|
|
|
182
221
|
* </Payment.LineItems>
|
|
183
222
|
* ```
|
|
184
223
|
*/
|
|
185
|
-
|
|
224
|
+
exports.LineItems = react_1.default.forwardRef((props, ref) => {
|
|
186
225
|
const { asChild, children, className, ...rest } = props;
|
|
187
|
-
return (
|
|
226
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.LineItems, { children: ({ lineItems, currency, isLoading, error }) => ((0, jsx_runtime_1.jsx)(react_3.GenericList.Root, { items: lineItems, isLoading: isLoading, error: error, children: (0, jsx_runtime_1.jsx)(LineItemsContext.Provider, { value: { currency }, children: (0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ...rest, ref: ref, asChild: asChild, className: className, "data-testid": exports.TestIds.paymentLineItems, "data-loading": isLoading, "data-error": !!error, customElement: children, customElementProps: { lineItems, currency, isLoading, error }, children: (0, jsx_runtime_1.jsx)("div", { children: react_1.default.isValidElement(children) ? children : null }) }) }) })) }));
|
|
188
227
|
});
|
|
189
|
-
LineItems.displayName = 'Payment.LineItems';
|
|
228
|
+
exports.LineItems.displayName = 'Payment.LineItems';
|
|
190
229
|
// Context for line items currency
|
|
191
|
-
const LineItemsContext =
|
|
230
|
+
const LineItemsContext = react_1.default.createContext(null);
|
|
192
231
|
function useLineItemsContext() {
|
|
193
|
-
const context =
|
|
232
|
+
const context = react_1.default.useContext(LineItemsContext);
|
|
194
233
|
if (!context) {
|
|
195
234
|
throw new Error('useLineItemsContext must be used within a Payment.LineItems component');
|
|
196
235
|
}
|
|
@@ -211,16 +250,16 @@ function useLineItemsContext() {
|
|
|
211
250
|
* </Payment.LineItemsList>
|
|
212
251
|
* ```
|
|
213
252
|
*/
|
|
214
|
-
|
|
253
|
+
exports.LineItemsList = react_1.default.forwardRef((props, ref) => {
|
|
215
254
|
const { children, emptyState, loadingState, errorState, className, ...otherProps } = props;
|
|
216
|
-
return (
|
|
255
|
+
return ((0, jsx_runtime_1.jsx)(react_3.GenericList.Items, { ref: ref, emptyState: emptyState, loadingState: loadingState, errorState: errorState, className: className, "data-testid": exports.TestIds.paymentLineItemsList, ...otherProps, children: children }));
|
|
217
256
|
});
|
|
218
|
-
LineItemsList.displayName = 'Payment.LineItemsList';
|
|
257
|
+
exports.LineItemsList.displayName = 'Payment.LineItemsList';
|
|
219
258
|
/**
|
|
220
259
|
* Internal component that wraps each line item with context provider.
|
|
221
260
|
*/
|
|
222
261
|
const LineItemWrapper = ({ item, currency, children, }) => {
|
|
223
|
-
return (
|
|
262
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.LineItemProvider, { lineItem: item, currency: currency, children: children }));
|
|
224
263
|
};
|
|
225
264
|
/**
|
|
226
265
|
* Repeater component that maps over line items and provides context per item.
|
|
@@ -234,12 +273,12 @@ const LineItemWrapper = ({ item, currency, children, }) => {
|
|
|
234
273
|
* </Payment.LineItemRepeater>
|
|
235
274
|
* ```
|
|
236
275
|
*/
|
|
237
|
-
|
|
276
|
+
exports.LineItemRepeater = react_1.default.forwardRef((props, ref) => {
|
|
238
277
|
const { children } = props;
|
|
239
278
|
const { currency } = useLineItemsContext();
|
|
240
|
-
return (
|
|
279
|
+
return ((0, jsx_runtime_1.jsx)(react_3.GenericList.Repeater, { ref: ref, itemWrapper: ({ item }) => ((0, jsx_runtime_1.jsx)(LineItemWrapper, { item: item, currency: currency, children: children }, item.id)), children: undefined }));
|
|
241
280
|
});
|
|
242
|
-
LineItemRepeater.displayName = 'Payment.LineItemRepeater';
|
|
281
|
+
exports.LineItemRepeater.displayName = 'Payment.LineItemRepeater';
|
|
243
282
|
/**
|
|
244
283
|
* Displays the line item total (total price after tax).
|
|
245
284
|
* Shows customPrice for CUSTOM rate type services, otherwise shows totalPrice.
|
|
@@ -250,11 +289,11 @@ LineItemRepeater.displayName = 'Payment.LineItemRepeater';
|
|
|
250
289
|
* <Payment.LineItemTotal className="text-2xl font-bold" />
|
|
251
290
|
* ```
|
|
252
291
|
*/
|
|
253
|
-
|
|
292
|
+
exports.LineItemTotal = react_1.default.forwardRef((props, ref) => {
|
|
254
293
|
const { asChild, children, ...rest } = props;
|
|
255
|
-
return (
|
|
294
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.LineItemInfo, { children: ({ totalPrice, customPrice }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.paymentLineItemTotal, "data-has-custom-price": !!customPrice, customElement: children, customElementProps: { totalPrice, customPrice }, children: customPrice ? ((0, jsx_runtime_1.jsx)("span", { children: customPrice })) : (totalPrice && (0, jsx_runtime_1.jsx)(react_3.Money, { money: totalPrice })) })) }));
|
|
256
295
|
});
|
|
257
|
-
LineItemTotal.displayName = 'Payment.LineItemTotal';
|
|
296
|
+
exports.LineItemTotal.displayName = 'Payment.LineItemTotal';
|
|
258
297
|
/**
|
|
259
298
|
* Displays the line item subtotal (full price before discounts).
|
|
260
299
|
* Shows customPrice for CUSTOM rate type services, otherwise shows subtotal.
|
|
@@ -265,11 +304,11 @@ LineItemTotal.displayName = 'Payment.LineItemTotal';
|
|
|
265
304
|
* <Payment.LineItemSubtotal className="text-lg" />
|
|
266
305
|
* ```
|
|
267
306
|
*/
|
|
268
|
-
|
|
307
|
+
exports.LineItemSubtotal = react_1.default.forwardRef((props, ref) => {
|
|
269
308
|
const { asChild, children, ...rest } = props;
|
|
270
|
-
return (
|
|
309
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.LineItemInfo, { children: ({ subtotal, customPrice }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.paymentLineItemSubtotal, "data-has-custom-price": !!customPrice, customElement: children, customElementProps: { subtotal, customPrice }, children: customPrice ? ((0, jsx_runtime_1.jsx)("span", { children: customPrice })) : (subtotal && (0, jsx_runtime_1.jsx)(react_3.Money, { money: subtotal })) })) }));
|
|
271
310
|
});
|
|
272
|
-
LineItemSubtotal.displayName = 'Payment.LineItemSubtotal';
|
|
311
|
+
exports.LineItemSubtotal.displayName = 'Payment.LineItemSubtotal';
|
|
273
312
|
/**
|
|
274
313
|
* Displays the line item deposit amount.
|
|
275
314
|
* Uses data-has-deposit attribute for conditional visibility.
|
|
@@ -280,8 +319,8 @@ LineItemSubtotal.displayName = 'Payment.LineItemSubtotal';
|
|
|
280
319
|
* <Payment.LineItemDeposit className="font-semibold" />
|
|
281
320
|
* ```
|
|
282
321
|
*/
|
|
283
|
-
|
|
322
|
+
exports.LineItemDeposit = react_1.default.forwardRef((props, ref) => {
|
|
284
323
|
const { asChild, children, className } = props;
|
|
285
|
-
return (
|
|
324
|
+
return ((0, jsx_runtime_1.jsx)(CorePayment.LineItemInfo, { children: ({ deposit, hasDeposit }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, customElement: children, customElementProps: { deposit }, "data-testid": exports.TestIds.paymentLineItemDeposit, "data-has-deposit": hasDeposit, children: hasDeposit && (0, jsx_runtime_1.jsx)(react_3.Money, { money: deposit }) })) }));
|
|
286
325
|
});
|
|
287
|
-
LineItemDeposit.displayName = 'Payment.LineItemDeposit';
|
|
326
|
+
exports.LineItemDeposit.displayName = 'Payment.LineItemDeposit';
|