@wix/headless-bookings 0.0.88 → 0.0.89

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.
@@ -19,13 +19,13 @@ export interface RootProps {
19
19
  /** Pricing service selections for lazy loading (triggers API call) */
20
20
  pricingServiceSelections?: PricingServiceSelection[];
21
21
  /** Number of participants for lazy loading */
22
- numberOfParticipants?: number;
22
+ totalParticipants?: number;
23
23
  }
24
24
  /**
25
25
  * Root component that provides payment context.
26
26
  * Supports 3 modes:
27
27
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
28
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API on init
28
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API on init
29
29
  * 3. Reactive: no config/props - reads from BookingService signals
30
30
  *
31
31
  * @component
@@ -37,7 +37,7 @@ export interface RootProps {
37
37
  * </Payment.Root>
38
38
  *
39
39
  * // Lazy loading mode
40
- * <Payment.Root pricingServiceSelections={[...]} numberOfParticipants={2}>
40
+ * <Payment.Root pricingServiceSelections={[...]} totalParticipants={2}>
41
41
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
42
42
  * </Payment.Root>
43
43
  *
@@ -26,7 +26,7 @@ function RootContent({ children, }) {
26
26
  * Root component that provides payment context.
27
27
  * Supports 3 modes:
28
28
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
29
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API on init
29
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API on init
30
30
  * 3. Reactive: no config/props - reads from BookingService signals
31
31
  *
32
32
  * @component
@@ -38,7 +38,7 @@ function RootContent({ children, }) {
38
38
  * </Payment.Root>
39
39
  *
40
40
  * // Lazy loading mode
41
- * <Payment.Root pricingServiceSelections={[...]} numberOfParticipants={2}>
41
+ * <Payment.Root pricingServiceSelections={[...]} totalParticipants={2}>
42
42
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
43
43
  * </Payment.Root>
44
44
  *
@@ -49,12 +49,12 @@ function RootContent({ children, }) {
49
49
  * ```
50
50
  */
51
51
  export function Root(props) {
52
- const { children, paymentServiceConfig = {}, pricingServiceSelections, numberOfParticipants, } = props;
52
+ const { children, paymentServiceConfig = {}, pricingServiceSelections, totalParticipants, } = props;
53
53
  // Merge public config with lazy loading props into internal config
54
54
  const internalConfig = {
55
55
  ...paymentServiceConfig,
56
56
  pricingServiceSelections,
57
- numberOfParticipants,
57
+ totalParticipants,
58
58
  };
59
59
  return (_jsx(WixServices, { servicesMap: createServicesMap().addService(PaymentServiceDefinition, PaymentService, internalConfig), disposeOnUnmount: true, children: _jsx(RootContent, { children: children }) }));
60
60
  }
@@ -19,7 +19,7 @@ export interface RootProps {
19
19
  /** Pricing service selections for lazy loading (triggers API call) */
20
20
  pricingServiceSelections?: PricingServiceSelection[];
21
21
  /** Number of participants for lazy loading */
22
- numberOfParticipants?: number;
22
+ totalParticipants?: number;
23
23
  asChild?: boolean;
24
24
  className?: string;
25
25
  }
