@solvapay/react 2.1.1 → 2.2.0-preview-11dbbe603cd1b9a44cc41b5eee3686bc4000f97f

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/index.d.cts CHANGED
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, B as BalanceStatus, q as UseTopupAmountSelectorOptions, r as UseTopupAmountSelectorReturn, s as UsePaymentMethodReturn, t as AutoRechargeConfig, u as SaveAutoRechargeInput, v as SolvaPayTransport, w as PartialSolvaPayCopy, x as PurchaseInfo, y as Product, z as SolvaPayConfig } from './shared-D0hmT1qU.cjs';
3
- export { D as BootstrapPlanLike, E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError } from './shared-D0hmT1qU.cjs';
4
- import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-SylJb9Rh.cjs';
5
- export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UsageSnapshot, x as UseCheckoutFlowOptions, y as UseCheckoutFlowReturn, z as UseUsageReturn, D as configToAutoRechargeInput, E as deriveVariant, F as useCheckoutFlow, G as useCheckoutStepsContext, H as useUsage } from './index-SylJb9Rh.cjs';
2
+ import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, B as BootstrapPlanLike, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, q as BalanceStatus, r as UseTopupAmountSelectorOptions, s as UseTopupAmountSelectorReturn, t as UsePaymentMethodReturn, u as AutoRechargeConfig, v as SaveAutoRechargeInput, w as SolvaPayTransport, x as PartialSolvaPayCopy, y as PurchaseInfo, z as Product, D as SolvaPayConfig } from './shared-BQbMyX5V.cjs';
3
+ export { E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError } from './shared-BQbMyX5V.cjs';
4
+ import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-APG9WYgS.cjs';
5
+ export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UsageSnapshot, x as UseCheckoutFlowOptions, y as UseCheckoutFlowReturn, z as UseUsageReturn, D as configToAutoRechargeInput, E as deriveVariant, F as useCheckoutFlow, G as useCheckoutStepsContext, H as useUsage } from './index-APG9WYgS.cjs';
6
6
  import { PaymentIntent, Stripe, StripeElements } from '@stripe/stripe-js';
7
7
  import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
8
+ import * as react_jsx_runtime from 'react/jsx-runtime';
8
9
  export { AuthAdapter, createAnonymousAuthAdapter, defaultAuthAdapter, getOrCreateAnonymousCustomerRef, resetAnonymousCustomerRef } from './adapters/auth.cjs';
9
10
  export { SessionAuthAdapterOptions, createSessionAuthAdapter } from './adapters/session-auth.cjs';
10
11
  import '@stripe/react-stripe-js';
11
- import 'react/jsx-runtime';
12
12
 
13
13
  /**
14
14
  * SolvaPay Provider - Headless Context Provider for React.
@@ -305,6 +305,8 @@ interface CurrentPlanCardClassNames {
305
305
  usageMeter?: string;
306
306
  paymentMethod?: string;
307
307
  actions?: string;
308
+ /** Small muted caption above a value when `showFieldLabels` is set. */
309
+ fieldLabel?: string;
308
310
  /** Embedded pending-cancellation notice + reactivate CTA. */
309
311
  cancelledNotice?: string;
310
312
  }
@@ -351,6 +353,17 @@ interface CurrentPlanCardProps {
351
353
  * Hosted-page parity for the MCP account surface.
352
354
  */
353
355
  showReference?: boolean;
356
+ /**
357
+ * Caption the price/rate and balance values with a field label
358
+ * ("Rate", "Balance"). Default: `false`. Those lines are bare
359
+ * numbers otherwise, which read alike on a surface that shows both.
360
+ */
361
+ showFieldLabels?: boolean;
362
+ /**
363
+ * Live catalog plans. Used to format a PAYG usage rate when the
364
+ * frozen snapshot has no `options[]`.
365
+ */
366
+ plans?: readonly CatalogPlanLike[];
354
367
  /** Per-element classNames. */
355
368
  classNames?: CurrentPlanCardClassNames;
356
369
  /**
@@ -359,6 +372,20 @@ interface CurrentPlanCardProps {
359
372
  */
360
373
  className?: string;
361
374
  }
