@crediball/react 0.14.0 → 0.15.0
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.
|
@@ -87,8 +87,11 @@ export interface CrediballProviderProps {
|
|
|
87
87
|
/** Override the custom-amount maximum (defaults to the dashboard's configured maximum). */
|
|
88
88
|
customMax?: number;
|
|
89
89
|
/**
|
|
90
|
-
* Show a "Have a promo code?" field in the paywall
|
|
91
|
-
*
|
|
90
|
+
* Show a "Have a promo code?" field in the paywall. Auto-derived from your
|
|
91
|
+
* dashboard's Growth → Promotions config: shown automatically once you have
|
|
92
|
+
* an active Checkout promotion, same as `allowCustom`/custom top-up. Pass
|
|
93
|
+
* this only to override (e.g. `false` to force-hide it, or `true` to show it
|
|
94
|
+
* before you've set one up). The code is passed through to
|
|
92
95
|
* `onSelectPackage`/`onTopup`, or included automatically in the built-in
|
|
93
96
|
* checkout when neither is provided.
|
|
94
97
|
*/
|
|
@@ -261,12 +261,15 @@ export function CrediballProvider({ children, publishableKey, userId, apiUrl, po
|
|
|
261
261
|
const effectiveAllowCustom = allowCustom ?? customCfg?.enabled ?? false;
|
|
262
262
|
const effectiveCustomMin = customMin ?? customCfg?.minEur;
|
|
263
263
|
const effectiveCustomMax = customMax ?? customCfg?.maxEur ?? undefined;
|
|
264
|
+
// Same auto-derivation for the promo-code field: a developer who set up a
|
|
265
|
+
// Checkout promotion in Growth gets the field for free, no code change.
|
|
266
|
+
const effectiveAllowPromoCode = allowPromoCode ?? pkgs?.hasActiveCheckoutPromotion ?? false;
|
|
264
267
|
// Published theme → --crediball-* CSS vars, applied on a display:contents
|
|
265
268
|
// wrapper so it themes every descendant (and the paywall) without adding a
|
|
266
269
|
// layout box. Host props/CSS are overridden by design (dashboard wins).
|
|
267
270
|
const themeVars = applyRemoteTheme ? themeToCssVars(uiTheme) : {};
|
|
268
271
|
const hasThemeVars = Object.keys(themeVars).length > 0;
|
|
269
|
-
const inner = (_jsxs(_Fragment, { children: [children, _jsx(PaywallModal, { open: open, packages: pkgs?.packages, onSelectPackage: handleSelectPackage, subscriptionPlans: pkgs?.subscriptionPlans, onSelectPlan: handleSelectPlan, activeSubscription: pkgs?.activeSubscription, onCancelSubscription: onCancelSubscription ? handleCancelSubscription : undefined, autoTopup: pkgs?.autoTopup, onEnableAutoTopup: handleEnableAutoTopup, amounts: amounts, amountPrefix: `Add ${currencySymbol}`, onAdd: handleAdd, onClose: hidePaywall, allowCustom: effectiveAllowCustom, customMin: effectiveCustomMin, customMax: effectiveCustomMax, allowPromoCode:
|
|
272
|
+
const inner = (_jsxs(_Fragment, { children: [children, _jsx(PaywallModal, { open: open, packages: pkgs?.packages, onSelectPackage: handleSelectPackage, subscriptionPlans: pkgs?.subscriptionPlans, onSelectPlan: handleSelectPlan, activeSubscription: pkgs?.activeSubscription, onCancelSubscription: onCancelSubscription ? handleCancelSubscription : undefined, autoTopup: pkgs?.autoTopup, onEnableAutoTopup: handleEnableAutoTopup, amounts: amounts, amountPrefix: `Add ${currencySymbol}`, onAdd: handleAdd, onClose: hidePaywall, allowCustom: effectiveAllowCustom, customMin: effectiveCustomMin, customMax: effectiveCustomMax, allowPromoCode: effectiveAllowPromoCode, promoCodeLabel: promoCodeLabel, customTopupRate: pkgs?.customTopup.enabled ? pkgs.customTopup.rate : undefined, currencySymbol: currencySymbol, balance: snapshot.balance ?? undefined, balanceRate: pkgs?.customTopup.enabled ? pkgs.customTopup.rate : undefined, currency: pkgs?.currency, usage: snapshot.usage?.usedCredits ?? undefined, title: title ?? uiContent?.paywallTitle, description: description ?? uiContent?.paywallDescription, addButtonText: uiContent?.paywallButtonText, referralLink: referral?.link ?? undefined, referralReward: referral?.rewardCredits, referralLabel: uiContent?.referralLabel, accentColor: accentColor })] }));
|
|
270
273
|
const configCtx = useMemo(() => ({ publishableKey, userId, apiUrl }), [publishableKey, userId, apiUrl]);
|
|
271
274
|
return (_jsx(CrediballContext.Provider, { value: ctx, children: _jsx(CrediballConfigContext.Provider, { value: configCtx, children: hasThemeVars ? (_jsx("div", { style: { display: "contents", ...themeVars }, children: inner })) : (inner) }) }));
|
|
272
275
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crediball/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Drop-in React components for showing Crediball credits inside your AI app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Filippo Rezzadore <filipporezzadore@gmail.com>",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react": ">=18"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@crediball/core": "^0.
|
|
54
|
+
"@crediball/core": "^0.9.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/react": "^18.3.11",
|