@wix/headless-bookings 0.0.30 → 0.0.32
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/react/core/payment/Payment.d.ts +193 -0
- package/cjs/dist/react/core/payment/Payment.js +202 -0
- package/cjs/dist/react/index.d.ts +2 -0
- package/cjs/dist/react/index.js +2 -0
- package/cjs/dist/react/payment/Payment.d.ts +342 -0
- package/cjs/dist/react/payment/Payment.js +294 -0
- package/cjs/dist/react/payment/PaymentLineItem.d.ts +144 -0
- package/cjs/dist/react/payment/PaymentLineItem.js +141 -0
- package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +23 -11
- package/cjs/dist/react/time-slot-list/TimeSlot.js +34 -16
- package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +6 -0
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +23 -5
- package/cjs/dist/services/index.d.ts +1 -0
- package/cjs/dist/services/index.js +1 -0
- package/cjs/dist/services/payment/payment.d.ts +32 -0
- package/cjs/dist/services/payment/payment.def.d.ts +66 -0
- package/cjs/dist/services/payment/payment.def.js +9 -0
- package/cjs/dist/services/payment/payment.js +167 -0
- package/cjs/dist/utils/money.d.ts +11 -0
- package/cjs/dist/utils/money.js +16 -0
- package/dist/react/core/payment/Payment.d.ts +193 -0
- package/dist/react/core/payment/Payment.js +202 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/react/payment/Payment.d.ts +342 -0
- package/dist/react/payment/Payment.js +294 -0
- package/dist/react/payment/PaymentLineItem.d.ts +144 -0
- package/dist/react/payment/PaymentLineItem.js +141 -0
- package/dist/react/time-slot-list/TimeSlot.d.ts +23 -11
- package/dist/react/time-slot-list/TimeSlot.js +34 -16
- package/dist/react/time-slot-list/TimeSlotList.d.ts +6 -0
- package/dist/react/time-slot-list/TimeSlotList.js +23 -5
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/payment/payment.d.ts +32 -0
- package/dist/services/payment/payment.def.d.ts +66 -0
- package/dist/services/payment/payment.def.js +9 -0
- package/dist/services/payment/payment.js +167 -0
- package/dist/utils/money.d.ts +11 -0
- package/dist/utils/money.js +16 -0
- package/package.json +2 -2
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaymentLineItem - Component for displaying individual line item information
|
|
3
|
+
* Used within Payment.LineItemRepeater to display price, discount, deposit, etc.
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
7
|
+
import { MoneyData } from '@wix/headless-components/react';
|
|
8
|
+
import type { CombinedLineItem } from '../core/payment/Payment.js';
|
|
9
|
+
/**
|
|
10
|
+
* Props for PaymentLineItem.Root component
|
|
11
|
+
*/
|
|
12
|
+
export interface RootProps {
|
|
13
|
+
lineItem: CombinedLineItem;
|
|
14
|
+
currency: string;
|
|
15
|
+
children?: React.ReactNode | AsChildChildren<{
|
|
16
|
+
lineItem: CombinedLineItem;
|
|
17
|
+
currency: string;
|
|
18
|
+
}>;
|
|
19
|
+
asChild?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
'data-testid'?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Root component for a single line item.
|
|
25
|
+
* Provides context for child components.
|
|
26
|
+
*
|
|
27
|
+
* @component
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <PaymentLineItem.Root lineItem={item} currency="USD">
|
|
31
|
+
* <PaymentLineItem.Price />
|
|
32
|
+
* <PaymentLineItem.Discount />
|
|
33
|
+
* </PaymentLineItem.Root>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLElement>>;
|
|
37
|
+
/**
|
|
38
|
+
* Props for PaymentLineItem.Price component
|
|
39
|
+
*/
|
|
40
|
+
export interface PriceProps {
|
|
41
|
+
asChild?: boolean;
|
|
42
|
+
children?: AsChildChildren<{
|
|
43
|
+
totalPrice: MoneyData | null;
|
|
44
|
+
subtotal: MoneyData | null;
|
|
45
|
+
tax: MoneyData | null;
|
|
46
|
+
discount: MoneyData | null;
|
|
47
|
+
deposit: MoneyData | null;
|
|
48
|
+
priceText: string | null;
|
|
49
|
+
}>;
|
|
50
|
+
className?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Displays the line item price with support for different price types.
|
|
54
|
+
* Uses data-attributes for conditional visibility.
|
|
55
|
+
*
|
|
56
|
+
* For CUSTOM rate type services, displays priceText instead of monetary value.
|
|
57
|
+
*
|
|
58
|
+
* @component
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* // Default usage - renders total price or price text
|
|
62
|
+
* <PaymentLineItem.Price className="text-lg font-bold" />
|
|
63
|
+
*
|
|
64
|
+
* // Custom rendering with full price data
|
|
65
|
+
* <PaymentLineItem.Price asChild>
|
|
66
|
+
* {({ totalPrice, subtotal, tax, discount, priceText }) => (
|
|
67
|
+
* <div>
|
|
68
|
+
* {priceText ? (
|
|
69
|
+
* <span>{priceText}</span>
|
|
70
|
+
* ) : (
|
|
71
|
+
* <>
|
|
72
|
+
* <span><Money money={totalPrice} /></span>
|
|
73
|
+
* <span data-has-discount={!!discount?.amount}><Money money={discount} /></span>
|
|
74
|
+
* </>
|
|
75
|
+
* )}
|
|
76
|
+
* </div>
|
|
77
|
+
* )}
|
|
78
|
+
* </PaymentLineItem.Price>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const Price: React.ForwardRefExoticComponent<PriceProps & React.RefAttributes<HTMLElement>>;
|
|
82
|
+
/**
|
|
83
|
+
* Props for PaymentLineItem.Discount component
|
|
84
|
+
*/
|
|
85
|
+
export interface DiscountProps {
|
|
86
|
+
asChild?: boolean;
|
|
87
|
+
children?: AsChildChildren<{
|
|
88
|
+
discount: MoneyData | null;
|
|
89
|
+
}>;
|
|
90
|
+
className?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Displays the line item discount.
|
|
94
|
+
* Uses data-has-discount attribute for conditional visibility.
|
|
95
|
+
*
|
|
96
|
+
* @component
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* <PaymentLineItem.Discount className="text-green-500" />
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare const Discount: React.ForwardRefExoticComponent<DiscountProps & React.RefAttributes<HTMLElement>>;
|
|
103
|
+
/**
|
|
104
|
+
* Props for PaymentLineItem.Deposit component
|
|
105
|
+
*/
|
|
106
|
+
export interface DepositProps {
|
|
107
|
+
asChild?: boolean;
|
|
108
|
+
children?: AsChildChildren<{
|
|
109
|
+
deposit: MoneyData | null;
|
|
110
|
+
}>;
|
|
111
|
+
className?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Displays the line item deposit amount.
|
|
115
|
+
* Uses data-has-deposit attribute for conditional visibility.
|
|
116
|
+
*
|
|
117
|
+
* @component
|
|
118
|
+
* @example
|
|
119
|
+
* ```tsx
|
|
120
|
+
* <PaymentLineItem.Deposit className="font-semibold" />
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare const Deposit: React.ForwardRefExoticComponent<DepositProps & React.RefAttributes<HTMLElement>>;
|
|
124
|
+
/**
|
|
125
|
+
* Props for PaymentLineItem.PriceText component
|
|
126
|
+
*/
|
|
127
|
+
export interface PriceTextProps {
|
|
128
|
+
asChild?: boolean;
|
|
129
|
+
children?: AsChildChildren<{
|
|
130
|
+
priceText: string | null;
|
|
131
|
+
}>;
|
|
132
|
+
className?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Displays the custom price text (for CUSTOM rate type services).
|
|
136
|
+
* Uses data-has-price-text attribute for conditional visibility.
|
|
137
|
+
*
|
|
138
|
+
* @component
|
|
139
|
+
* @example
|
|
140
|
+
* ```tsx
|
|
141
|
+
* <PaymentLineItem.PriceText className="text-foreground" />
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare const PriceText: React.ForwardRefExoticComponent<PriceTextProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* PaymentLineItem - Component for displaying individual line item information
|
|
4
|
+
* Used within Payment.LineItemRepeater to display price, discount, deposit, etc.
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import * as CorePayment from '../core/payment/Payment.js';
|
|
8
|
+
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
9
|
+
import { Money } from '@wix/headless-components/react';
|
|
10
|
+
var TestIds;
|
|
11
|
+
(function (TestIds) {
|
|
12
|
+
TestIds["paymentLineItemRoot"] = "payment-line-item-root";
|
|
13
|
+
TestIds["paymentLineItemPrice"] = "payment-line-item-price";
|
|
14
|
+
TestIds["paymentLineItemDiscount"] = "payment-line-item-discount";
|
|
15
|
+
TestIds["paymentLineItemDeposit"] = "payment-line-item-deposit";
|
|
16
|
+
TestIds["paymentLineItemPriceText"] = "payment-line-item-price-text";
|
|
17
|
+
})(TestIds || (TestIds = {}));
|
|
18
|
+
const PaymentLineItemContext = React.createContext(null);
|
|
19
|
+
/**
|
|
20
|
+
* Hook to access PaymentLineItem context
|
|
21
|
+
*/
|
|
22
|
+
function usePaymentLineItemContext() {
|
|
23
|
+
const context = React.useContext(PaymentLineItemContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error('usePaymentLineItemContext must be used within a PaymentLineItem.Root component');
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Root component for a single line item.
|
|
31
|
+
* Provides context for child components.
|
|
32
|
+
*
|
|
33
|
+
* @component
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <PaymentLineItem.Root lineItem={item} currency="USD">
|
|
37
|
+
* <PaymentLineItem.Price />
|
|
38
|
+
* <PaymentLineItem.Discount />
|
|
39
|
+
* </PaymentLineItem.Root>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export const Root = React.forwardRef((props, ref) => {
|
|
43
|
+
const { lineItem, currency, children, asChild, className, ...attrs } = props;
|
|
44
|
+
return (_jsx(PaymentLineItemContext.Provider, { value: { lineItem, currency }, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": attrs['data-testid'] || TestIds.paymentLineItemRoot, customElement: children, customElementProps: { lineItem, currency }, ...attrs, children: _jsx("div", { children: React.isValidElement(children) ? children : null }) }) }));
|
|
45
|
+
});
|
|
46
|
+
Root.displayName = 'PaymentLineItem.Root';
|
|
47
|
+
/**
|
|
48
|
+
* Displays the line item price with support for different price types.
|
|
49
|
+
* Uses data-attributes for conditional visibility.
|
|
50
|
+
*
|
|
51
|
+
* For CUSTOM rate type services, displays priceText instead of monetary value.
|
|
52
|
+
*
|
|
53
|
+
* @component
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* // Default usage - renders total price or price text
|
|
57
|
+
* <PaymentLineItem.Price className="text-lg font-bold" />
|
|
58
|
+
*
|
|
59
|
+
* // Custom rendering with full price data
|
|
60
|
+
* <PaymentLineItem.Price asChild>
|
|
61
|
+
* {({ totalPrice, subtotal, tax, discount, priceText }) => (
|
|
62
|
+
* <div>
|
|
63
|
+
* {priceText ? (
|
|
64
|
+
* <span>{priceText}</span>
|
|
65
|
+
* ) : (
|
|
66
|
+
* <>
|
|
67
|
+
* <span><Money money={totalPrice} /></span>
|
|
68
|
+
* <span data-has-discount={!!discount?.amount}><Money money={discount} /></span>
|
|
69
|
+
* </>
|
|
70
|
+
* )}
|
|
71
|
+
* </div>
|
|
72
|
+
* )}
|
|
73
|
+
* </PaymentLineItem.Price>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export const Price = React.forwardRef((props, ref) => {
|
|
77
|
+
const { asChild, children, className } = props;
|
|
78
|
+
const { lineItem, currency } = usePaymentLineItemContext();
|
|
79
|
+
return (_jsx(CorePayment.LineItem, { lineItem: lineItem, currency: currency, children: (priceData) => {
|
|
80
|
+
const { totalPrice, discount, deposit, priceText } = priceData;
|
|
81
|
+
// Default rendering based on price type
|
|
82
|
+
const renderDefaultPrice = () => {
|
|
83
|
+
// If custom price text (CUSTOM rate type), show text
|
|
84
|
+
if (priceText) {
|
|
85
|
+
return (_jsx("span", { className: className, "data-testid": TestIds.paymentLineItemPrice, children: priceText }));
|
|
86
|
+
}
|
|
87
|
+
// Otherwise show monetary price
|
|
88
|
+
return totalPrice ? (_jsx(Money, { money: totalPrice, className: className })) : null;
|
|
89
|
+
};
|
|
90
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemPrice, "data-has-discount": discount !== null && discount.amount > 0, "data-has-deposit": deposit !== null && deposit.amount > 0, "data-has-price-text": !!priceText, customElement: children, customElementProps: priceData, children: renderDefaultPrice() }));
|
|
91
|
+
} }));
|
|
92
|
+
});
|
|
93
|
+
Price.displayName = 'PaymentLineItem.Price';
|
|
94
|
+
/**
|
|
95
|
+
* Displays the line item discount.
|
|
96
|
+
* Uses data-has-discount attribute for conditional visibility.
|
|
97
|
+
*
|
|
98
|
+
* @component
|
|
99
|
+
* @example
|
|
100
|
+
* ```tsx
|
|
101
|
+
* <PaymentLineItem.Discount className="text-green-500" />
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export const Discount = React.forwardRef((props, ref) => {
|
|
105
|
+
const { asChild, children, className } = props;
|
|
106
|
+
const { lineItem, currency } = usePaymentLineItemContext();
|
|
107
|
+
return (_jsx(CorePayment.LineItem, { lineItem: lineItem, currency: currency, children: ({ discount }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemDiscount, "data-has-discount": discount !== null && discount.amount > 0, customElement: children, customElementProps: { discount }, children: discount ? _jsx(Money, { money: discount }) : null })) }));
|
|
108
|
+
});
|
|
109
|
+
Discount.displayName = 'PaymentLineItem.Discount';
|
|
110
|
+
/**
|
|
111
|
+
* Displays the line item deposit amount.
|
|
112
|
+
* Uses data-has-deposit attribute for conditional visibility.
|
|
113
|
+
*
|
|
114
|
+
* @component
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* <PaymentLineItem.Deposit className="font-semibold" />
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export const Deposit = React.forwardRef((props, ref) => {
|
|
121
|
+
const { asChild, children, className } = props;
|
|
122
|
+
const { lineItem, currency } = usePaymentLineItemContext();
|
|
123
|
+
return (_jsx(CorePayment.LineItem, { lineItem: lineItem, currency: currency, children: ({ deposit }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemDeposit, "data-has-deposit": deposit !== null && deposit.amount > 0, customElement: children, customElementProps: { deposit }, children: deposit ? _jsx(Money, { money: deposit }) : null })) }));
|
|
124
|
+
});
|
|
125
|
+
Deposit.displayName = 'PaymentLineItem.Deposit';
|
|
126
|
+
/**
|
|
127
|
+
* Displays the custom price text (for CUSTOM rate type services).
|
|
128
|
+
* Uses data-has-price-text attribute for conditional visibility.
|
|
129
|
+
*
|
|
130
|
+
* @component
|
|
131
|
+
* @example
|
|
132
|
+
* ```tsx
|
|
133
|
+
* <PaymentLineItem.PriceText className="text-foreground" />
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export const PriceText = React.forwardRef((props, ref) => {
|
|
137
|
+
const { asChild, children, className } = props;
|
|
138
|
+
const { lineItem, currency } = usePaymentLineItemContext();
|
|
139
|
+
return (_jsx(CorePayment.LineItem, { lineItem: lineItem, currency: currency, children: ({ priceText }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.paymentLineItemPriceText, "data-has-price-text": !!priceText, customElement: children, customElementProps: { priceText }, children: priceText ? _jsx("span", { children: priceText }) : null })) }));
|
|
140
|
+
});
|
|
141
|
+
PriceText.displayName = 'PaymentLineItem.PriceText';
|
|
@@ -21,13 +21,13 @@ export interface StartDateProps {
|
|
|
21
21
|
className?: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Displays the time slot start
|
|
25
|
-
*
|
|
24
|
+
* Displays the time slot start time.
|
|
25
|
+
* Default formatting shows time as "10:00 AM" (hour:minute with AM/PM).
|
|
26
26
|
*
|
|
27
27
|
* @component
|
|
28
28
|
* @example
|
|
29
29
|
* ```tsx
|
|
30
|
-
* // Default usage - displays
|
|
30
|
+
* // Default usage - displays "10:00 AM"
|
|
31
31
|
* <TimeSlot.StartDate className="text-foreground" />
|
|
32
32
|
*
|
|
33
33
|
* // With custom formatting
|
|
@@ -50,13 +50,13 @@ export interface EndDateProps {
|
|
|
50
50
|
className?: string;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Displays the time slot end
|
|
54
|
-
*
|
|
53
|
+
* Displays the time slot end time.
|
|
54
|
+
* Default formatting shows time as "11:00 AM" (hour:minute with AM/PM).
|
|
55
55
|
*
|
|
56
56
|
* @component
|
|
57
57
|
* @example
|
|
58
58
|
* ```tsx
|
|
59
|
-
* // Default usage - displays
|
|
59
|
+
* // Default usage - displays "11:00 AM"
|
|
60
60
|
* <TimeSlot.EndDate className="text-foreground" />
|
|
61
61
|
*
|
|
62
62
|
* // With custom formatting
|
|
@@ -112,12 +112,16 @@ export interface SelectProps {
|
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* Button to select this time slot.
|
|
115
|
+
* Default label is "Select".
|
|
115
116
|
*
|
|
116
117
|
* @component
|
|
117
118
|
* @example
|
|
118
119
|
* ```tsx
|
|
119
|
-
* // Default button
|
|
120
|
-
* <TimeSlot.Actions.Select
|
|
120
|
+
* // Default button with "Select" label
|
|
121
|
+
* <TimeSlot.Actions.Select />
|
|
122
|
+
*
|
|
123
|
+
* // With custom label
|
|
124
|
+
* <TimeSlot.Actions.Select label="Book" />
|
|
121
125
|
*
|
|
122
126
|
* // With asChild
|
|
123
127
|
* <TimeSlot.Actions.Select asChild>
|
|
@@ -149,11 +153,15 @@ export interface ClearStaffSelectionProps {
|
|
|
149
153
|
/**
|
|
150
154
|
* Button to clear staff selection while keeping the slot selected.
|
|
151
155
|
* Only renders when a staff member is selected and there are multiple staff options.
|
|
156
|
+
* Default label is "Change".
|
|
152
157
|
*
|
|
153
158
|
* @component
|
|
154
159
|
* @example
|
|
155
160
|
* ```tsx
|
|
156
|
-
* // Default button
|
|
161
|
+
* // Default button with "Change" label
|
|
162
|
+
* <TimeSlot.Actions.ClearStaffSelection />
|
|
163
|
+
*
|
|
164
|
+
* // With custom label
|
|
157
165
|
* <TimeSlot.Actions.ClearStaffSelection label="Change staff" />
|
|
158
166
|
*
|
|
159
167
|
* // With asChild
|
|
@@ -297,12 +305,16 @@ export interface SelectStaffMemberProps {
|
|
|
297
305
|
}
|
|
298
306
|
/**
|
|
299
307
|
* Button to select this staff member.
|
|
308
|
+
* Default label is "Select".
|
|
300
309
|
*
|
|
301
310
|
* @component
|
|
302
311
|
* @example
|
|
303
312
|
* ```tsx
|
|
304
|
-
* // Default button
|
|
305
|
-
* <TimeSlot.StaffMember.Actions.Select
|
|
313
|
+
* // Default button with "Select" label
|
|
314
|
+
* <TimeSlot.StaffMember.Actions.Select />
|
|
315
|
+
*
|
|
316
|
+
* // With custom label
|
|
317
|
+
* <TimeSlot.StaffMember.Actions.Select label="Choose" />
|
|
306
318
|
*
|
|
307
319
|
* // With asChild
|
|
308
320
|
* <TimeSlot.StaffMember.Actions.Select asChild>
|
|
@@ -31,13 +31,13 @@ var TestIds;
|
|
|
31
31
|
TestIds["timeSlotStaffMemberActionSelect"] = "time-slot-staff-member-action-select";
|
|
32
32
|
})(TestIds || (TestIds = {}));
|
|
33
33
|
/**
|
|
34
|
-
* Displays the time slot start
|
|
35
|
-
*
|
|
34
|
+
* Displays the time slot start time.
|
|
35
|
+
* Default formatting shows time as "10:00 AM" (hour:minute with AM/PM).
|
|
36
36
|
*
|
|
37
37
|
* @component
|
|
38
38
|
* @example
|
|
39
39
|
* ```tsx
|
|
40
|
-
* // Default usage - displays
|
|
40
|
+
* // Default usage - displays "10:00 AM"
|
|
41
41
|
* <TimeSlot.StartDate className="text-foreground" />
|
|
42
42
|
*
|
|
43
43
|
* // With custom formatting
|
|
@@ -50,17 +50,20 @@ var TestIds;
|
|
|
50
50
|
*/
|
|
51
51
|
export const StartDate = React.forwardRef((props, ref) => {
|
|
52
52
|
const { asChild, children, className } = props;
|
|
53
|
-
return (_jsx(CoreTimeSlot.Info, { children: ({ startDate }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStartDate, customElement: children, customElementProps: { startDate }, children: _jsx("span", { children: startDate.
|
|
53
|
+
return (_jsx(CoreTimeSlot.Info, { children: ({ startDate }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStartDate, customElement: children, customElementProps: { startDate }, children: _jsx("span", { children: startDate.toLocaleTimeString([], {
|
|
54
|
+
hour: '2-digit',
|
|
55
|
+
minute: '2-digit',
|
|
56
|
+
}) }) })) }));
|
|
54
57
|
});
|
|
55
58
|
StartDate.displayName = 'TimeSlot.StartDate';
|
|
56
59
|
/**
|
|
57
|
-
* Displays the time slot end
|
|
58
|
-
*
|
|
60
|
+
* Displays the time slot end time.
|
|
61
|
+
* Default formatting shows time as "11:00 AM" (hour:minute with AM/PM).
|
|
59
62
|
*
|
|
60
63
|
* @component
|
|
61
64
|
* @example
|
|
62
65
|
* ```tsx
|
|
63
|
-
* // Default usage - displays
|
|
66
|
+
* // Default usage - displays "11:00 AM"
|
|
64
67
|
* <TimeSlot.EndDate className="text-foreground" />
|
|
65
68
|
*
|
|
66
69
|
* // With custom formatting
|
|
@@ -73,7 +76,10 @@ StartDate.displayName = 'TimeSlot.StartDate';
|
|
|
73
76
|
*/
|
|
74
77
|
export const EndDate = React.forwardRef((props, ref) => {
|
|
75
78
|
const { asChild, children, className } = props;
|
|
76
|
-
return (_jsx(CoreTimeSlot.Info, { children: ({ endDate }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotEndDate, customElement: children, customElementProps: { endDate }, children: _jsx("span", { children: endDate.
|
|
79
|
+
return (_jsx(CoreTimeSlot.Info, { children: ({ endDate }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotEndDate, customElement: children, customElementProps: { endDate }, children: _jsx("span", { children: endDate.toLocaleTimeString([], {
|
|
80
|
+
hour: '2-digit',
|
|
81
|
+
minute: '2-digit',
|
|
82
|
+
}) }) })) }));
|
|
77
83
|
});
|
|
78
84
|
EndDate.displayName = 'TimeSlot.EndDate';
|
|
79
85
|
/**
|
|
@@ -101,12 +107,16 @@ export const Duration = React.forwardRef((props, ref) => {
|
|
|
101
107
|
Duration.displayName = 'TimeSlot.Duration';
|
|
102
108
|
/**
|
|
103
109
|
* Button to select this time slot.
|
|
110
|
+
* Default label is "Select".
|
|
104
111
|
*
|
|
105
112
|
* @component
|
|
106
113
|
* @example
|
|
107
114
|
* ```tsx
|
|
108
|
-
* // Default button
|
|
109
|
-
* <TimeSlot.Actions.Select
|
|
115
|
+
* // Default button with "Select" label
|
|
116
|
+
* <TimeSlot.Actions.Select />
|
|
117
|
+
*
|
|
118
|
+
* // With custom label
|
|
119
|
+
* <TimeSlot.Actions.Select label="Book" />
|
|
110
120
|
*
|
|
111
121
|
* // With asChild
|
|
112
122
|
* <TimeSlot.Actions.Select asChild>
|
|
@@ -124,7 +134,7 @@ Duration.displayName = 'TimeSlot.Duration';
|
|
|
124
134
|
* ```
|
|
125
135
|
*/
|
|
126
136
|
export const Select = React.forwardRef((props, ref) => {
|
|
127
|
-
const { asChild, children, className, label } = props;
|
|
137
|
+
const { asChild, children, className, label = 'Select' } = props;
|
|
128
138
|
return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, isSelected, bookable }) => {
|
|
129
139
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionSelect, "data-selected": isSelected, "data-bookable": bookable, customElement: children, customElementProps: {
|
|
130
140
|
onClick: selectTimeSlot,
|
|
@@ -138,11 +148,15 @@ Select.displayName = 'TimeSlot.Actions.Select';
|
|
|
138
148
|
/**
|
|
139
149
|
* Button to clear staff selection while keeping the slot selected.
|
|
140
150
|
* Only renders when a staff member is selected and there are multiple staff options.
|
|
151
|
+
* Default label is "Change".
|
|
141
152
|
*
|
|
142
153
|
* @component
|
|
143
154
|
* @example
|
|
144
155
|
* ```tsx
|
|
145
|
-
* // Default button
|
|
156
|
+
* // Default button with "Change" label
|
|
157
|
+
* <TimeSlot.Actions.ClearStaffSelection />
|
|
158
|
+
*
|
|
159
|
+
* // With custom label
|
|
146
160
|
* <TimeSlot.Actions.ClearStaffSelection label="Change staff" />
|
|
147
161
|
*
|
|
148
162
|
* // With asChild
|
|
@@ -157,7 +171,7 @@ Select.displayName = 'TimeSlot.Actions.Select';
|
|
|
157
171
|
* ```
|
|
158
172
|
*/
|
|
159
173
|
export const ClearStaffSelection = React.forwardRef((props, ref) => {
|
|
160
|
-
const { asChild, children, className, label } = props;
|
|
174
|
+
const { asChild, children, className, label = 'Change' } = props;
|
|
161
175
|
return (_jsx(CoreTimeSlot.Actions, { children: ({ clearStaffSelection }) => {
|
|
162
176
|
if (!clearStaffSelection) {
|
|
163
177
|
return null;
|
|
@@ -278,12 +292,16 @@ export const StaffMemberName = React.forwardRef((props, ref) => {
|
|
|
278
292
|
StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
|
|
279
293
|
/**
|
|
280
294
|
* Button to select this staff member.
|
|
295
|
+
* Default label is "Select".
|
|
281
296
|
*
|
|
282
297
|
* @component
|
|
283
298
|
* @example
|
|
284
299
|
* ```tsx
|
|
285
|
-
* // Default button
|
|
286
|
-
* <TimeSlot.StaffMember.Actions.Select
|
|
300
|
+
* // Default button with "Select" label
|
|
301
|
+
* <TimeSlot.StaffMember.Actions.Select />
|
|
302
|
+
*
|
|
303
|
+
* // With custom label
|
|
304
|
+
* <TimeSlot.StaffMember.Actions.Select label="Choose" />
|
|
287
305
|
*
|
|
288
306
|
* // With asChild
|
|
289
307
|
* <TimeSlot.StaffMember.Actions.Select asChild>
|
|
@@ -301,7 +319,7 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
|
|
|
301
319
|
* ```
|
|
302
320
|
*/
|
|
303
321
|
export const SelectStaffMember = React.forwardRef((props, ref) => {
|
|
304
|
-
const { asChild, children, className, label } = props;
|
|
322
|
+
const { asChild, children, className, label = 'Select' } = props;
|
|
305
323
|
return (_jsx(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
|
|
306
324
|
onClick: selectStaffMember,
|
|
307
325
|
isSelected,
|
|
@@ -190,9 +190,15 @@ export interface DateRangeInputProps {
|
|
|
190
190
|
* Uses the core DateRange component to access service data.
|
|
191
191
|
* Both dates are set together and trigger a single fetch.
|
|
192
192
|
*
|
|
193
|
+
* Default rendering provides two native date inputs.
|
|
194
|
+
*
|
|
193
195
|
* @component
|
|
194
196
|
* @example
|
|
195
197
|
* ```tsx
|
|
198
|
+
* // Default usage - renders two date inputs
|
|
199
|
+
* <TimeSlotList.DateRange.Input className="flex gap-2" />
|
|
200
|
+
*
|
|
201
|
+
* // With asChild for custom rendering
|
|
196
202
|
* <TimeSlotList.DateRange.Input asChild>
|
|
197
203
|
* {({ startDate, endDate, onChange }) => (
|
|
198
204
|
* <MyDateRangePicker
|
|
@@ -9,6 +9,15 @@ import { AsChildSlot } from '@wix/headless-utils/react';
|
|
|
9
9
|
import * as CoreTimeSlotList from '../core/time-slot-list/TimeSlotList.js';
|
|
10
10
|
import { TimeSlotProvider, Info as CoreTimeSlotInfo, } from '../core/time-slot-list/TimeSlot.js';
|
|
11
11
|
import { StartDate as TimeSlotStartDate, EndDate as TimeSlotEndDate, Duration, Actions as TimeSlotActions, Location, StaffMembers, StaffMemberRepeater, StaffMember, } from './TimeSlot.js';
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Utilities
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* Converts a Date to ISO date string format (YYYY-MM-DD) for input[type="date"]
|
|
17
|
+
*/
|
|
18
|
+
function toISODateString(date) {
|
|
19
|
+
return date.toISOString().split('T')[0] ?? '';
|
|
20
|
+
}
|
|
12
21
|
/**
|
|
13
22
|
* TimeSlot with required id field for GenericList
|
|
14
23
|
*/
|
|
@@ -178,9 +187,15 @@ export const Actions = {
|
|
|
178
187
|
* Uses the core DateRange component to access service data.
|
|
179
188
|
* Both dates are set together and trigger a single fetch.
|
|
180
189
|
*
|
|
190
|
+
* Default rendering provides two native date inputs.
|
|
191
|
+
*
|
|
181
192
|
* @component
|
|
182
193
|
* @example
|
|
183
194
|
* ```tsx
|
|
195
|
+
* // Default usage - renders two date inputs
|
|
196
|
+
* <TimeSlotList.DateRange.Input className="flex gap-2" />
|
|
197
|
+
*
|
|
198
|
+
* // With asChild for custom rendering
|
|
184
199
|
* <TimeSlotList.DateRange.Input asChild>
|
|
185
200
|
* {({ startDate, endDate, onChange }) => (
|
|
186
201
|
* <MyDateRangePicker
|
|
@@ -194,11 +209,14 @@ export const Actions = {
|
|
|
194
209
|
*/
|
|
195
210
|
export const DateRangeInput = React.forwardRef((props, ref) => {
|
|
196
211
|
const { asChild, children, className, ...otherProps } = props;
|
|
197
|
-
return (_jsx(CoreTimeSlotList.DateRange, { children: ({ startDate, endDate, setDateRange }) =>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
return (_jsx(CoreTimeSlotList.DateRange, { children: ({ startDate, endDate, setDateRange }) => {
|
|
213
|
+
const defaultContent = (_jsxs("div", { ref: ref, className: className, "data-testid": TestIds.timeSlotListDateRangeInput, children: [_jsx("input", { type: "date", value: toISODateString(startDate), onChange: (e) => setDateRange(new Date(e.target.value), endDate) }), _jsx("span", { children: "-" }), _jsx("input", { type: "date", value: toISODateString(endDate), onChange: (e) => setDateRange(startDate, new Date(e.target.value)) })] }));
|
|
214
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotListDateRangeInput, customElement: children, customElementProps: {
|
|
215
|
+
startDate,
|
|
216
|
+
endDate,
|
|
217
|
+
onChange: setDateRange,
|
|
218
|
+
}, ...otherProps, children: defaultContent }));
|
|
219
|
+
} }));
|
|
202
220
|
});
|
|
203
221
|
DateRangeInput.displayName = 'TimeSlotList.DateRange.Input';
|
|
204
222
|
/**
|
|
@@ -8,3 +8,4 @@ export { TimeSlotListService, TimeSlotListServiceDefinition, ViewMode, loadTimeS
|
|
|
8
8
|
export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListFilters, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
|
|
9
9
|
export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCheckoutParams, } from './booking/book-action/index.js';
|
|
10
10
|
export { BookingFormService, BookingFormServiceDefinition, type BookingFormServiceAPI, type BookingFormServiceConfig, type BookingFormServiceInternalAPI, type ValidationResult, } from './booking-form/booking-form.js';
|
|
11
|
+
export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type SlotService, type LineItemAdditionalInfo, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
|
|
@@ -8,3 +8,4 @@ export { TimeSlotListService, TimeSlotListServiceDefinition, ViewMode, loadTimeS
|
|
|
8
8
|
export { ServiceListService, ServiceListServiceDefinition, loadServiceListServiceInitialData, } from './service-list/service-list.js';
|
|
9
9
|
export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, } from './booking/book-action/index.js';
|
|
10
10
|
export { BookingFormService, BookingFormServiceDefinition, } from './booking-form/booking-form.js';
|
|
11
|
+
export { PaymentService, PaymentServiceDefinition, loadPaymentConfig, } from './payment/payment.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment Service - Pricing calculation and payment details management
|
|
3
|
+
* Handles calculating total prices, taxes, discounts, and deposit information
|
|
4
|
+
* Supports two modes: SSR (config with pre-fetched data) and lazy loading (reactive)
|
|
5
|
+
*/
|
|
6
|
+
import { type PaymentServiceConfig, type PaymentServiceInternalConfig, type SlotService } from './payment.def.js';
|
|
7
|
+
export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type SlotService, } from './payment.def.js';
|
|
8
|
+
export type { PaymentServiceAPI, PaymentServiceInternalConfig, } from './payment.def.js';
|
|
9
|
+
export declare const PaymentService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
10
|
+
__api: import("./payment.def.js").PaymentServiceAPI;
|
|
11
|
+
__config: {};
|
|
12
|
+
isServiceDefinition?: boolean;
|
|
13
|
+
} & import("./payment.def.js").PaymentServiceAPI, PaymentServiceInternalConfig>;
|
|
14
|
+
export type SuccessPaymentConfigResult = {
|
|
15
|
+
type: 'success';
|
|
16
|
+
config: PaymentServiceConfig;
|
|
17
|
+
};
|
|
18
|
+
export type ErrorPaymentConfigResult = {
|
|
19
|
+
type: 'error';
|
|
20
|
+
error: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Load payment configuration for Server-Side Rendering (SSR).
|
|
24
|
+
* Calls the pricing APIs and returns pre-calculated payment details.
|
|
25
|
+
*
|
|
26
|
+
* @param params.slotServices - Slot/service inputs for calculation
|
|
27
|
+
* @param params.numberOfParticipants - Number of participants (default: 1)
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadPaymentConfig(params: {
|
|
30
|
+
slotServices: SlotService[];
|
|
31
|
+
numberOfParticipants?: number;
|
|
32
|
+
}): Promise<SuccessPaymentConfigResult | ErrorPaymentConfigResult>;
|