375
+ /**
376
+ * Structural catalog / snapshot subset `formatPaygRate` can read.
377
+ * Wider than `BootstrapPlanLike` so MCP `PlanLike` (which allows `null`
378
+ * on optional fields) is assignable without a cast.
379
+ */
380
+ interface CatalogPlanLike {
381
+ reference?: string | null;
382
+ name?: string;
383
+ options?: BootstrapPlanLike['options'] | null;
384
+ price?: number | null;
385
+ currency?: string | null;
386
+ requiresPayment?: boolean | null;
387
+ isMetered?: boolean | null;
388
+ }
362
389
  declare const CurrentPlanCard: React.FC<CurrentPlanCardProps>;
363
390
 
364
391
  type AutoRechargeProps = {
@@ -381,17 +408,18 @@ declare function AutoRecharge({ currency, defaultThresholdAmountMajor, defaultTo
381
408
  * Render-eager: the button is enabled and labelled from the first paint
382
409
  * regardless of session state. The portal session URL is fetched in the
383
410
  * background through `useCustomerSessionUrl()` (a single in-flight call
384
- * shared across every instance under the same transport). When the URL
385
- * is ready, click is a synchronous `<a target="_blank">` navigation —
386
- * which MCP host sandboxes permit even though scripted `window.open`
387
- * after an async round-trip is blocked.
388
- *
389
- * If the user clicks before the URL has resolved, the click handler
390
- * awaits the in-flight fetch and falls back to `window.open` (works on
391
- * hosts that don't sandbox scripted opens, e.g. ChatGPT). On Claude the
392
- * sandbox silently drops the open in that race; the cache-hit path
393
- * remains the optimal one and is the steady state for any user that
394
- * doesn't click within a few hundred ms of opening the surface.
411
+ * shared across every instance under the same transport).
412
+ *
413
+ * Opening the portal always goes through `useExternalLink`, which
414
+ * prefers the host's `ui/open-link` when one is mounted and otherwise
415
+ * lets the browser navigate. That distinction matters inside MCP hosts:
416
+ * Claude's iframe sandbox omits `allow-popups`, so both a bare
417
+ * `<a target="_blank">` and `window.open()` are dropped without an
418
+ * error — the button looks alive and does nothing.
419
+ *
420
+ * If the user clicks before the URL has resolved, the handler awaits
421
+ * the in-flight fetch and then opens the resolved URL through the same
422
+ * path, flipping to the error state if the open is refused.
395
423
  */
396
424
 
397
425
  interface LaunchCustomerPortalButtonProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel' | 'onError'> {
@@ -1001,6 +1029,43 @@ interface UsePaywallResolverReturn {
1001
1029
  }
1002
1030
  declare function usePaywallResolver(content: PaywallStructuredContent): UsePaywallResolverReturn;
1003
1031
 
1032
+ interface ExternalLinkOpener {
1033
+ /**
1034
+ * Whether the host can open links right now. Read synchronously from
1035
+ * the click handler, because suppressing native navigation on a host
1036
+ * that *cannot* open links would turn a working link into a dead one
1037
+ * — so `preventDefault()` is gated on this returning `true`.
1038
+ */
1039
+ canOpen: () => boolean;
1040
+ /**
1041
+ * Hand `url` to the host. Resolves `false` when the host refused
1042
+ * (blocked domain, user cancelled) or the request failed, so callers
1043
+ * can surface the dead end instead of leaving the user guessing.
1044
+ */
1045
+ open: (url: string) => Promise<boolean>;
1046
+ }
1047
+ interface ExternalLinkProviderProps {
1048
+ opener: ExternalLinkOpener;
1049
+ children: React.ReactNode;
1050
+ }
1051
+ declare function ExternalLinkProvider({ opener, children }: ExternalLinkProviderProps): react_jsx_runtime.JSX.Element;
1052
+ /**
1053
+ * Imperative opener for flows that only learn the URL after an `await`,
1054
+ * where there is no anchor left to click (the portal button's
1055
+ * cache-miss path). Prefers the host, otherwise asks the browser.
1056
+ *
1057
+ * Resolves `false` only when a host-mediated open was attempted and
1058
+ * refused. The browser path reports `true` because it cannot be
1059
+ * verified: `window.open` with `noopener` returns `null` on success by
1060
+ * spec, so a null handle says nothing about whether the tab opened.
1061
+ */
1062
+ declare function useOpenExternal(): (url: string) => Promise<boolean>;
1063
+ /**
1064
+ * `onClick` for any `<a href target="_blank">` the SDK renders. A no-op
1065
+ * when no host opener is mounted, which leaves the browser to navigate.
1066
+ */
1067
+ declare function useExternalLinkClick(): (event: React.MouseEvent<HTMLAnchorElement>) => void;
1068
+
1004
1069
  type CopyContextValue = {
1005
1070
  locale?: string;
1006
1071
  copy: SolvaPayCopy;
@@ -1258,4 +1323,4 @@ declare const DEFAULT_ROUTES: {
1258
1323
  };
1259
1324
  declare function createHttpTransport(config: SolvaPayConfig | undefined): SolvaPayTransport;
1260
1325
 
1261
- export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useLimits, useLocale, useMerchant, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };
1326
+ export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, BootstrapPlanLike, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type ExternalLinkOpener, ExternalLinkProvider, type ExternalLinkProviderProps, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useExternalLinkClick, useLimits, useLocale, useMerchant, useOpenExternal, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, B as BalanceStatus, q as UseTopupAmountSelectorOptions, r as UseTopupAmountSelectorReturn, s as UsePaymentMethodReturn, t as AutoRechargeConfig, u as SaveAutoRechargeInput, v as SolvaPayTransport, w as PartialSolvaPayCopy, x as PurchaseInfo, y as Product, z as SolvaPayConfig } from './shared-CUl6mTC1.js';
3
- export { D as BootstrapPlanLike, E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError } from './shared-CUl6mTC1.js';
4
- import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-CBWGkBqF.js';
5
- export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UsageSnapshot, x as UseCheckoutFlowOptions, y as UseCheckoutFlowReturn, z as UseUsageReturn, D as configToAutoRechargeInput, E as deriveVariant, F as useCheckoutFlow, G as useCheckoutStepsContext, H as useUsage } from './index-CBWGkBqF.js';
2
+ import { S as SolvaPayProviderProps, P as PaymentFormProps, a as PrefillCustomer, T as TopupFormProps, C as CheckoutResult, b as Plan, A as ActivationResult, B as BootstrapPlanLike, c as SaveAutoRechargeResponse, d as PurchaseStatus, e as SolvaPayContextValue, U as UsePlansOptions, f as UsePlansReturn, g as UsePlanOptions, h as UsePlanReturn, i as UseProductReturn, j as UseMerchantReturn, k as SolvaPayCopy, l as PurchaseStatusReturn, m as CancelResult, R as ReactivateResult, n as ActivatePlanResult, o as UseTopupOptions, p as UseTopupReturn, q as BalanceStatus, r as UseTopupAmountSelectorOptions, s as UseTopupAmountSelectorReturn, t as UsePaymentMethodReturn, u as AutoRechargeConfig, v as SaveAutoRechargeInput, w as SolvaPayTransport, x as PartialSolvaPayCopy, y as PurchaseInfo, z as Product, D as SolvaPayConfig } from './shared-DJdsOLag.js';
3
+ export { E as CheckoutStep, F as CustomerPurchaseData, M as MandateContext, G as MandateTemplate, H as Merchant, I as PaymentError, J as PaymentIntentResult, K as PaymentMethodInfo, L as PaymentResult, N as PurchaseStatusValue, O as SuccessMeta, Q as TopupPaymentResult, V as TransportBalanceResult, W as TransportCheckoutSessionResult, X as TransportCustomerSessionResult, Y as TransportLimitsResult, Z as UnsupportedTransportMethodError } from './shared-DJdsOLag.js';
4
+ import { P as PaymentFormSummary, a as PaymentFormCustomerFields, b as PaymentFormPaymentElement, c as PaymentFormCardElement, d as PaymentFormMandateText, e as PaymentFormTermsCheckbox, f as PaymentFormSubmitButton, g as PaymentFormLoading, h as PaymentFormError, i as PaymentFormLegalFooter, j as PaymentFormBusinessDetails, k as PaymentFormTaxSummary, A as AutoRechargeInputPayload, l as PaywallStructuredContent, C as CheckoutVariant } from './index-ofZwGvIZ.js';
5
+ export { m as ActivationFlowStep, B as BalanceBadge, n as CancelPlanButton, o as CheckoutErrorPhase, p as CheckoutStatus, q as CheckoutSteps, r as CheckoutSummary, s as CheckoutSummaryProps, M as MandateText, t as MandateTextProps, u as PlanBadge, v as ProductBadge, w as PurchaseGate, U as UsageSnapshot, x as UseCheckoutFlowOptions, y as UseCheckoutFlowReturn, z as UseUsageReturn, D as configToAutoRechargeInput, E as deriveVariant, F as useCheckoutFlow, G as useCheckoutStepsContext, H as useUsage } from './index-ofZwGvIZ.js';
6
6
  import { PaymentIntent, Stripe, StripeElements } from '@stripe/stripe-js';
7
7
  import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
8
+ import * as react_jsx_runtime from 'react/jsx-runtime';
8
9
  export { AuthAdapter, createAnonymousAuthAdapter, defaultAuthAdapter, getOrCreateAnonymousCustomerRef, resetAnonymousCustomerRef } from './adapters/auth.js';
9
10
  export { SessionAuthAdapterOptions, createSessionAuthAdapter } from './adapters/session-auth.js';
10
11
  import '@stripe/react-stripe-js';
11
- import 'react/jsx-runtime';
12
12
 
13
13
  /**
14
14
  * SolvaPay Provider - Headless Context Provider for React.
@@ -305,6 +305,8 @@ interface CurrentPlanCardClassNames {
305
305
  usageMeter?: string;
306
306
  paymentMethod?: string;
307
307
  actions?: string;
308
+ /** Small muted caption above a value when `showFieldLabels` is set. */
309
+ fieldLabel?: string;
308
310
  /** Embedded pending-cancellation notice + reactivate CTA. */
309
311
  cancelledNotice?: string;
310
312
  }