@@ -27,7 +27,7 @@ export interface RootProps {
27
27
  * Root component that provides payment context to the entire app.
28
28
  * Supports 3 modes:
29
29
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
30
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API via useEffect
30
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API via useEffect
31
31
  * 3. Reactive: no config/props - reads from BookingService signals
32
32
  *
33
33
  * @order 1
@@ -48,7 +48,7 @@ export interface RootProps {
48
48
  * // Lazy loading mode
49
49
  * function LazyPayment({ slotServices }) {
50
50
  * return (
51
- * <Payment.Root slotServices={slotServices} numberOfParticipants={2}>
51
+ * <Payment.Root slotServices={slotServices} totalParticipants={2}>
52
52
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
53
53
  * </Payment.Root>
54
54
  * );
@@ -109,27 +109,6 @@ export interface TaxProps {
109
109
  * ```
110
110
  */
111
111
  export declare const Tax: React.ForwardRefExoticComponent<TaxProps & React.RefAttributes<HTMLElement>>;
112
- /**
113
- * Props for Payment.Discount component
114
- */
115
- export interface DiscountProps {
116
- asChild?: boolean;
117
- children?: AsChildChildren<{
118
- discount: MoneyData | null;
119
- }>;
120
- className?: string;
121
- }
122
- /**
123
- * Displays the payment discount.
124
- * Uses data-has-discount attribute for conditional visibility.
125
- *
126
- * @component
127
- * @example
128
- * ```tsx
129
- * <Payment.Discount className="text-green-500" />
130
- * ```
131
- */
132
- export declare const Discount: React.ForwardRefExoticComponent<DiscountProps & React.RefAttributes<HTMLElement>>;
133
112
  /**
134
113
  * Props for Payment.Total component
135
114
  */
@@ -280,7 +259,6 @@ export interface LineItemRepeaterProps {
280
259
  * ```tsx
281
260
  * <Payment.LineItemRepeater>
282
261
  * <Payment.LineItemTotal />
283
- * <Payment.LineItemDiscount />
284
262
  * </Payment.LineItemRepeater>
285
263
  * ```
286
264
  */
@@ -329,27 +307,6 @@ export interface LineItemSubtotalProps {
329
307
  * ```
330
308
  */
331
309
  export declare const LineItemSubtotal: React.ForwardRefExoticComponent<LineItemSubtotalProps & React.RefAttributes<HTMLElement>>;
332
- /**
333
- * Props for Payment.LineItemDiscount component
334
- */
335
- export interface LineItemDiscountProps {
336
- asChild?: boolean;
337
- children?: AsChildChildren<{
338
- discount: MoneyData | null;
339
- }>;
340
- className?: string;
341
- }
342
- /**
343
- * Displays the line item discount.
344
- * Uses data-has-discount attribute for conditional visibility.
345
- *
346
- * @component
347
- * @example
348
- * ```tsx
349
- * <Payment.LineItemDiscount className="text-green-500" />
350
- * ```
351
- */
352
- export declare const LineItemDiscount: React.ForwardRefExoticComponent<LineItemDiscountProps & React.RefAttributes<HTMLElement>>;
353
310
  /**
354
311
  * Props for Payment.LineItemDeposit component
355
312
  */
@@ -12,7 +12,6 @@ var TestIds;
12
12
  TestIds["paymentRoot"] = "payment-root";
13
13
  TestIds["paymentSubtotal"] = "payment-subtotal";
14
14
  TestIds["paymentTax"] = "payment-tax";
15
- TestIds["paymentDiscount"] = "payment-discount";
16
15
  TestIds["paymentTotal"] = "payment-total";
17
16
  TestIds["paymentPayNow"] = "payment-pay-now";
18
17
  TestIds["paymentPayLater"] = "payment-pay-later";
@@ -21,14 +20,13 @@ var TestIds;
21
20
  TestIds["paymentLineItemRepeater"] = "payment-line-item-repeater";
22
21
  TestIds["paymentLineItemTotal"] = "payment-line-item-total";
23
22
  TestIds["paymentLineItemSubtotal"] = "payment-line-item-subtotal";
24
- TestIds["paymentLineItemDiscount"] = "payment-line-item-discount";
25
23
  TestIds["paymentLineItemDeposit"] = "payment-line-item-deposit";
26
24
  })(TestIds || (TestIds = {}));
27
25
  /**
28
26
  * Root component that provides payment context to the entire app.
29
27
  * Supports 3 modes:
30
28
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
31
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API via useEffect
29
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API via useEffect
32
30
  * 3. Reactive: no config/props - reads from BookingService signals
33
31
  *
34
32
  * @order 1
@@ -49,7 +47,7 @@ var TestIds;
49
47
  * // Lazy loading mode
50
48
  * function LazyPayment({ slotServices }) {
51
49
  * return (
52
- * <Payment.Root slotServices={slotServices} numberOfParticipants={2}>
50
+ * <Payment.Root slotServices={slotServices} totalParticipants={2}>
53
51
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
54
52
  * </Payment.Root>
55
53
  * );
@@ -57,8 +55,8 @@ var TestIds;
57
55
  * ```
58
56
  */
59
57
  export const Root = React.forwardRef((props, ref) => {
60
- const { children, paymentServiceConfig, pricingServiceSelections, numberOfParticipants, asChild, className, ...attrs } = props;
61
- return (_jsx(CorePayment.Root, { paymentServiceConfig: paymentServiceConfig, pricingServiceSelections: pricingServiceSelections, numberOfParticipants: numberOfParticipants, children: ({ isLoading, hasError }) => {
58
+ const { children, paymentServiceConfig, pricingServiceSelections, totalParticipants, asChild, className, ...attrs } = props;
59
+ return (_jsx(CorePayment.Root, { paymentServiceConfig: paymentServiceConfig, pricingServiceSelections: pricingServiceSelections, totalParticipants: totalParticipants, children: ({ isLoading, hasError }) => {
62
60
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentRoot, "data-loading": isLoading, "data-has-error": hasError, customElement: children, customElementProps: { isLoading, hasError }, ...attrs, children: children }));
63
61
  } }));
64
62
  });
@@ -106,21 +104,6 @@ export const Tax = React.forwardRef((props, ref) => {
106
104
  return (_jsx(CorePayment.Data, { children: ({ tax, hasTax }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentTax, "data-has-tax": hasTax, customElement: children, customElementProps: { tax }, children: hasTax && _jsx(Money, { money: tax }) })) }));
107
105
  });
108
106
  Tax.displayName = 'Payment.Tax';
109
- /**
110
- * Displays the payment discount.
111
- * Uses data-has-discount attribute for conditional visibility.
112
- *
113
- * @component
114
- * @example
115
- * ```tsx
116
- * <Payment.Discount className="text-green-500" />
117
- * ```
118
- */
119
- export const Discount = React.forwardRef((props, ref) => {
120
- const { asChild, children, className } = props;
121
- return (_jsx(CorePayment.Data, { children: ({ discount, hasDiscount }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentDiscount, "data-has-discount": hasDiscount, customElement: children, customElementProps: { discount }, children: hasDiscount && _jsx(Money, { money: discount }) })) }));
122
- });
123
- Discount.displayName = 'Payment.Discount';
124
107
  /**
125
108
  * Displays the payment total.
126
109
  * Always displays the monetary value. Exposes customPrice for custom rendering.
@@ -249,7 +232,6 @@ const LineItemWrapper = ({ item, currency, children, }) => {
249
232
  * ```tsx
250
233
  * <Payment.LineItemRepeater>
251
234
  * <Payment.LineItemTotal />
252
- * <Payment.LineItemDiscount />
253
235
  * </Payment.LineItemRepeater>
254
236
  * ```
255
237
  */
