@wix/headless-bookings 0.0.88 → 0.0.90

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.
Files changed (53) hide show
  1. package/cjs/dist/react/booking/Book.d.ts +11 -19
  2. package/cjs/dist/react/booking/Book.js +17 -13
  3. package/cjs/dist/react/booking/Booking.d.ts +1 -1
  4. package/cjs/dist/react/booking/Booking.js +1 -1
  5. package/cjs/dist/react/booking-form/BookingForm.d.ts +5 -2
  6. package/cjs/dist/react/booking-form/BookingForm.js +3 -2
  7. package/cjs/dist/react/core/payment/Payment.d.ts +3 -3
  8. package/cjs/dist/react/core/payment/Payment.js +4 -4
  9. package/cjs/dist/react/location/Location.d.ts +3 -4
  10. package/cjs/dist/react/location/Location.js +6 -6
  11. package/cjs/dist/react/location/LocationList.d.ts +2 -4
  12. package/cjs/dist/react/location/LocationList.js +22 -15
  13. package/cjs/dist/react/payment/Payment.d.ts +3 -46
  14. package/cjs/dist/react/payment/Payment.js +4 -37
  15. package/cjs/dist/react/service/Service.d.ts +18 -33
  16. package/cjs/dist/react/service/Service.js +20 -33
  17. package/cjs/dist/react/staff-member/StaffMember.d.ts +9 -4
  18. package/cjs/dist/react/staff-member/StaffMember.js +7 -7
  19. package/cjs/dist/react/staff-member/StaffMemberList.d.ts +9 -4
  20. package/cjs/dist/react/staff-member/StaffMemberList.js +23 -16
  21. package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +17 -21
  22. package/cjs/dist/react/time-slot-list/TimeSlot.js +18 -22
  23. package/cjs/dist/services/booking/book-action/types.d.ts +3 -3
  24. package/cjs/dist/services/payment/payment.d.ts +2 -2
  25. package/cjs/dist/services/payment/payment.def.d.ts +1 -1
  26. package/cjs/dist/services/payment/payment.js +11 -11
  27. package/dist/react/booking/Book.d.ts +11 -19
  28. package/dist/react/booking/Book.js +17 -13
  29. package/dist/react/booking/Booking.d.ts +1 -1
  30. package/dist/react/booking/Booking.js +1 -1
  31. package/dist/react/booking-form/BookingForm.d.ts +5 -2
  32. package/dist/react/booking-form/BookingForm.js +3 -2
  33. package/dist/react/core/payment/Payment.d.ts +3 -3
  34. package/dist/react/core/payment/Payment.js +4 -4
  35. package/dist/react/location/Location.d.ts +3 -4
  36. package/dist/react/location/Location.js +6 -6
  37. package/dist/react/location/LocationList.d.ts +2 -4
  38. package/dist/react/location/LocationList.js +22 -15
  39. package/dist/react/payment/Payment.d.ts +3 -46
  40. package/dist/react/payment/Payment.js +4 -37
  41. package/dist/react/service/Service.d.ts +18 -33
  42. package/dist/react/service/Service.js +20 -33
  43. package/dist/react/staff-member/StaffMember.d.ts +9 -4
  44. package/dist/react/staff-member/StaffMember.js +7 -7
  45. package/dist/react/staff-member/StaffMemberList.d.ts +9 -4
  46. package/dist/react/staff-member/StaffMemberList.js +23 -16
  47. package/dist/react/time-slot-list/TimeSlot.d.ts +17 -21
  48. package/dist/react/time-slot-list/TimeSlot.js +18 -22
  49. package/dist/services/booking/book-action/types.d.ts +3 -3
  50. package/dist/services/payment/payment.d.ts +2 -2
  51. package/dist/services/payment/payment.def.d.ts +1 -1
  52. package/dist/services/payment/payment.js +11 -11
  53. package/package.json +2 -2
@@ -159,11 +159,9 @@ Duration.displayName = 'TimeSlot.Duration';
159
159
  * <button className="btn-primary">Book this slot</button>
160
160
  * </TimeSlot.Actions.Select>
161
161
  *