@@ -351,6 +353,17 @@ interface CurrentPlanCardProps {
351
353
  * Hosted-page parity for the MCP account surface.
352
354
  */
353
355
  showReference?: boolean;
356
+ /**
357
+ * Caption the price/rate and balance values with a field label
358
+ * ("Rate", "Balance"). Default: `false`. Those lines are bare
359
+ * numbers otherwise, which read alike on a surface that shows both.
360
+ */
361
+ showFieldLabels?: boolean;
362
+ /**
363
+ * Live catalog plans. Used to format a PAYG usage rate when the
364
+ * frozen snapshot has no `options[]`.
365
+ */
366
+ plans?: readonly CatalogPlanLike[];
354
367
  /** Per-element classNames. */
355
368
  classNames?: CurrentPlanCardClassNames;
356
369
  /**
@@ -359,6 +372,20 @@ interface CurrentPlanCardProps {
359
372
  */
360
373
  className?: string;
361
374
  }
375
+ /**
376
+ * Structural catalog / snapshot subset `formatPaygRate` can read.
377
+ * Wider than `BootstrapPlanLike` so MCP `PlanLike` (which allows `null`
378
+ * on optional fields) is assignable without a cast.
379
+ */
380
+ interface CatalogPlanLike {
381
+ reference?: string | null;
382
+ name?: string;
383
+ options?: BootstrapPlanLike['options'] | null;
384
+ price?: number | null;
385
+ currency?: string | null;
386
+ requiresPayment?: boolean | null;
387
+ isMetered?: boolean | null;
388
+ }
362
389
  declare const CurrentPlanCard: React.FC<CurrentPlanCardProps>;