@@ -289,21 +271,6 @@ export const LineItemSubtotal = React.forwardRef((props, ref) => {
289
271
  return (_jsx(CorePayment.LineItemInfo, { children: ({ subtotal, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemSubtotal, "data-has-custom-price": !!customPrice, customElement: children, customElementProps: { subtotal, customPrice }, children: customPrice ? (_jsx("span", { children: customPrice })) : (subtotal && _jsx(Money, { money: subtotal })) })) }));
290
272
  });
291
273
  LineItemSubtotal.displayName = 'Payment.LineItemSubtotal';
292
- /**
293
- * Displays the line item discount.
294
- * Uses data-has-discount attribute for conditional visibility.
295
- *
296
- * @component
297
- * @example
298
- * ```tsx
299
- * <Payment.LineItemDiscount className="text-green-500" />
300
- * ```
301
- */
302
- export const LineItemDiscount = React.forwardRef((props, ref) => {
303
- const { asChild, children, className } = props;
304
- return (_jsx(CorePayment.LineItemInfo, { children: ({ discount, hasDiscount }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemDiscount, "data-has-discount": hasDiscount, customElement: children, customElementProps: { discount }, children: hasDiscount && _jsx(Money, { money: discount }) })) }));
305
- });
306
- LineItemDiscount.displayName = 'Payment.LineItemDiscount';
307
274
  /**
308
275
  * Displays the line item deposit amount.
309
276
  * Uses data-has-deposit attribute for conditional visibility.
@@ -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 },
@@ -19,13 +19,13 @@ export interface RootProps {
19
19
  /** Pricing service selections for lazy loading (triggers API call) */
20
20
  pricingServiceSelections?: PricingServiceSelection[];