162
- * // With onClicked callback for navigation
162
+ * // With onClick callback
163
163
  * <TimeSlot.Actions.Select
164
- * onClicked={(timeSlot) => {
165
- * router.push(`/booking/confirm/${timeSlot.localStartDate}`);
166
- * }}
164
+ * onClick={() => router.push('/booking/confirm')}
167
165
  * />
168
166
  *
169
167
  * // Using render prop pattern
@@ -177,18 +175,19 @@ Duration.displayName = 'TimeSlot.Duration';
177
175
  * ```
178
176
  */
179
177
  export const Select = React.forwardRef((props, ref) => {
180
- const { asChild, children, className, label = 'Select', onClicked } = props;
181
- return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, isSelected, bookable, timeSlot }) => {
178
+ const { asChild, children, className, label, onClick, ...buttonProps } = props;
179
+ return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, timeSlot, isSelected, bookable }) => {
182
180
  const handleClick = () => {
183
181
  selectTimeSlot();
184
- onClicked?.(timeSlot);
182
+ onClick?.(timeSlot);
185
183
  };
186
184
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionSelect, "data-selected": isSelected, "data-bookable": bookable, customElement: children, customElementProps: {
187
185
  onClick: handleClick,
188
186
  disabled: !bookable,
189
187
  isSelected,
190
188
  bookable,
191
- }, children: _jsx("button", { onClick: handleClick, disabled: !bookable, children: children || label }) }));
189
+ timeSlot,
190
+ }, children: _jsx("button", { ...buttonProps, onClick: handleClick, disabled: !bookable, children: children || label }) }));
192
191
  } }));
193
192
  });
194
193
  Select.displayName = 'TimeSlot.Actions.Select';
@@ -211,11 +210,9 @@ Select.displayName = 'TimeSlot.Actions.Select';
211
210
  * <button className="btn-secondary">Clear staff</button>
212
211
  * </TimeSlot.Actions.ClearStaffSelection>
213
212
  *
214
- * // With onClicked callback
213
+ * // With onClick callback
215
214
  * <TimeSlot.Actions.ClearStaffSelection
216
- * onClicked={(timeSlot) => {
217
- * console.log('Staff selection cleared for', timeSlot.localStartDate);
218
- * }}
215
+ * onClick={() => console.log('Staff selection cleared')}
219
216
  * />
220
217
  *
221
218
  * // Using render prop pattern
@@ -225,18 +222,18 @@ Select.displayName = 'TimeSlot.Actions.Select';
225
222
  * ```
226
223
  */
227
224
  export const ClearStaffSelection = React.forwardRef((props, ref) => {
228
- const { asChild, children, className, label = 'Change', onClicked } = props;
225
+ const { asChild, children, className, label, onClick, ...buttonProps } = props;
229
226
  return (_jsx(CoreTimeSlot.Actions, { children: ({ clearStaffSelection, timeSlot }) => {
230
227
  if (!clearStaffSelection) {
231
228
  return null;
232
229
  }
233
230
  const handleClick = () => {
234
231
  clearStaffSelection();
235
- onClicked?.(timeSlot);
232
+ onClick?.(timeSlot);
236
233
  };
237
234
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionClearStaffSelection, customElement: children, customElementProps: {
238
235
  onClick: handleClick,
239
- }, children: _jsx("button", { onClick: handleClick, children: label }) }));
236
+ }, children: _jsx("button", { ...buttonProps, onClick: handleClick, children: children || label }) }));
240
237
  } }));
241
238
  });
242
239
  ClearStaffSelection.displayName = 'TimeSlot.Actions.ClearStaffSelection';
@@ -366,11 +363,9 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
366
363
  * <button className="btn-primary">Choose Staff</button>
367
364
  * </TimeSlot.StaffMember.Actions.Select>
368
365
  *
369
- * // With onClicked callback
366
+ * // With onClick callback
370
367
  * <TimeSlot.StaffMember.Actions.Select
371
- * onClicked={(staffMember) => {
372
- * console.log('Selected staff:', staffMember.name);
373
- * }}
368
+ * onClick={() => console.log('Staff selected')}
374
369
  * />