363
390
 
364
391
  type AutoRechargeProps = {
@@ -381,17 +408,18 @@ declare function AutoRecharge({ currency, defaultThresholdAmountMajor, defaultTo
381
408
  * Render-eager: the button is enabled and labelled from the first paint
382
409
  * regardless of session state. The portal session URL is fetched in the
383
410
  * background through `useCustomerSessionUrl()` (a single in-flight call
384
- * shared across every instance under the same transport). When the URL
385
- * is ready, click is a synchronous `<a target="_blank">` navigation —
386
- * which MCP host sandboxes permit even though scripted `window.open`
387
- * after an async round-trip is blocked.
388
- *
389
- * If the user clicks before the URL has resolved, the click handler
390
- * awaits the in-flight fetch and falls back to `window.open` (works on
391
- * hosts that don't sandbox scripted opens, e.g. ChatGPT). On Claude the
392
- * sandbox silently drops the open in that race; the cache-hit path
393
- * remains the optimal one and is the steady state for any user that
394
- * doesn't click within a few hundred ms of opening the surface.
411
+ * shared across every instance under the same transport).
412
+ *
413
+ * Opening the portal always goes through `useExternalLink`, which
414
+ * prefers the host's `ui/open-link` when one is mounted and otherwise
415
+ * lets the browser navigate. That distinction matters inside MCP hosts:
416
+ * Claude's iframe sandbox omits `allow-popups`, so both a bare
417
+ * `<a target="_blank">` and `window.open()` are dropped without an
418
+ * error — the button looks alive and does nothing.
419
+ *
420
+ * If the user clicks before the URL has resolved, the handler awaits
421
+ * the in-flight fetch and then opens the resolved URL through the same
422
+ * path, flipping to the error state if the open is refused.
395
423
  */
396
424
 
397
425
  interface LaunchCustomerPortalButtonProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel' | 'onError'> {
@@ -1001,6 +1029,43 @@ interface UsePaywallResolverReturn {
1001
1029
  }
1002
1030
  declare function usePaywallResolver(content: PaywallStructuredContent): UsePaywallResolverReturn;
1003
1031
 
1032
+ interface ExternalLinkOpener {
1033
+ /**
1034
+ * Whether the host can open links right now. Read synchronously from
1035
+ * the click handler, because suppressing native navigation on a host
1036
+ * that *cannot* open links would turn a working link into a dead one
1037
+ * — so `preventDefault()` is gated on this returning `true`.
1038
+ */
1039
+ canOpen: () => boolean;
1040
+ /**
1041
+ * Hand `url` to the host. Resolves `false` when the host refused
1042
+ * (blocked domain, user cancelled) or the request failed, so callers
1043
+ * can surface the dead end instead of leaving the user guessing.
1044
+ */
1045
+ open: (url: string) => Promise<boolean>;
1046
+ }
1047
+ interface ExternalLinkProviderProps {
1048
+ opener: ExternalLinkOpener;
1049
+ children: React.ReactNode;
1050
+ }
1051
+ declare function ExternalLinkProvider({ opener, children }: ExternalLinkProviderProps): react_jsx_runtime.JSX.Element;
1052
+ /**
1053
+ * Imperative opener for flows that only learn the URL after an `await`,
1054
+ * where there is no anchor left to click (the portal button's
1055
+ * cache-miss path). Prefers the host, otherwise asks the browser.
1056
+ *
1057
+ * Resolves `false` only when a host-mediated open was attempted and
1058
+ * refused. The browser path reports `true` because it cannot be
1059
+ * verified: `window.open` with `noopener` returns `null` on success by
1060
+ * spec, so a null handle says nothing about whether the tab opened.
1061
+ */
1062
+ declare function useOpenExternal(): (url: string) => Promise<boolean>;
1063
+ /**
1064
+ * `onClick` for any `<a href target="_blank">` the SDK renders. A no-op
1065
+ * when no host opener is mounted, which leaves the browser to navigate.
1066
+ */
1067
+ declare function useExternalLinkClick(): (event: React.MouseEvent<HTMLAnchorElement>) => void;
1068
+
1004
1069
  type CopyContextValue = {
1005
1070
  locale?: string;
1006
1071
  copy: SolvaPayCopy;
@@ -1258,4 +1323,4 @@ declare const DEFAULT_ROUTES: {
1258
1323
  };
1259
1324
  declare function createHttpTransport(config: SolvaPayConfig | undefined): SolvaPayTransport;
1260
1325
 
1261
- export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useLimits, useLocale, useMerchant, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };
1326
+ export { ActivatePlanResult, ActivationFlow, type ActivationFlowProps, ActivationResult, type ActivationState, AmountPicker, type AmountPickerProps, AutoRecharge, type AutoRechargeProps, BalanceStatus, BootstrapPlanLike, CancelResult, CancelledPlanNotice, type CancelledPlanNoticeProps, CheckoutLayout, type CheckoutLayoutPlanSelectorOptions, type CheckoutLayoutProps, type CheckoutLayoutSize, CheckoutResult, CheckoutVariant, type ConfirmPaymentInput, type ConfirmPaymentMode, type ConfirmPaymentResult, CopyContext, CopyProvider, CreditGate, type CreditGateProps, CurrentPlanCard, type CurrentPlanCardClassNames, type CurrentPlanCardProps, type CustomerInfo, DEFAULT_ROUTES, type ExternalLinkOpener, ExternalLinkProvider, type ExternalLinkProviderProps, type FormatPriceOptions, LaunchCustomerPortalButton, type LaunchCustomerPortalButtonProps, PartialSolvaPayCopy, type PaymentElementKind, PaymentForm, PaymentFormContext, type PaymentFormContextValue, PaymentFormProps, PaymentFormProvider, Plan, PlanSelector, type PlanSelectorProps, PrefillCustomer, Product, type PurchaseActions, PurchaseInfo, PurchaseStatus, PurchaseStatusReturn, ReactivateResult, SolvaPayConfig, SolvaPayContextValue, SolvaPayCopy, SolvaPayProvider, SolvaPayProviderProps, SolvaPayTransport, Spinner, StripePaymentFormWrapper, type StripePaymentFormWrapperProps, TopupForm, TopupFormProps, UpdatePaymentMethodButton, type UpdatePaymentMethodButtonMode, type UpdatePaymentMethodButtonProps, type UseActivationReturn, type UseAutoActivateFreePlanOptions, type UseAutoActivateFreePlanReturn, type UseLimitsOptions, type UseLimitsReturn, UseMerchantReturn, UsePaymentMethodReturn, type UsePaywallResolverReturn, UsePlanOptions, UsePlanReturn, UsePlansOptions, UsePlansReturn, UseProductReturn, UseTopupAmountSelectorOptions, UseTopupAmountSelectorReturn, UseTopupOptions, UseTopupReturn, confirmPayment, createHttpTransport, enCopy, filterPurchases, formatPrice, getActivePurchases, getCancelledPurchasesWithEndDate, getMinorUnitsPerMajor, getMostRecentPurchase, getPrimaryPurchase, interpolate, isPaidPurchase, isPlanPurchase, isTopupPurchase, isUnlimited, mergeCopy, readPaymentIntentClientSecret, resolveCta, stripPaymentIntentParams, toMajorUnits, useActivation, useAutoActivateFreePlan, useAutoRecharge, useBalance, useCheckout, useCopy, useCustomer, useExternalLinkClick, useLimits, useLocale, useMerchant, useOpenExternal, usePaymentForm, usePaymentMethod, usePaywallResolver, usePlan, usePlans, useProduct, usePurchase, usePurchaseActions, usePurchaseStatus, useSolvaPay, useTopup, useTopupAmountSelector, useTransport };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  LaunchCustomerPortalButton,
8
8
  UpdatePaymentMethodButton,
9
9
  usePaymentMethod
10
- } from "./chunk-QXNNMNCV.js";
10
+ } from "./chunk-M6O7ZWNP.js";
11
11
  import {
12
12
  ActivationFlow,
13
13
  AutoRecharge,
@@ -23,7 +23,7 @@ import {
23
23
  useCheckoutSteps,
24
24
  useCreditGate,
25
25
  usePaywallResolver
26
- } from "./chunk-HQH6KSXJ.js";
26
+ } from "./chunk-EWB43JVC.js";
27
27
  import {
28
28
  AmountPicker,
29
29
  BalanceBadge,
@@ -32,6 +32,7 @@ import {
32
32
  CopyContext,
33
33
  CopyProvider,
34
34
  DEFAULT_ROUTES,
35
+ ExternalLinkProvider,
35
36
  MandateText,
36
37
  PaymentForm,
37
38
  PaymentFormBusinessDetails,
@@ -82,9 +83,11 @@ import {
82
83
  useCheckoutFlow,
83
84
  useCopy,
84
85
  useCustomer,
86
+ useExternalLinkClick,
85
87
  useLimits,
86
88
  useLocale,
87
89
  useMerchant,
90
+ useOpenExternal,
88
91
  usePaymentForm,
89
92
  usePlan,
90
93
  usePlans,
@@ -97,7 +100,7 @@ import {
97
100
  useTopupAmountSelector,
98
101
  useTransport,
99
102
  useUsage
100
- } from "./chunk-LL6AYSTC.js";
103
+ } from "./chunk-WISTNSUH.js";
101
104
  import {
102
105
  createAnonymousAuthAdapter,
103
106
  defaultAuthAdapter,
@@ -874,6 +877,7 @@ export {
874
877
  CreditGate2 as CreditGate,
875
878
  CurrentPlanCard,
876
879
  DEFAULT_ROUTES,
880
+ ExternalLinkProvider,
877
881
  LaunchCustomerPortalButton,
878
882
  MandateText,
879
883
  PaymentForm2 as PaymentForm,
@@ -925,9 +929,11 @@ export {
925
929
  useCheckoutSteps as useCheckoutStepsContext,
926
930
  useCopy,
927
931
  useCustomer,
932
+ useExternalLinkClick,
928
933
  useLimits,
929
934
  useLocale,
930
935
  useMerchant,
936
+ useOpenExternal,
931
937
  usePaymentForm,
932
938
  usePaymentMethod,
933
939
  usePaywallResolver,