21
21
  /** Number of participants for lazy loading */
22
- numberOfParticipants?: number;
22
+ totalParticipants?: number;
23
23
  }
24
24
  /**
25
25
  * Root component that provides payment context.
26
26
  * Supports 3 modes:
27
27
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
28
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API on init
28
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API on init
29
29
  * 3. Reactive: no config/props - reads from BookingService signals
30
30
  *
31
31
  * @component
@@ -37,7 +37,7 @@ export interface RootProps {
37
37
  * </Payment.Root>
38
38
  *
39
39
  * // Lazy loading mode
40
- * <Payment.Root pricingServiceSelections={[...]} numberOfParticipants={2}>
40
+ * <Payment.Root pricingServiceSelections={[...]} totalParticipants={2}>
41
41
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
42
42
  * </Payment.Root>
43
43
  *
@@ -26,7 +26,7 @@ function RootContent({ children, }) {
26
26
  * Root component that provides payment context.
27
27
  * Supports 3 modes:
28
28
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
29
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API on init
29
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API on init
30
30
  * 3. Reactive: no config/props - reads from BookingService signals
31
31
  *
32
32
  * @component
@@ -38,7 +38,7 @@ function RootContent({ children, }) {
38
38
  * </Payment.Root>
39
39
  *
40
40
  * // Lazy loading mode
41
- * <Payment.Root pricingServiceSelections={[...]} numberOfParticipants={2}>
41
+ * <Payment.Root pricingServiceSelections={[...]} totalParticipants={2}>
42
42
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
43
43
  * </Payment.Root>
44
44
  *
@@ -49,12 +49,12 @@ function RootContent({ children, }) {
49
49
  * ```
50
50
  */
51
51
  export function Root(props) {
52
- const { children, paymentServiceConfig = {}, pricingServiceSelections, numberOfParticipants, } = props;
52
+ const { children, paymentServiceConfig = {}, pricingServiceSelections, totalParticipants, } = props;
53
53
  // Merge public config with lazy loading props into internal config
54
54
  const internalConfig = {
55
55
  ...paymentServiceConfig,
56
56
  pricingServiceSelections,
57
- numberOfParticipants,
57
+ totalParticipants,
58
58
  };
59
59
  return (_jsx(WixServices, { servicesMap: createServicesMap().addService(PaymentServiceDefinition, PaymentService, internalConfig), disposeOnUnmount: true, children: _jsx(RootContent, { children: children }) }));
60
60
  }
@@ -19,7 +19,7 @@ export interface RootProps {
19
19
  /** Pricing service selections for lazy loading (triggers API call) */
20
20
  pricingServiceSelections?: PricingServiceSelection[];
21
21
  /** Number of participants for lazy loading */
22
- numberOfParticipants?: number;
22
+ totalParticipants?: number;
23
23
  asChild?: boolean;
24
24
  className?: string;
25
25
  }
