@crediball/react 0.18.0 → 0.19.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.
@@ -22,8 +22,12 @@ export interface CrediballProviderProps {
22
22
  lowCreditThreshold?: number;
23
23
  /**
24
24
  * Top-up amounts to offer in the paywall (host decides the meaning, e.g. euros).
25
- * Match these to the packages you configured in the Crediball dashboard.
26
- * Ignored once real packages are available (with publishableKey/userId set).
25
+ * Only used in data-less mode (no publishableKey/userId), where there's no
26
+ * dashboard catalog to fall back to and the host is fully responsible for
27
+ * `onTopup`. Ignored whenever publishableKey + userId are set — the paywall
28
+ * then shows your dashboard's real packages, or no top-up button at all if
29
+ * you haven't configured any yet, rather than a button that can't actually
30
+ * charge anything.
27
31
  */
28
32
  amounts?: number[];
29
33
  /**
@@ -88,7 +92,7 @@ export interface CrediballProviderProps {
88
92
  customMax?: number;
89
93
  /**
90
94
  * 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
95
+ * dashboard's Promos → Promotions config: shown automatically once you have
92
96
  * an active Checkout promotion, same as `allowCustom`/custom top-up. Pass
93
97
  * this only to override (e.g. `false` to force-hide it, or `true` to show it
94
98
  * before you've set one up). The code is passed through to
@@ -291,14 +291,20 @@ export function CrediballProvider({ children, publishableKey, userId, apiUrl, po
291
291
  const effectiveCustomMin = customMin ?? customCfg?.minEur;
292
292
  const effectiveCustomMax = customMax ?? customCfg?.maxEur ?? undefined;
293
293
  // Same auto-derivation for the promo-code field: a developer who set up a
294
- // Checkout promotion in Growth gets the field for free, no code change.
294
+ // Checkout promotion in Promos gets the field for free, no code change.
295
295
  const effectiveAllowPromoCode = allowPromoCode ?? pkgs?.hasActiveCheckoutPromotion ?? false;
296
296
  // Published theme → --crediball-* CSS vars, applied on a display:contents
297
297
  // wrapper so it themes every descendant (and the paywall) without adding a
298
298
  // layout box. Host props/CSS are overridden by design (dashboard wins).
299
299
  const themeVars = applyRemoteTheme ? themeToCssVars(uiTheme, resolvedColorScheme) : {};
300
300
  const hasThemeVars = Object.keys(themeVars).length > 0;
301
- 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, referredReward: referral?.referredRewardCredits, referralLabel: uiContent?.referralLabel, checkoutError: checkoutError, accentColor: accentColor })] }));
301
+ 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,
302
+ // Connected to live dashboard data: the legacy flat-amounts fallback
303
+ // only makes sense when there's no catalog to consult at all (see the
304
+ // `amounts` prop doc). Once a client exists, no packages configured
305
+ // means no top-up button — never a button whose checkout is
306
+ // guaranteed to fail.
307
+ amounts: client ? [] : 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, referredReward: referral?.referredRewardCredits, referralLabel: uiContent?.referralLabel, checkoutError: checkoutError, accentColor: accentColor })] }));
302
308
  const configCtx = useMemo(() => ({ publishableKey, userId, apiUrl }), [publishableKey, userId, apiUrl]);
303
309
  return (_jsx(CrediballContext.Provider, { value: ctx, children: _jsx(CrediballConfigContext.Provider, { value: configCtx, children: hasThemeVars ? (_jsx("div", { style: { display: "contents", ...themeVars }, children: inner })) : (inner) }) }));
304
310
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crediball/react",
3
- "version": "0.18.0",
3
+ "version": "0.19.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>",