375
370
  *
376
371
  * // Using render prop pattern
@@ -384,16 +379,17 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
384
379
  * ```
385
380
  */
386
381
  export const SelectStaffMember = React.forwardRef((props, ref) => {
387
- const { asChild, children, className, label = 'Select', onClicked } = props;
382
+ const { asChild, children, className, label, onClick, ...buttonProps } = props;
388
383
  return (_jsx(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected, staffMember }) => {
389
384
  const handleClick = () => {
390
385
  selectStaffMember();
391
- onClicked?.(staffMember);
386
+ onClick?.(staffMember);
392
387
  };
393
388
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
394
389
  onClick: handleClick,
395
390
  isSelected,
396
- }, children: _jsx("button", { onClick: handleClick, children: label }) }));
391
+ staffMember,
392
+ }, children: _jsx("button", { ...buttonProps, onClick: handleClick, children: children || label }) }));
397
393
  } }));
398
394
  });
399
395
  SelectStaffMember.displayName = 'TimeSlot.StaffMember.Actions.Select';
@@ -62,9 +62,9 @@ export interface BookProps {
62
62
  * The navigateToCheckout function has the checkoutId captured - just call it.
63
63
  * When navigateToCheckout is called, the button will show loading state until navigation completes.
64
64
  */
65
- onCheckout?: (result: {
66
- navigateToCheckout: () => Promise<void>;
67
- }) => void;
65
+ onCheckout?: (navigateToCheckout: (options: {
66
+ postFlowUrl: string;
67
+ }) => Promise<void>) => void;
68
68
  /**
69
69
  * Called when booking completes without requiring checkout (free/offline services).
70
70
  * Receives the orderId which can be used to display confirmation or navigate to a thank you page.
@@ -24,9 +24,9 @@ export type ErrorPaymentConfigResult = {
24
24
  * Calls the pricing APIs and returns pre-calculated payment details.
25
25
  *
26
26
  * @param params.pricingServiceSelections - Pricing service selections for calculation
27
- * @param params.numberOfParticipants - Number of participants (default: 1)
27
+ * @param params.totalParticipants - Number of participants (default: 1)
28
28
  */
29
29
  export declare function loadPaymentConfig(params: {
30
30
  pricingServiceSelections: PricingServiceSelection[];
31
- numberOfParticipants?: number;
31
+ totalParticipants?: number;
32
32
  }): Promise<SuccessPaymentConfigResult | ErrorPaymentConfigResult>;
@@ -53,7 +53,7 @@ export interface PaymentServiceInternalConfig extends PaymentServiceConfig {
53
53
  /** Booking services for lazy loading (internal use) */
54
54
  pricingServiceSelections?: PricingServiceSelection[];
55
55
  /** Number of participants for lazy loading (internal use) */
56
- numberOfParticipants?: number;
56
+ totalParticipants?: number;
57
57
  }
58
58
  export interface PaymentServiceAPI {
59
59
  paymentDetailsSignal: Signal<PaymentDetails | null>;
@@ -36,15 +36,15 @@ function getPaymentOption(service, hasDeposit) {
36
36
  }
37
37
  return 'FULL_PAYMENT_ONLINE';
38
38
  }
39
- function buildLineItem(service, numberOfParticipants, lineItemId) {
39
+ function buildLineItem(service, totalParticipants, lineItemId) {
40
40
  // Get fixed price from service
41
41
  const servicePrice = service.payment?.fixed?.price?.value;
42
- const price = Number(servicePrice || 0) * numberOfParticipants;
42
+ const price = Number(servicePrice || 0) * totalParticipants;
43
43
  // Get deposit if configured
44
44
  const depositValue = service.payment?.fixed?.deposit?.value;
45
45
  const hasDeposit = !!depositValue && Number(depositValue) > 0;
46
46
  const deposit = hasDeposit
47
- ? Number(depositValue) * numberOfParticipants
47
+ ? Number(depositValue) * totalParticipants
48
48
  : undefined;
49
49
  // Get payment option from service configuration (pass hasDeposit for correct API behavior)
50
50
  const paymentOption = getPaymentOption(service, hasDeposit);
@@ -60,13 +60,13 @@ function buildLineItem(service, numberOfParticipants, lineItemId) {
60
60
  paymentOption,
61
61
  };
62
62
  }
63
- async function calculatePaymentDetails(pricingServiceSelections, numberOfParticipants) {
63
+ async function calculatePaymentDetails(pricingServiceSelections, totalParticipants) {
64
64
  // Ensure all booking services have a lineItemId
65
65
  const data = pricingServiceSelections.map((selection) => ({
66
66
  ...selection,
67
67
  lineItemId: selection.lineItemId || generateLineItemId(),
68
68
  }));
69
- const lineItems = data.map((item) => buildLineItem(item.service, numberOfParticipants, item.lineItemId));
69
+ const lineItems = data.map((item) => buildLineItem(item.service, totalParticipants, item.lineItemId));
70
70
  const response = await calculateTotals({
71
71
  lineItems,
72
72
  });
@@ -96,7 +96,7 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
96
96
  const isLoadingSignal = signalsService.signal(false);
97
97
  const errorSignal = signalsService.signal(null);
98
98
  // Internal calculate function
99
- const calculate = async (pricingServiceSelections, numberOfParticipants) => {
99
+ const calculate = async (pricingServiceSelections, totalParticipants) => {
100
100
  if (!pricingServiceSelections.length) {
101
101
  paymentDetailsSignal.set(null);
102
102
  return;
@@ -104,7 +104,7 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
104
104
  isLoadingSignal.set(true);
105
105
  errorSignal.set(null);
106
106
  try {
107
- const paymentDetails = await calculatePaymentDetails(pricingServiceSelections, numberOfParticipants);
107
+ const paymentDetails = await calculatePaymentDetails(pricingServiceSelections, totalParticipants);
108
108
  paymentDetailsSignal.set(paymentDetails);
109
109
  }
110
110
  catch (error) {
@@ -124,7 +124,7 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
124
124
  }
125
125
  // Mode 2: Lazy loading - pricingServiceSelections provided via internal config
126
126
  else if (config.pricingServiceSelections?.length) {
127
- void calculate(config.pricingServiceSelections, config.numberOfParticipants ?? 1);
127
+ void calculate(config.pricingServiceSelections, config.totalParticipants ?? 1);
128
128
  }
129
129
  // Mode 3: Reactive - observe BookingService signals (client-side only)
130
130
  else if (typeof window !== 'undefined' && bookingService) {
@@ -159,18 +159,18 @@ export const PaymentService = implementService.withConfig()(PaymentServiceDefini
159
159
  * Calls the pricing APIs and returns pre-calculated payment details.
160
160
  *
161
161
  * @param params.pricingServiceSelections - Pricing service selections for calculation
162
- * @param params.numberOfParticipants - Number of participants (default: 1)
162
+ * @param params.totalParticipants - Number of participants (default: 1)
163
163
  */
164
164
  export async function loadPaymentConfig(params) {
165
165
  try {
166
- const { pricingServiceSelections, numberOfParticipants = 1 } = params;
166
+ const { pricingServiceSelections, totalParticipants = 1 } = params;
167
167
  if (!pricingServiceSelections.length) {
168
168
  return {
169
169
  type: 'success',
170
170
  config: { paymentDetails: undefined },
171
171
  };
172
172
  }
173
- const paymentDetails = await calculatePaymentDetails(pricingServiceSelections, numberOfParticipants);
173
+ const paymentDetails = await calculatePaymentDetails(pricingServiceSelections, totalParticipants);
174
174
  return {
175
175
  type: 'success',
176
176
  config: { paymentDetails },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -72,5 +72,5 @@
72
72
  "groupId": "com.wixpress.headless-components"
73
73
  }
74
74
  },
75
- "falconPackageHash": "812d699830f343f6c162ed64b79333910ca8641451f43f1090ae9c17"
75
+ "falconPackageHash": "de93b455730e45ed2adcc6ab0f146aa5ae59da054da5ae8c3ffda373"
76
76
  }