@@ -27,7 +27,7 @@ export interface RootProps {
27
27
  * Root component that provides payment context to the entire app.
28
28
  * Supports 3 modes:
29
29
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
30
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API via useEffect
30
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API via useEffect
31
31
  * 3. Reactive: no config/props - reads from BookingService signals
32
32
  *
33
33
  * @order 1
@@ -48,7 +48,7 @@ export interface RootProps {
48
48
  * // Lazy loading mode
49
49
  * function LazyPayment({ slotServices }) {
50
50
  * return (
51
- * <Payment.Root slotServices={slotServices} numberOfParticipants={2}>
51
+ * <Payment.Root slotServices={slotServices} totalParticipants={2}>
52
52
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
53
53
  * </Payment.Root>
54
54
  * );
@@ -109,27 +109,6 @@ export interface TaxProps {
109
109
  * ```
110
110
  */
111
111
  export declare const Tax: React.ForwardRefExoticComponent<TaxProps & React.RefAttributes<HTMLElement>>;
112
- /**
113
- * Props for Payment.Discount component
114
- */
115
- export interface DiscountProps {
116
- asChild?: boolean;
117
- children?: AsChildChildren<{
118
- discount: MoneyData | null;
119
- }>;
120
- className?: string;
121
- }
122
- /**
123
- * Displays the payment discount.
124
- * Uses data-has-discount attribute for conditional visibility.
125
- *
126
- * @component
127
- * @example
128
- * ```tsx
129
- * <Payment.Discount className="text-green-500" />
130
- * ```
131
- */
132
- export declare const Discount: React.ForwardRefExoticComponent<DiscountProps & React.RefAttributes<HTMLElement>>;
133
112
  /**
134
113
  * Props for Payment.Total component
135
114
  */
@@ -280,7 +259,6 @@ export interface LineItemRepeaterProps {
280
259
  * ```tsx
281
260
  * <Payment.LineItemRepeater>
282
261
  * <Payment.LineItemTotal />
283
- * <Payment.LineItemDiscount />
284
262
  * </Payment.LineItemRepeater>
285
263
  * ```
286
264
  */
@@ -329,27 +307,6 @@ export interface LineItemSubtotalProps {
329
307
  * ```
330
308
  */
331
309
  export declare const LineItemSubtotal: React.ForwardRefExoticComponent<LineItemSubtotalProps & React.RefAttributes<HTMLElement>>;
332
- /**
333
- * Props for Payment.LineItemDiscount component
334
- */
335
- export interface LineItemDiscountProps {
336
- asChild?: boolean;
337
- children?: AsChildChildren<{
338
- discount: MoneyData | null;
339
- }>;
340
- className?: string;
341
- }
342
- /**
343
- * Displays the line item discount.
344
- * Uses data-has-discount attribute for conditional visibility.
345
- *
346
- * @component
347
- * @example
348
- * ```tsx
349
- * <Payment.LineItemDiscount className="text-green-500" />
350
- * ```
351
- */
352
- export declare const LineItemDiscount: React.ForwardRefExoticComponent<LineItemDiscountProps & React.RefAttributes<HTMLElement>>;
353
310
  /**
354
311
  * Props for Payment.LineItemDeposit component
355
312
  */
@@ -12,7 +12,6 @@ var TestIds;
12
12
  TestIds["paymentRoot"] = "payment-root";
13
13
  TestIds["paymentSubtotal"] = "payment-subtotal";
14
14
  TestIds["paymentTax"] = "payment-tax";
15
- TestIds["paymentDiscount"] = "payment-discount";
16
15
  TestIds["paymentTotal"] = "payment-total";
17
16
  TestIds["paymentPayNow"] = "payment-pay-now";
18
17
  TestIds["paymentPayLater"] = "payment-pay-later";
@@ -21,14 +20,13 @@ var TestIds;
21
20
  TestIds["paymentLineItemRepeater"] = "payment-line-item-repeater";
22
21
  TestIds["paymentLineItemTotal"] = "payment-line-item-total";
23
22
  TestIds["paymentLineItemSubtotal"] = "payment-line-item-subtotal";
24
- TestIds["paymentLineItemDiscount"] = "payment-line-item-discount";
25
23
  TestIds["paymentLineItemDeposit"] = "payment-line-item-deposit";
26
24
  })(TestIds || (TestIds = {}));
27
25
  /**
28
26
  * Root component that provides payment context to the entire app.
29
27
  * Supports 3 modes:
30
28
  * 1. SSR: paymentServiceConfig.paymentDetails - pre-fetched data
31
- * 2. Lazy loading: pricingServiceSelections + numberOfParticipants props - calls API via useEffect
29
+ * 2. Lazy loading: pricingServiceSelections + totalParticipants props - calls API via useEffect
32
30
  * 3. Reactive: no config/props - reads from BookingService signals
33
31
  *
34
32
  * @order 1
@@ -49,7 +47,7 @@ var TestIds;
49
47
  * // Lazy loading mode
50
48
  * function LazyPayment({ slotServices }) {
51
49
  * return (
52
- * <Payment.Root slotServices={slotServices} numberOfParticipants={2}>
50
+ * <Payment.Root slotServices={slotServices} totalParticipants={2}>
53
51
  * {({ isLoading }) => isLoading ? <div>Loading...</div> : <Payment.Total />}
54
52
  * </Payment.Root>
55
53
  * );
@@ -57,8 +55,8 @@ var TestIds;
57
55
  * ```
58
56
  */
59
57
  export const Root = React.forwardRef((props, ref) => {
60
- const { children, paymentServiceConfig, pricingServiceSelections, numberOfParticipants, asChild, className, ...attrs } = props;
61
- return (_jsx(CorePayment.Root, { paymentServiceConfig: paymentServiceConfig, pricingServiceSelections: pricingServiceSelections, numberOfParticipants: numberOfParticipants, children: ({ isLoading, hasError }) => {
58
+ const { children, paymentServiceConfig, pricingServiceSelections, totalParticipants, asChild, className, ...attrs } = props;
59
+ return (_jsx(CorePayment.Root, { paymentServiceConfig: paymentServiceConfig, pricingServiceSelections: pricingServiceSelections, totalParticipants: totalParticipants, children: ({ isLoading, hasError }) => {
62
60
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentRoot, "data-loading": isLoading, "data-has-error": hasError, customElement: children, customElementProps: { isLoading, hasError }, ...attrs, children: children }));
63
61
  } }));
64
62
  });
@@ -106,21 +104,6 @@ export const Tax = React.forwardRef((props, ref) => {
106
104
  return (_jsx(CorePayment.Data, { children: ({ tax, hasTax }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentTax, "data-has-tax": hasTax, customElement: children, customElementProps: { tax }, children: hasTax && _jsx(Money, { money: tax }) })) }));
107
105
  });
108
106
  Tax.displayName = 'Payment.Tax';
109
- /**
110
- * Displays the payment discount.
111
- * Uses data-has-discount attribute for conditional visibility.
112
- *
113
- * @component
114
- * @example
115
- * ```tsx
116
- * <Payment.Discount className="text-green-500" />
117
- * ```
118
- */
119
- export const Discount = React.forwardRef((props, ref) => {
120
- const { asChild, children, className } = props;
121
- return (_jsx(CorePayment.Data, { children: ({ discount, hasDiscount }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentDiscount, "data-has-discount": hasDiscount, customElement: children, customElementProps: { discount }, children: hasDiscount && _jsx(Money, { money: discount }) })) }));
122
- });
123
- Discount.displayName = 'Payment.Discount';
124
107
  /**
125
108
  * Displays the payment total.
126
109
  * Always displays the monetary value. Exposes customPrice for custom rendering.
@@ -249,7 +232,6 @@ const LineItemWrapper = ({ item, currency, children, }) => {
249
232
  * ```tsx
250
233
  * <Payment.LineItemRepeater>
251
234
  * <Payment.LineItemTotal />
252
- * <Payment.LineItemDiscount />
253
235
  * </Payment.LineItemRepeater>
254
236
  * ```
255
237
  */
