@bunnyapp/components 1.7.0-beta.23 → 1.7.0-beta.25
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/dist/cjs/index.js +63 -33
- package/dist/cjs/types/src/components/PaymentForm/PaymentForm.d.ts +2 -1
- package/dist/cjs/types/src/components/PaymentForm/hooks/usePayableCurrency.d.ts +2 -1
- package/dist/esm/index.js +63 -33
- package/dist/esm/types/src/components/PaymentForm/PaymentForm.d.ts +2 -1
- package/dist/esm/types/src/components/PaymentForm/hooks/usePayableCurrency.d.ts +2 -1
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1283,7 +1283,7 @@ const DEFAULT_CONFIG = {
|
|
|
1283
1283
|
};
|
|
1284
1284
|
|
|
1285
1285
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1286
|
-
const PACKAGE_VERSION = '1.7.0-beta.
|
|
1286
|
+
const PACKAGE_VERSION = '1.7.0-beta.24';
|
|
1287
1287
|
const createRequestHeaders = (token) => {
|
|
1288
1288
|
const headers = createClientDevHeaders({ token });
|
|
1289
1289
|
// Add the components version header
|
|
@@ -20267,36 +20267,63 @@ const useStripePlugin = (plugin, currencyId, accountId) => {
|
|
|
20267
20267
|
// Hooks
|
|
20268
20268
|
const showErrorNotification = useErrorNotification();
|
|
20269
20269
|
const { token: antdToken } = useAntdToken$1();
|
|
20270
|
-
|
|
20271
|
-
|
|
20270
|
+
const fontFamily = react.useMemo(() => {
|
|
20271
|
+
const baseFontFamily = antdToken.fontFamily;
|
|
20272
|
+
// If it's the default Inter font, use the CSS variable with fallbacks
|
|
20273
|
+
if (baseFontFamily === 'Inter') {
|
|
20272
20274
|
return 'var(--font-inter, Inter), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
20273
20275
|
}
|
|
20274
|
-
|
|
20275
|
-
|
|
20276
|
-
|
|
20277
|
-
|
|
20278
|
-
|
|
20279
|
-
|
|
20280
|
-
|
|
20281
|
-
|
|
20282
|
-
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
rules: {
|
|
20286
|
-
'.Input': {
|
|
20276
|
+
// For custom fonts, ensure we have proper fallbacks
|
|
20277
|
+
// Check if the font family already includes fallbacks (contains a comma)
|
|
20278
|
+
if (baseFontFamily.includes(',')) {
|
|
20279
|
+
return baseFontFamily;
|
|
20280
|
+
}
|
|
20281
|
+
// Add system font fallbacks for custom fonts
|
|
20282
|
+
return `${baseFontFamily}, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
|
|
20283
|
+
}, [antdToken.fontFamily]);
|
|
20284
|
+
const options = react.useMemo(() => {
|
|
20285
|
+
const appearance = {
|
|
20286
|
+
variables: {
|
|
20287
20287
|
fontFamily: fontFamily,
|
|
20288
|
+
fontLineHeight: antdToken.lineHeight.toString(),
|
|
20289
|
+
borderRadius: antdToken.borderRadius.toString() + 'px',
|
|
20290
|
+
colorBackground: 'white',
|
|
20291
|
+
colorPrimary: antdToken.colorPrimary,
|
|
20288
20292
|
},
|
|
20289
|
-
|
|
20290
|
-
|
|
20293
|
+
rules: {
|
|
20294
|
+
'.Input': {
|
|
20295
|
+
fontFamily: fontFamily,
|
|
20296
|
+
},
|
|
20297
|
+
'.Label': {
|
|
20298
|
+
fontFamily: fontFamily,
|
|
20299
|
+
},
|
|
20300
|
+
'.Text': {
|
|
20301
|
+
fontFamily: fontFamily,
|
|
20302
|
+
},
|
|
20303
|
+
'.Tab': {
|
|
20304
|
+
fontFamily: fontFamily,
|
|
20305
|
+
},
|
|
20306
|
+
'.TabLabel': {
|
|
20307
|
+
fontFamily: fontFamily,
|
|
20308
|
+
},
|
|
20309
|
+
'.Error': {
|
|
20310
|
+
fontFamily: fontFamily,
|
|
20311
|
+
},
|
|
20291
20312
|
},
|
|
20292
|
-
}
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
20298
|
-
|
|
20299
|
-
}
|
|
20313
|
+
};
|
|
20314
|
+
return {
|
|
20315
|
+
mode: 'setup',
|
|
20316
|
+
currency: currencyId,
|
|
20317
|
+
setupFutureUsage: 'off_session',
|
|
20318
|
+
appearance,
|
|
20319
|
+
};
|
|
20320
|
+
}, [
|
|
20321
|
+
fontFamily,
|
|
20322
|
+
antdToken.lineHeight,
|
|
20323
|
+
antdToken.borderRadius,
|
|
20324
|
+
antdToken.colorPrimary,
|
|
20325
|
+
currencyId,
|
|
20326
|
+
]);
|
|
20300
20327
|
react.useEffect(() => {
|
|
20301
20328
|
var _a, _b;
|
|
20302
20329
|
if (!plugin)
|
|
@@ -20438,8 +20465,8 @@ function usePay({ onPaymentSuccess, onPaymentError, quoteId, invoice, plugin, })
|
|
|
20438
20465
|
onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
|
|
20439
20466
|
}
|
|
20440
20467
|
else {
|
|
20441
|
-
if (!quoteId) {
|
|
20442
|
-
showErrorNotification$8('Quote ID is required');
|
|
20468
|
+
if (!quoteId && !(invoice === null || invoice === void 0 ? void 0 : invoice.id)) {
|
|
20469
|
+
showErrorNotification$8('Quote ID or Invoice ID is required');
|
|
20443
20470
|
return;
|
|
20444
20471
|
}
|
|
20445
20472
|
const response = await checkout({
|
|
@@ -21138,12 +21165,13 @@ const useCurrentUserData = (token) => {
|
|
|
21138
21165
|
return { currentUser, isCurrentUserDataLoading };
|
|
21139
21166
|
};
|
|
21140
21167
|
|
|
21141
|
-
function usePayableCurrency({ payableCurrencyId }) {
|
|
21168
|
+
function usePayableCurrency({ payableCurrencyId, accountCurrencyId }) {
|
|
21169
|
+
var _a;
|
|
21142
21170
|
const token = useToken();
|
|
21143
21171
|
const { currentUser, isCurrentUserDataLoading } = useCurrentUserData(token);
|
|
21144
21172
|
const account = currentUser === null || currentUser === void 0 ? void 0 : currentUser.account;
|
|
21145
|
-
const
|
|
21146
|
-
const currencyId = react.useMemo(() => { var _a; return (_a = (
|
|
21173
|
+
const accountCurrencyIdValue = (_a = account === null || account === void 0 ? void 0 : account.currencyId) !== null && _a !== void 0 ? _a : accountCurrencyId;
|
|
21174
|
+
const currencyId = react.useMemo(() => { var _a; return (_a = (accountCurrencyIdValue !== null && accountCurrencyIdValue !== void 0 ? accountCurrencyIdValue : payableCurrencyId)) === null || _a === void 0 ? void 0 : _a.toLowerCase(); }, [accountCurrencyIdValue, payableCurrencyId]);
|
|
21147
21175
|
return { currencyId, isCurrencyIdLoading: isCurrentUserDataLoading };
|
|
21148
21176
|
}
|
|
21149
21177
|
|
|
@@ -21261,11 +21289,13 @@ const PaymentForm_QuoteFragment = t(`
|
|
|
21261
21289
|
...PaymentProvider_QuoteFragment
|
|
21262
21290
|
}
|
|
21263
21291
|
`, [PaymentProvider_QuoteFragment]);
|
|
21264
|
-
function PaymentForm({ invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }) {
|
|
21292
|
+
function PaymentForm({ currencyId: accountCurrencyId, invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }) {
|
|
21293
|
+
var _a;
|
|
21265
21294
|
// Read fragments
|
|
21266
21295
|
const quote = readFragment(PaymentForm_QuoteFragment, maskedQuote);
|
|
21267
21296
|
const { currencyId, isCurrencyIdLoading } = usePayableCurrency({
|
|
21268
|
-
payableCurrencyId: (quote === null || quote === void 0 ? void 0 : quote.currencyId)
|
|
21297
|
+
payableCurrencyId: (_a = quote === null || quote === void 0 ? void 0 : quote.currencyId) !== null && _a !== void 0 ? _a : invoice === null || invoice === void 0 ? void 0 : invoice.currencyId,
|
|
21298
|
+
accountCurrencyId,
|
|
21269
21299
|
});
|
|
21270
21300
|
// Return early because PaymentForm should not be rendered without a valid currency ID.
|
|
21271
21301
|
// For example, sepa / iDeal may not show for Dutch customer if no currencyId
|
|
@@ -14,7 +14,8 @@ export declare const PaymentForm_QuoteFragment: import("gql.tada").TadaDocumentN
|
|
|
14
14
|
on: "Quote";
|
|
15
15
|
masked: true;
|
|
16
16
|
}>;
|
|
17
|
-
export declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }: {
|
|
17
|
+
export declare function PaymentForm({ currencyId: accountCurrencyId, invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }: {
|
|
18
|
+
currencyId?: string;
|
|
18
19
|
invoice?: FormattedInvoice | Invoice;
|
|
19
20
|
quote?: FragmentOf<typeof PaymentForm_QuoteFragment>;
|
|
20
21
|
onPaymentSuccess?: (response: any) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare function usePayableCurrency({ payableCurrencyId }: {
|
|
1
|
+
export declare function usePayableCurrency({ payableCurrencyId, accountCurrencyId }: {
|
|
2
2
|
payableCurrencyId?: string;
|
|
3
|
+
accountCurrencyId?: string;
|
|
3
4
|
}): {
|
|
4
5
|
currencyId: string | undefined;
|
|
5
6
|
isCurrencyIdLoading: boolean;
|
package/dist/esm/index.js
CHANGED
|
@@ -1281,7 +1281,7 @@ const DEFAULT_CONFIG = {
|
|
|
1281
1281
|
};
|
|
1282
1282
|
|
|
1283
1283
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1284
|
-
const PACKAGE_VERSION = '1.7.0-beta.
|
|
1284
|
+
const PACKAGE_VERSION = '1.7.0-beta.24';
|
|
1285
1285
|
const createRequestHeaders = (token) => {
|
|
1286
1286
|
const headers = createClientDevHeaders({ token });
|
|
1287
1287
|
// Add the components version header
|
|
@@ -20265,36 +20265,63 @@ const useStripePlugin = (plugin, currencyId, accountId) => {
|
|
|
20265
20265
|
// Hooks
|
|
20266
20266
|
const showErrorNotification = useErrorNotification();
|
|
20267
20267
|
const { token: antdToken } = useAntdToken$1();
|
|
20268
|
-
|
|
20269
|
-
|
|
20268
|
+
const fontFamily = useMemo(() => {
|
|
20269
|
+
const baseFontFamily = antdToken.fontFamily;
|
|
20270
|
+
// If it's the default Inter font, use the CSS variable with fallbacks
|
|
20271
|
+
if (baseFontFamily === 'Inter') {
|
|
20270
20272
|
return 'var(--font-inter, Inter), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
20271
20273
|
}
|
|
20272
|
-
|
|
20273
|
-
|
|
20274
|
-
|
|
20275
|
-
|
|
20276
|
-
|
|
20277
|
-
|
|
20278
|
-
|
|
20279
|
-
|
|
20280
|
-
|
|
20281
|
-
|
|
20282
|
-
|
|
20283
|
-
rules: {
|
|
20284
|
-
'.Input': {
|
|
20274
|
+
// For custom fonts, ensure we have proper fallbacks
|
|
20275
|
+
// Check if the font family already includes fallbacks (contains a comma)
|
|
20276
|
+
if (baseFontFamily.includes(',')) {
|
|
20277
|
+
return baseFontFamily;
|
|
20278
|
+
}
|
|
20279
|
+
// Add system font fallbacks for custom fonts
|
|
20280
|
+
return `${baseFontFamily}, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
|
|
20281
|
+
}, [antdToken.fontFamily]);
|
|
20282
|
+
const options = useMemo(() => {
|
|
20283
|
+
const appearance = {
|
|
20284
|
+
variables: {
|
|
20285
20285
|
fontFamily: fontFamily,
|
|
20286
|
+
fontLineHeight: antdToken.lineHeight.toString(),
|
|
20287
|
+
borderRadius: antdToken.borderRadius.toString() + 'px',
|
|
20288
|
+
colorBackground: 'white',
|
|
20289
|
+
colorPrimary: antdToken.colorPrimary,
|
|
20286
20290
|
},
|
|
20287
|
-
|
|
20288
|
-
|
|
20291
|
+
rules: {
|
|
20292
|
+
'.Input': {
|
|
20293
|
+
fontFamily: fontFamily,
|
|
20294
|
+
},
|
|
20295
|
+
'.Label': {
|
|
20296
|
+
fontFamily: fontFamily,
|
|
20297
|
+
},
|
|
20298
|
+
'.Text': {
|
|
20299
|
+
fontFamily: fontFamily,
|
|
20300
|
+
},
|
|
20301
|
+
'.Tab': {
|
|
20302
|
+
fontFamily: fontFamily,
|
|
20303
|
+
},
|
|
20304
|
+
'.TabLabel': {
|
|
20305
|
+
fontFamily: fontFamily,
|
|
20306
|
+
},
|
|
20307
|
+
'.Error': {
|
|
20308
|
+
fontFamily: fontFamily,
|
|
20309
|
+
},
|
|
20289
20310
|
},
|
|
20290
|
-
}
|
|
20291
|
-
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
}
|
|
20311
|
+
};
|
|
20312
|
+
return {
|
|
20313
|
+
mode: 'setup',
|
|
20314
|
+
currency: currencyId,
|
|
20315
|
+
setupFutureUsage: 'off_session',
|
|
20316
|
+
appearance,
|
|
20317
|
+
};
|
|
20318
|
+
}, [
|
|
20319
|
+
fontFamily,
|
|
20320
|
+
antdToken.lineHeight,
|
|
20321
|
+
antdToken.borderRadius,
|
|
20322
|
+
antdToken.colorPrimary,
|
|
20323
|
+
currencyId,
|
|
20324
|
+
]);
|
|
20298
20325
|
useEffect(() => {
|
|
20299
20326
|
var _a, _b;
|
|
20300
20327
|
if (!plugin)
|
|
@@ -20436,8 +20463,8 @@ function usePay({ onPaymentSuccess, onPaymentError, quoteId, invoice, plugin, })
|
|
|
20436
20463
|
onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
|
|
20437
20464
|
}
|
|
20438
20465
|
else {
|
|
20439
|
-
if (!quoteId) {
|
|
20440
|
-
showErrorNotification$8('Quote ID is required');
|
|
20466
|
+
if (!quoteId && !(invoice === null || invoice === void 0 ? void 0 : invoice.id)) {
|
|
20467
|
+
showErrorNotification$8('Quote ID or Invoice ID is required');
|
|
20441
20468
|
return;
|
|
20442
20469
|
}
|
|
20443
20470
|
const response = await checkout({
|
|
@@ -21136,12 +21163,13 @@ const useCurrentUserData = (token) => {
|
|
|
21136
21163
|
return { currentUser, isCurrentUserDataLoading };
|
|
21137
21164
|
};
|
|
21138
21165
|
|
|
21139
|
-
function usePayableCurrency({ payableCurrencyId }) {
|
|
21166
|
+
function usePayableCurrency({ payableCurrencyId, accountCurrencyId }) {
|
|
21167
|
+
var _a;
|
|
21140
21168
|
const token = useToken();
|
|
21141
21169
|
const { currentUser, isCurrentUserDataLoading } = useCurrentUserData(token);
|
|
21142
21170
|
const account = currentUser === null || currentUser === void 0 ? void 0 : currentUser.account;
|
|
21143
|
-
const
|
|
21144
|
-
const currencyId = useMemo(() => { var _a; return (_a = (
|
|
21171
|
+
const accountCurrencyIdValue = (_a = account === null || account === void 0 ? void 0 : account.currencyId) !== null && _a !== void 0 ? _a : accountCurrencyId;
|
|
21172
|
+
const currencyId = useMemo(() => { var _a; return (_a = (accountCurrencyIdValue !== null && accountCurrencyIdValue !== void 0 ? accountCurrencyIdValue : payableCurrencyId)) === null || _a === void 0 ? void 0 : _a.toLowerCase(); }, [accountCurrencyIdValue, payableCurrencyId]);
|
|
21145
21173
|
return { currencyId, isCurrencyIdLoading: isCurrentUserDataLoading };
|
|
21146
21174
|
}
|
|
21147
21175
|
|
|
@@ -21259,11 +21287,13 @@ const PaymentForm_QuoteFragment = t(`
|
|
|
21259
21287
|
...PaymentProvider_QuoteFragment
|
|
21260
21288
|
}
|
|
21261
21289
|
`, [PaymentProvider_QuoteFragment]);
|
|
21262
|
-
function PaymentForm({ invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }) {
|
|
21290
|
+
function PaymentForm({ currencyId: accountCurrencyId, invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }) {
|
|
21291
|
+
var _a;
|
|
21263
21292
|
// Read fragments
|
|
21264
21293
|
const quote = readFragment(PaymentForm_QuoteFragment, maskedQuote);
|
|
21265
21294
|
const { currencyId, isCurrencyIdLoading } = usePayableCurrency({
|
|
21266
|
-
payableCurrencyId: (quote === null || quote === void 0 ? void 0 : quote.currencyId)
|
|
21295
|
+
payableCurrencyId: (_a = quote === null || quote === void 0 ? void 0 : quote.currencyId) !== null && _a !== void 0 ? _a : invoice === null || invoice === void 0 ? void 0 : invoice.currencyId,
|
|
21296
|
+
accountCurrencyId,
|
|
21267
21297
|
});
|
|
21268
21298
|
// Return early because PaymentForm should not be rendered without a valid currency ID.
|
|
21269
21299
|
// For example, sepa / iDeal may not show for Dutch customer if no currencyId
|
|
@@ -14,7 +14,8 @@ export declare const PaymentForm_QuoteFragment: import("gql.tada").TadaDocumentN
|
|
|
14
14
|
on: "Quote";
|
|
15
15
|
masked: true;
|
|
16
16
|
}>;
|
|
17
|
-
export declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }: {
|
|
17
|
+
export declare function PaymentForm({ currencyId: accountCurrencyId, invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }: {
|
|
18
|
+
currencyId?: string;
|
|
18
19
|
invoice?: FormattedInvoice | Invoice;
|
|
19
20
|
quote?: FragmentOf<typeof PaymentForm_QuoteFragment>;
|
|
20
21
|
onPaymentSuccess?: (response: any) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare function usePayableCurrency({ payableCurrencyId }: {
|
|
1
|
+
export declare function usePayableCurrency({ payableCurrencyId, accountCurrencyId }: {
|
|
2
2
|
payableCurrencyId?: string;
|
|
3
|
+
accountCurrencyId?: string;
|
|
3
4
|
}): {
|
|
4
5
|
currencyId: string | undefined;
|
|
5
6
|
isCurrencyIdLoading: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -107,7 +107,8 @@ declare const PaymentForm_QuoteFragment: gql_tada.TadaDocumentNode<{
|
|
|
107
107
|
on: "Quote";
|
|
108
108
|
masked: true;
|
|
109
109
|
}>;
|
|
110
|
-
declare function PaymentForm({ invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }: {
|
|
110
|
+
declare function PaymentForm({ currencyId: accountCurrencyId, invoice, quote: maskedQuote, onPaymentSuccess, onPaymentHoldSuccess, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, paymentHoldOptions, }: {
|
|
111
|
+
currencyId?: string;
|
|
111
112
|
invoice?: FormattedInvoice | Invoice$1;
|
|
112
113
|
quote?: FragmentOf<typeof PaymentForm_QuoteFragment>;
|
|
113
114
|
onPaymentSuccess?: (response: any) => void;
|
package/package.json
CHANGED