@@ -289,21 +271,6 @@ export const LineItemSubtotal = React.forwardRef((props, ref) => {
289
271
  return (_jsx(CorePayment.LineItemInfo, { children: ({ subtotal, customPrice }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemSubtotal, "data-has-custom-price": !!customPrice, customElement: children, customElementProps: { subtotal, customPrice }, children: customPrice ? (_jsx("span", { children: customPrice })) : (subtotal && _jsx(Money, { money: subtotal })) })) }));
290
272
  });
291
273
  LineItemSubtotal.displayName = 'Payment.LineItemSubtotal';
292
- /**
293
- * Displays the line item discount.
294
- * Uses data-has-discount attribute for conditional visibility.
295
- *
296
- * @component
297
- * @example
298
- * ```tsx
299
- * <Payment.LineItemDiscount className="text-green-500" />
300
- * ```
301
- */
302
- export const LineItemDiscount = React.forwardRef((props, ref) => {
303
- const { asChild, children, className } = props;
304
- return (_jsx(CorePayment.LineItemInfo, { children: ({ discount, hasDiscount }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemDiscount, "data-has-discount": hasDiscount, customElement: children, customElementProps: { discount }, children: hasDiscount && _jsx(Money, { money: discount }) })) }));
305
- });
306
- LineItemDiscount.displayName = 'Payment.LineItemDiscount';
307
274
  /**
308
275
  * Displays the line item deposit amount.
309
276
  * Uses data-has-deposit attribute for conditional visibility.
@@ -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.89",
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": "57a07a8154bb7def020ba4429b5e58f59af1a8c7e7451b13e715d4a4"
76
76
  }