@solvapay/react 2.2.1 → 2.2.2-preview-09731417a0a7b4fd3afb4783fdf20b5ad293f63d
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/CHANGELOG.md +12 -0
- package/dist/{UsageMeter-CkJ_nowq.d.ts → UsageMeter-BZWfC5KX.d.ts} +1 -1
- package/dist/{UsageMeter-ClENA677.d.cts → UsageMeter-BiujMmVR.d.cts} +1 -1
- package/dist/{chunk-QZLY6SIU.js → chunk-4UFQDYG5.js} +1 -1
- package/dist/{chunk-LCBCOFXZ.js → chunk-GPP4MY3I.js} +54 -86
- package/dist/{chunk-AW5PCAYK.js → chunk-KUH3SNWZ.js} +1 -1
- package/dist/{index-DFtP872_.d.cts → index-B5QUesJE.d.cts} +5 -1
- package/dist/{index-D4EhOmYp.d.ts → index-BAYpUp5R.d.ts} +5 -1
- package/dist/index.cjs +32 -55
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +3 -3
- package/dist/mcp/index.cjs +29 -57
- package/dist/mcp/index.d.cts +2 -2
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +6 -10
- package/dist/primitives/index.cjs +32 -55
- package/dist/primitives/index.d.cts +5 -5
- package/dist/primitives/index.d.ts +5 -5
- package/dist/primitives/index.js +2 -2
- package/dist/{useUsage-x6DQG7xe.d.cts → useUsage-CRd_E6J3.d.cts} +9 -0
- package/dist/{useUsage-CfM9dQwB.d.ts → useUsage-DSPWQ37m.d.ts} +9 -0
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, 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 './useUsage-
|
|
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, _ as UsageSnapshot, $ as UseUsageReturn, a0 as useUsage } from './useUsage-
|
|
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-
|
|
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 UseCheckoutFlowOptions, x as UseCheckoutFlowReturn, y as configToAutoRechargeInput, z as deriveVariant, D as useCheckoutFlow, E as useCheckoutStepsContext } from './index-
|
|
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 './useUsage-CRd_E6J3.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, _ as UsageSnapshot, $ as UseUsageReturn, a0 as useUsage } from './useUsage-CRd_E6J3.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-B5QUesJE.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 UseCheckoutFlowOptions, x as UseCheckoutFlowReturn, y as configToAutoRechargeInput, z as deriveVariant, D as useCheckoutFlow, E as useCheckoutStepsContext } from './index-B5QUesJE.cjs';
|
|
6
6
|
import { PaymentIntent, Stripe, StripeElements } from '@stripe/stripe-js';
|
|
7
7
|
import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
|
|
8
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -692,7 +692,8 @@ declare function useSolvaPay(): SolvaPayContextValue;
|
|
|
692
692
|
* Selection lifecycle:
|
|
693
693
|
* 1. While `selectionReady` is false, plans fetch but no auto-selection fires.
|
|
694
694
|
* 2. When `selectionReady` becomes true AND plans are loaded, one-shot initial
|
|
695
|
-
* selection is applied (initialPlanRef > autoSelectFirstPaid
|
|
695
|
+
* selection is applied (initialPlanRef > autoSelectFirstPaid excluding
|
|
696
|
+
* excludePlanRef > no selection).
|
|
696
697
|
* 3. After initial selection, user picks always win — the hook never overrides.
|
|
697
698
|
*/
|
|
698
699
|
declare function usePlans(options: UsePlansOptions): UsePlansReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, 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 './useUsage-
|
|
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, _ as UsageSnapshot, $ as UseUsageReturn, a0 as useUsage } from './useUsage-
|
|
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-
|
|
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 UseCheckoutFlowOptions, x as UseCheckoutFlowReturn, y as configToAutoRechargeInput, z as deriveVariant, D as useCheckoutFlow, E as useCheckoutStepsContext } from './index-
|
|
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 './useUsage-DSPWQ37m.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, _ as UsageSnapshot, $ as UseUsageReturn, a0 as useUsage } from './useUsage-DSPWQ37m.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-BAYpUp5R.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 UseCheckoutFlowOptions, x as UseCheckoutFlowReturn, y as configToAutoRechargeInput, z as deriveVariant, D as useCheckoutFlow, E as useCheckoutStepsContext } from './index-BAYpUp5R.js';
|
|
6
6
|
import { PaymentIntent, Stripe, StripeElements } from '@stripe/stripe-js';
|
|
7
7
|
import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
|
|
8
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -692,7 +692,8 @@ declare function useSolvaPay(): SolvaPayContextValue;
|
|
|
692
692
|
* Selection lifecycle:
|
|
693
693
|
* 1. While `selectionReady` is false, plans fetch but no auto-selection fires.
|
|
694
694
|
* 2. When `selectionReady` becomes true AND plans are loaded, one-shot initial
|
|
695
|
-
* selection is applied (initialPlanRef > autoSelectFirstPaid
|
|
695
|
+
* selection is applied (initialPlanRef > autoSelectFirstPaid excluding
|
|
696
|
+
* excludePlanRef > no selection).
|
|
696
697
|
* 3. After initial selection, user picks always win — the hook never overrides.
|
|
697
698
|
*/
|
|
698
699
|
declare function usePlans(options: UsePlansOptions): UsePlansReturn;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
LaunchCustomerPortalButton,
|
|
6
6
|
usePaymentMethod
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4UFQDYG5.js";
|
|
8
8
|
import {
|
|
9
9
|
ActivationFlow,
|
|
10
10
|
AutoRecharge,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
useCheckoutSteps,
|
|
20
20
|
useCreditGate,
|
|
21
21
|
usePaywallResolver
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-KUH3SNWZ.js";
|
|
23
23
|
import {
|
|
24
24
|
AmountPicker,
|
|
25
25
|
BalanceBadge,
|
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
useTopupAmountSelector,
|
|
101
101
|
useTransport,
|
|
102
102
|
useUsage
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-GPP4MY3I.js";
|
|
104
104
|
import {
|
|
105
105
|
createAnonymousAuthAdapter,
|
|
106
106
|
defaultAuthAdapter,
|
package/dist/mcp/index.cjs
CHANGED
|
@@ -2405,15 +2405,14 @@ function processPlans(raw, filter, sortBy) {
|
|
|
2405
2405
|
if (filter) result = result.filter(filter);
|
|
2406
2406
|
return result;
|
|
2407
2407
|
}
|
|
2408
|
-
function computeInitialIndex(plans, initialPlanRef, autoSelectFirstPaid) {
|
|
2408
|
+
function computeInitialIndex(plans, initialPlanRef, autoSelectFirstPaid, excludePlanRef) {
|
|
2409
2409
|
if (plans.length === 0) return 0;
|
|
2410
2410
|
if (initialPlanRef) {
|
|
2411
2411
|
const idx = plans.findIndex((p) => p.reference === initialPlanRef);
|
|
2412
2412
|
if (idx >= 0) return idx;
|
|
2413
2413
|
}
|
|
2414
2414
|
if (autoSelectFirstPaid) {
|
|
2415
|
-
|
|
2416
|
-
return idx >= 0 ? idx : 0;
|
|
2415
|
+
return plans.findIndex((p) => p.requiresPayment !== false && p.reference !== excludePlanRef);
|
|
2417
2416
|
}
|
|
2418
2417
|
return -1;
|
|
2419
2418
|
}
|
|
@@ -2425,6 +2424,7 @@ function usePlans(options) {
|
|
|
2425
2424
|
sortBy,
|
|
2426
2425
|
autoSelectFirstPaid = false,
|
|
2427
2426
|
initialPlanRef,
|
|
2427
|
+
excludePlanRef,
|
|
2428
2428
|
selectionReady = true
|
|
2429
2429
|
} = options;
|
|
2430
2430
|
const solvaContext = (0, import_react11.useContext)(SolvaPayContext);
|
|
@@ -2438,6 +2438,7 @@ function usePlans(options) {
|
|
|
2438
2438
|
const sortByRef = (0, import_react11.useRef)(sortBy);
|
|
2439
2439
|
const autoSelectFirstPaidRef = (0, import_react11.useRef)(autoSelectFirstPaid);
|
|
2440
2440
|
const initialPlanRefRef = (0, import_react11.useRef)(initialPlanRef);
|
|
2441
|
+
const excludePlanRefRef = (0, import_react11.useRef)(excludePlanRef);
|
|
2441
2442
|
const selectionReadyRef = (0, import_react11.useRef)(selectionReady);
|
|
2442
2443
|
const hasAppliedInitialRef = (0, import_react11.useRef)(false);
|
|
2443
2444
|
const userHasSelectedRef = (0, import_react11.useRef)(false);
|
|
@@ -2449,7 +2450,7 @@ function usePlans(options) {
|
|
|
2449
2450
|
}
|
|
2450
2451
|
const processed = processPlans(cached.plans, filter, sortBy);
|
|
2451
2452
|
if (processed.length === 0) return 0;
|
|
2452
|
-
const idx = computeInitialIndex(processed, initialPlanRef, autoSelectFirstPaid);
|
|
2453
|
+
const idx = computeInitialIndex(processed, initialPlanRef, autoSelectFirstPaid, excludePlanRef);
|
|
2453
2454
|
hasAppliedInitialRef.current = true;
|
|
2454
2455
|
return idx;
|
|
2455
2456
|
});
|
|
@@ -2478,6 +2479,9 @@ function usePlans(options) {
|
|
|
2478
2479
|
(0, import_react11.useEffect)(() => {
|
|
2479
2480
|
initialPlanRefRef.current = initialPlanRef;
|
|
2480
2481
|
}, [initialPlanRef]);
|
|
2482
|
+
(0, import_react11.useEffect)(() => {
|
|
2483
|
+
excludePlanRefRef.current = excludePlanRef;
|
|
2484
|
+
}, [excludePlanRef]);
|
|
2481
2485
|
(0, import_react11.useEffect)(() => {
|
|
2482
2486
|
selectionReadyRef.current = selectionReady;
|
|
2483
2487
|
}, [selectionReady]);
|
|
@@ -2492,7 +2496,8 @@ function usePlans(options) {
|
|
|
2492
2496
|
const idx = computeInitialIndex(
|
|
2493
2497
|
processedPlans,
|
|
2494
2498
|
initialPlanRefRef.current,
|
|
2495
|
-
autoSelectFirstPaidRef.current
|
|
2499
|
+
autoSelectFirstPaidRef.current,
|
|
2500
|
+
excludePlanRefRef.current
|
|
2496
2501
|
);
|
|
2497
2502
|
setSelectedPlanIndexState(idx);
|
|
2498
2503
|
}, []);
|
|
@@ -2509,11 +2514,7 @@ function usePlans(options) {
|
|
|
2509
2514
|
try {
|
|
2510
2515
|
setLoading(true);
|
|
2511
2516
|
const fetchedPlans = await cached.promise;
|
|
2512
|
-
const processedPlans = processPlans(
|
|
2513
|
-
fetchedPlans,
|
|
2514
|
-
filterRef.current,
|
|
2515
|
-
sortByRef.current
|
|
2516
|
-
);
|
|
2517
|
+
const processedPlans = processPlans(fetchedPlans, filterRef.current, sortByRef.current);
|
|
2517
2518
|
setPlans(processedPlans);
|
|
2518
2519
|
setError(null);
|
|
2519
2520
|
applyInitialSelection(processedPlans);
|
|
@@ -2525,11 +2526,7 @@ function usePlans(options) {
|
|
|
2525
2526
|
return;
|
|
2526
2527
|
}
|
|
2527
2528
|
if (!force && cached && cached.plans.length > 0 && now - cached.timestamp < CACHE_DURATION5) {
|
|
2528
|
-
const processedPlans = processPlans(
|
|
2529
|
-
cached.plans,
|
|
2530
|
-
filterRef.current,
|
|
2531
|
-
sortByRef.current
|
|
2532
|
-
);
|
|
2529
|
+
const processedPlans = processPlans(cached.plans, filterRef.current, sortByRef.current);
|
|
2533
2530
|
setPlans(processedPlans);
|
|
2534
2531
|
setLoading(false);
|
|
2535
2532
|
setError(null);
|
|
@@ -2543,11 +2540,7 @@ function usePlans(options) {
|
|
|
2543
2540
|
plansCache.set(productRef, { plans: [], timestamp: now, promise: fetchPromise });
|
|
2544
2541
|
const fetchedPlans = await fetchPromise;
|
|
2545
2542
|
plansCache.set(productRef, { plans: fetchedPlans, timestamp: now, promise: null });
|
|
2546
|
-
const processedPlans = processPlans(
|
|
2547
|
-
fetchedPlans,
|
|
2548
|
-
filterRef.current,
|
|
2549
|
-
sortByRef.current
|
|
2550
|
-
);
|
|
2543
|
+
const processedPlans = processPlans(fetchedPlans, filterRef.current, sortByRef.current);
|
|
2551
2544
|
setPlans(processedPlans);
|
|
2552
2545
|
applyInitialSelection(processedPlans);
|
|
2553
2546
|
} catch (err) {
|
|
@@ -6876,19 +6869,20 @@ var Root3 = (0, import_react31.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
6876
6869
|
() => fetcher ?? ((ref) => defaultListPlans(ref, _config)),
|
|
6877
6870
|
[fetcher, _config]
|
|
6878
6871
|
);
|
|
6872
|
+
const autoCurrentPlanRef = (0, import_react31.useMemo)(() => {
|
|
6873
|
+
const active = purchases.filter((p) => p.status === "active").sort((a, b) => new Date(b.startDate).getTime() - new Date(a.startDate).getTime())[0];
|
|
6874
|
+
return active?.planSnapshot?.reference ?? null;
|
|
6875
|
+
}, [purchases]);
|
|
6876
|
+
const resolvedCurrentPlanRef = currentPlanRef === null ? null : currentPlanRef ?? autoCurrentPlanRef;
|
|
6879
6877
|
const { plans, selectedPlan, selectPlan, setSelectedPlanIndex, loading, error } = usePlans({
|
|
6880
6878
|
productRef,
|
|
6881
6879
|
fetcher: effectiveFetcher,
|
|
6882
6880
|
filter,
|
|
6883
6881
|
sortBy,
|
|
6884
6882
|
autoSelectFirstPaid,
|
|
6885
|
-
initialPlanRef
|
|
6883
|
+
initialPlanRef,
|
|
6884
|
+
excludePlanRef: resolvedCurrentPlanRef
|
|
6886
6885
|
});
|
|
6887
|
-
const autoCurrentPlanRef = (0, import_react31.useMemo)(() => {
|
|
6888
|
-
const active = purchases.filter((p) => p.status === "active").sort((a, b) => new Date(b.startDate).getTime() - new Date(a.startDate).getTime())[0];
|
|
6889
|
-
return active?.planSnapshot?.reference ?? null;
|
|
6890
|
-
}, [purchases]);
|
|
6891
|
-
const resolvedCurrentPlanRef = currentPlanRef === null ? null : currentPlanRef ?? autoCurrentPlanRef;
|
|
6892
6886
|
const isCurrent = (0, import_react31.useCallback)(
|
|
6893
6887
|
(ref) => resolvedCurrentPlanRef === ref,
|
|
6894
6888
|
[resolvedCurrentPlanRef]
|
|
@@ -6897,19 +6891,17 @@ var Root3 = (0, import_react31.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
6897
6891
|
(ref) => plans.find((p) => p.reference === ref)?.requiresPayment === false,
|
|
6898
6892
|
[plans]
|
|
6899
6893
|
);
|
|
6900
|
-
const isPopular = (0, import_react31.useCallback)(
|
|
6901
|
-
(ref) => popularPlanRef === ref,
|
|
6902
|
-
[popularPlanRef]
|
|
6903
|
-
);
|
|
6894
|
+
const isPopular = (0, import_react31.useCallback)((ref) => popularPlanRef === ref, [popularPlanRef]);
|
|
6904
6895
|
const select = (0, import_react31.useCallback)(
|
|
6905
6896
|
(ref) => {
|
|
6906
6897
|
const plan = plans.find((p) => p.reference === ref);
|
|
6907
6898
|
if (!plan) return;
|
|
6908
6899
|
if (plan.requiresPayment === false) return;
|
|
6900
|
+
if (isCurrent(ref)) return;
|
|
6909
6901
|
selectPlan(ref);
|
|
6910
6902
|
onSelect?.(ref, plan);
|
|
6911
6903
|
},
|
|
6912
|
-
[plans, selectPlan, onSelect]
|
|
6904
|
+
[plans, selectPlan, onSelect, isCurrent]
|
|
6913
6905
|
);
|
|
6914
6906
|
const clearSelection = (0, import_react31.useCallback)(() => {
|
|
6915
6907
|
setSelectedPlanIndex(-1);
|
|
@@ -6932,22 +6924,6 @@ var Root3 = (0, import_react31.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
6932
6924
|
setSelectedCurrencies((current) => ({ ...current, [planRef]: currency }));
|
|
6933
6925
|
}, []);
|
|
6934
6926
|
const selectedCurrency = selectedPlan ? getSelectedOption(selectedPlan).currency : null;
|
|
6935
|
-
const autoCurrentAppliedKeyRef = (0, import_react31.useRef)(null);
|
|
6936
|
-
(0, import_react31.useEffect)(() => {
|
|
6937
|
-
if (autoCurrentAppliedKeyRef.current === productRef) return;
|
|
6938
|
-
if (selectedPlanRef) {
|
|
6939
|
-
autoCurrentAppliedKeyRef.current = productRef;
|
|
6940
|
-
return;
|
|
6941
|
-
}
|
|
6942
|
-
if (!resolvedCurrentPlanRef || plans.length === 0) return;
|
|
6943
|
-
const currentPlan = plans.find((p) => p.reference === resolvedCurrentPlanRef);
|
|
6944
|
-
if (!currentPlan || !isPaygPlan(currentPlan)) {
|
|
6945
|
-
autoCurrentAppliedKeyRef.current = productRef;
|
|
6946
|
-
return;
|
|
6947
|
-
}
|
|
6948
|
-
autoCurrentAppliedKeyRef.current = productRef;
|
|
6949
|
-
select(resolvedCurrentPlanRef);
|
|
6950
|
-
}, [productRef, plans, resolvedCurrentPlanRef, selectedPlanRef, select]);
|
|
6951
6927
|
const ctx = (0, import_react31.useMemo)(
|
|
6952
6928
|
() => ({
|
|
6953
6929
|
plans,
|
|
@@ -7024,9 +7000,8 @@ var Grid = (0, import_react31.forwardRef)(function PlanSelectorGrid({ children,
|
|
|
7024
7000
|
const isFree = ctx.isFree(plan.reference);
|
|
7025
7001
|
const isPopular = ctx.isPopular(plan.reference);
|
|
7026
7002
|
const selected = ctx.selectedPlanRef === plan.reference;
|
|
7027
|
-
const
|
|
7028
|
-
const
|
|
7029
|
-
const state = isCurrent && !isPaygCurrent ? "current" : selected ? "selected" : isCurrent ? "current" : isFree ? "disabled" : "idle";
|
|
7003
|
+
const disabled = isFree || isCurrent;
|
|
7004
|
+
const state = isCurrent ? "current" : selected ? "selected" : isFree ? "disabled" : "idle";
|
|
7030
7005
|
const pricingOptions = getPlanPricingOptions(plan);
|
|
7031
7006
|
const selectedOption = ctx.getSelectedOption(plan);
|
|
7032
7007
|
const cardCtx = {
|
|
@@ -7593,9 +7568,8 @@ function CheckoutPlanRow({
|
|
|
7593
7568
|
description: descriptionOverride,
|
|
7594
7569
|
onSelect
|
|
7595
7570
|
}) {
|
|
7596
|
-
const
|
|
7597
|
-
const
|
|
7598
|
-
const state = resolvePlanRowState({ current, selected, free, isPaygCurrent });
|
|
7571
|
+
const disabled = disabledOverride ?? (free || current);
|
|
7572
|
+
const state = resolvePlanRowState({ current, selected, free });
|
|
7599
7573
|
const priceLabel = formatPlanPriceLabel(plan, locale, selectedOption);
|
|
7600
7574
|
const description = descriptionOverride ?? planWhatItGives(plan, locale, balance);
|
|
7601
7575
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -7616,12 +7590,10 @@ function CheckoutPlanRow({
|
|
|
7616
7590
|
function resolvePlanRowState({
|
|
7617
7591
|
current,
|
|
7618
7592
|
selected,
|
|
7619
|
-
free
|
|
7620
|
-
isPaygCurrent
|
|
7593
|
+
free
|
|
7621
7594
|
}) {
|
|
7622
|
-
if (current && !isPaygCurrent) return "current";
|
|
7623
|
-
if (selected) return "selected";
|
|
7624
7595
|
if (current) return "current";
|
|
7596
|
+
if (selected) return "selected";
|
|
7625
7597
|
if (free) return "disabled";
|
|
7626
7598
|
return "idle";
|
|
7627
7599
|
}
|
package/dist/mcp/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { w as SolvaPayTransport, a1 as SolvaPayProviderInitial, D as SolvaPayConfig, B as BootstrapPlanLike, y as PurchaseInfo, a2 as CreditActivityType, a3 as CreditActivityEntry, H as Merchant } from '../useUsage-
|
|
1
|
+
import { w as SolvaPayTransport, a1 as SolvaPayProviderInitial, D as SolvaPayConfig, B as BootstrapPlanLike, y as PurchaseInfo, a2 as CreditActivityType, a3 as CreditActivityEntry, H as Merchant } from '../useUsage-CRd_E6J3.cjs';
|
|
2
2
|
import { TOOL_FOR_VIEW, SolvaPayMcpViewKind, BootstrapMerchant, BootstrapProduct, BootstrapPlan, BootstrapCustomer } from '@solvapay/mcp-core';
|
|
3
3
|
export { MCP_TOOL_NAMES, McpToolName } from '@solvapay/mcp-core';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { PricingOptionLike, PricedLike, BalancePegLike } from '@solvapay/core';
|
|
7
|
-
import { U as UsageMeterRootProps } from '../UsageMeter-
|
|
7
|
+
import { U as UsageMeterRootProps } from '../UsageMeter-BiujMmVR.cjs';
|
|
8
8
|
import '@stripe/stripe-js';
|
|
9
9
|
import '../adapters/auth.cjs';
|
|
10
10
|
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { w as SolvaPayTransport, a1 as SolvaPayProviderInitial, D as SolvaPayConfig, B as BootstrapPlanLike, y as PurchaseInfo, a2 as CreditActivityType, a3 as CreditActivityEntry, H as Merchant } from '../useUsage-
|
|
1
|
+
import { w as SolvaPayTransport, a1 as SolvaPayProviderInitial, D as SolvaPayConfig, B as BootstrapPlanLike, y as PurchaseInfo, a2 as CreditActivityType, a3 as CreditActivityEntry, H as Merchant } from '../useUsage-DSPWQ37m.js';
|
|
2
2
|
import { TOOL_FOR_VIEW, SolvaPayMcpViewKind, BootstrapMerchant, BootstrapProduct, BootstrapPlan, BootstrapCustomer } from '@solvapay/mcp-core';
|
|
3
3
|
export { MCP_TOOL_NAMES, McpToolName } from '@solvapay/mcp-core';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { PricingOptionLike, PricedLike, BalancePegLike } from '@solvapay/core';
|
|
7
|
-
import { U as UsageMeterRootProps } from '../UsageMeter-
|
|
7
|
+
import { U as UsageMeterRootProps } from '../UsageMeter-BZWfC5KX.js';
|
|
8
8
|
import '@stripe/stripe-js';
|
|
9
9
|
import '../adapters/auth.js';
|
|
10
10
|
|
package/dist/mcp/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
LaunchCustomerPortalButton,
|
|
4
4
|
paymentMethodCache,
|
|
5
5
|
usePaymentMethod
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-4UFQDYG5.js";
|
|
7
7
|
import {
|
|
8
8
|
AmountPicker,
|
|
9
9
|
BalanceBadge,
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
inferIncludedUnits,
|
|
33
33
|
interpolate,
|
|
34
34
|
isPayg,
|
|
35
|
-
isPaygPlan,
|
|
36
35
|
limitsCache,
|
|
37
36
|
merchantCache,
|
|
38
37
|
planBillingCycle,
|
|
@@ -63,7 +62,7 @@ import {
|
|
|
63
62
|
useTransport,
|
|
64
63
|
useUsage,
|
|
65
64
|
validateAutoRechargeForm
|
|
66
|
-
} from "../chunk-
|
|
65
|
+
} from "../chunk-GPP4MY3I.js";
|
|
67
66
|
import "../chunk-UMXOAUW7.js";
|
|
68
67
|
import "../chunk-MLKGABMK.js";
|
|
69
68
|
|
|
@@ -3008,9 +3007,8 @@ function CheckoutPlanRow({
|
|
|
3008
3007
|
description: descriptionOverride,
|
|
3009
3008
|
onSelect
|
|
3010
3009
|
}) {
|
|
3011
|
-
const
|
|
3012
|
-
const
|
|
3013
|
-
const state = resolvePlanRowState({ current, selected, free, isPaygCurrent });
|
|
3010
|
+
const disabled = disabledOverride ?? (free || current);
|
|
3011
|
+
const state = resolvePlanRowState({ current, selected, free });
|
|
3014
3012
|
const priceLabel = formatPlanPriceLabel(plan, locale, selectedOption);
|
|
3015
3013
|
const description = descriptionOverride ?? planWhatItGives(plan, locale, balance);
|
|
3016
3014
|
return /* @__PURE__ */ jsx16(
|
|
@@ -3031,12 +3029,10 @@ function CheckoutPlanRow({
|
|
|
3031
3029
|
function resolvePlanRowState({
|
|
3032
3030
|
current,
|
|
3033
3031
|
selected,
|
|
3034
|
-
free
|
|
3035
|
-
isPaygCurrent
|
|
3032
|
+
free
|
|
3036
3033
|
}) {
|
|
3037
|
-
if (current && !isPaygCurrent) return "current";
|
|
3038
|
-
if (selected) return "selected";
|
|
3039
3034
|
if (current) return "current";
|
|
3035
|
+
if (selected) return "selected";
|
|
3040
3036
|
if (free) return "disabled";
|
|
3041
3037
|
return "idle";
|
|
3042
3038
|
}
|
|
@@ -1144,15 +1144,14 @@ function processPlans(raw, filter, sortBy) {
|
|
|
1144
1144
|
if (filter) result = result.filter(filter);
|
|
1145
1145
|
return result;
|
|
1146
1146
|
}
|
|
1147
|
-
function computeInitialIndex(plans, initialPlanRef, autoSelectFirstPaid) {
|
|
1147
|
+
function computeInitialIndex(plans, initialPlanRef, autoSelectFirstPaid, excludePlanRef) {
|
|
1148
1148
|
if (plans.length === 0) return 0;
|
|
1149
1149
|
if (initialPlanRef) {
|
|
1150
1150
|
const idx = plans.findIndex((p) => p.reference === initialPlanRef);
|
|
1151
1151
|
if (idx >= 0) return idx;
|
|
1152
1152
|
}
|
|
1153
1153
|
if (autoSelectFirstPaid) {
|
|
1154
|
-
|
|
1155
|
-
return idx >= 0 ? idx : 0;
|
|
1154
|
+
return plans.findIndex((p) => p.requiresPayment !== false && p.reference !== excludePlanRef);
|
|
1156
1155
|
}
|
|
1157
1156
|
return -1;
|
|
1158
1157
|
}
|
|
@@ -1164,6 +1163,7 @@ function usePlans(options) {
|
|
|
1164
1163
|
sortBy,
|
|
1165
1164
|
autoSelectFirstPaid = false,
|
|
1166
1165
|
initialPlanRef,
|
|
1166
|
+
excludePlanRef,
|
|
1167
1167
|
selectionReady = true
|
|
1168
1168
|
} = options;
|
|
1169
1169
|
const solvaContext = (0, import_react5.useContext)(SolvaPayContext);
|
|
@@ -1177,6 +1177,7 @@ function usePlans(options) {
|
|
|
1177
1177
|
const sortByRef = (0, import_react5.useRef)(sortBy);
|
|
1178
1178
|
const autoSelectFirstPaidRef = (0, import_react5.useRef)(autoSelectFirstPaid);
|
|
1179
1179
|
const initialPlanRefRef = (0, import_react5.useRef)(initialPlanRef);
|
|
1180
|
+
const excludePlanRefRef = (0, import_react5.useRef)(excludePlanRef);
|
|
1180
1181
|
const selectionReadyRef = (0, import_react5.useRef)(selectionReady);
|
|
1181
1182
|
const hasAppliedInitialRef = (0, import_react5.useRef)(false);
|
|
1182
1183
|
const userHasSelectedRef = (0, import_react5.useRef)(false);
|
|
@@ -1188,7 +1189,7 @@ function usePlans(options) {
|
|
|
1188
1189
|
}
|
|
1189
1190
|
const processed = processPlans(cached.plans, filter, sortBy);
|
|
1190
1191
|
if (processed.length === 0) return 0;
|
|
1191
|
-
const idx = computeInitialIndex(processed, initialPlanRef, autoSelectFirstPaid);
|
|
1192
|
+
const idx = computeInitialIndex(processed, initialPlanRef, autoSelectFirstPaid, excludePlanRef);
|
|
1192
1193
|
hasAppliedInitialRef.current = true;
|
|
1193
1194
|
return idx;
|
|
1194
1195
|
});
|
|
@@ -1217,6 +1218,9 @@ function usePlans(options) {
|
|
|
1217
1218
|
(0, import_react5.useEffect)(() => {
|
|
1218
1219
|
initialPlanRefRef.current = initialPlanRef;
|
|
1219
1220
|
}, [initialPlanRef]);
|
|
1221
|
+
(0, import_react5.useEffect)(() => {
|
|
1222
|
+
excludePlanRefRef.current = excludePlanRef;
|
|
1223
|
+
}, [excludePlanRef]);
|
|
1220
1224
|
(0, import_react5.useEffect)(() => {
|
|
1221
1225
|
selectionReadyRef.current = selectionReady;
|
|
1222
1226
|
}, [selectionReady]);
|
|
@@ -1231,7 +1235,8 @@ function usePlans(options) {
|
|
|
1231
1235
|
const idx = computeInitialIndex(
|
|
1232
1236
|
processedPlans,
|
|
1233
1237
|
initialPlanRefRef.current,
|
|
1234
|
-
autoSelectFirstPaidRef.current
|
|
1238
|
+
autoSelectFirstPaidRef.current,
|
|
1239
|
+
excludePlanRefRef.current
|
|
1235
1240
|
);
|
|
1236
1241
|
setSelectedPlanIndexState(idx);
|
|
1237
1242
|
}, []);
|
|
@@ -1248,11 +1253,7 @@ function usePlans(options) {
|
|
|
1248
1253
|
try {
|
|
1249
1254
|
setLoading(true);
|
|
1250
1255
|
const fetchedPlans = await cached.promise;
|
|
1251
|
-
const processedPlans = processPlans(
|
|
1252
|
-
fetchedPlans,
|
|
1253
|
-
filterRef.current,
|
|
1254
|
-
sortByRef.current
|
|
1255
|
-
);
|
|
1256
|
+
const processedPlans = processPlans(fetchedPlans, filterRef.current, sortByRef.current);
|
|
1256
1257
|
setPlans(processedPlans);
|
|
1257
1258
|
setError(null);
|
|
1258
1259
|
applyInitialSelection(processedPlans);
|
|
@@ -1264,11 +1265,7 @@ function usePlans(options) {
|
|
|
1264
1265
|
return;
|
|
1265
1266
|
}
|
|
1266
1267
|
if (!force && cached && cached.plans.length > 0 && now - cached.timestamp < CACHE_DURATION3) {
|
|
1267
|
-
const processedPlans = processPlans(
|
|
1268
|
-
cached.plans,
|
|
1269
|
-
filterRef.current,
|
|
1270
|
-
sortByRef.current
|
|
1271
|
-
);
|
|
1268
|
+
const processedPlans = processPlans(cached.plans, filterRef.current, sortByRef.current);
|
|
1272
1269
|
setPlans(processedPlans);
|
|
1273
1270
|
setLoading(false);
|
|
1274
1271
|
setError(null);
|
|
@@ -1282,11 +1279,7 @@ function usePlans(options) {
|
|
|
1282
1279
|
plansCache.set(productRef, { plans: [], timestamp: now, promise: fetchPromise });
|
|
1283
1280
|
const fetchedPlans = await fetchPromise;
|
|
1284
1281
|
plansCache.set(productRef, { plans: fetchedPlans, timestamp: now, promise: null });
|
|
1285
|
-
const processedPlans = processPlans(
|
|
1286
|
-
fetchedPlans,
|
|
1287
|
-
filterRef.current,
|
|
1288
|
-
sortByRef.current
|
|
1289
|
-
);
|
|
1282
|
+
const processedPlans = processPlans(fetchedPlans, filterRef.current, sortByRef.current);
|
|
1290
1283
|
setPlans(processedPlans);
|
|
1291
1284
|
applyInitialSelection(processedPlans);
|
|
1292
1285
|
} catch (err) {
|
|
@@ -2201,11 +2194,6 @@ function usePurchase() {
|
|
|
2201
2194
|
};
|
|
2202
2195
|
}
|
|
2203
2196
|
|
|
2204
|
-
// src/utils/isPayg.ts
|
|
2205
|
-
function isPaygPlan(plan) {
|
|
2206
|
-
return plan?.type === "usage-based" || plan?.type === "hybrid";
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
2197
|
// src/utils/planPricing.ts
|
|
2210
2198
|
var import_core2 = require("@solvapay/core");
|
|
2211
2199
|
function getPlanPricingOptions(plan) {
|
|
@@ -2279,19 +2267,20 @@ var Root2 = (0, import_react11.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
2279
2267
|
() => fetcher ?? ((ref) => defaultListPlans(ref, _config)),
|
|
2280
2268
|
[fetcher, _config]
|
|
2281
2269
|
);
|
|
2270
|
+
const autoCurrentPlanRef = (0, import_react11.useMemo)(() => {
|
|
2271
|
+
const active = purchases.filter((p) => p.status === "active").sort((a, b) => new Date(b.startDate).getTime() - new Date(a.startDate).getTime())[0];
|
|
2272
|
+
return active?.planSnapshot?.reference ?? null;
|
|
2273
|
+
}, [purchases]);
|
|
2274
|
+
const resolvedCurrentPlanRef = currentPlanRef === null ? null : currentPlanRef ?? autoCurrentPlanRef;
|
|
2282
2275
|
const { plans, selectedPlan, selectPlan, setSelectedPlanIndex, loading, error } = usePlans({
|
|
2283
2276
|
productRef,
|
|
2284
2277
|
fetcher: effectiveFetcher,
|
|
2285
2278
|
filter,
|
|
2286
2279
|
sortBy,
|
|
2287
2280
|
autoSelectFirstPaid,
|
|
2288
|
-
initialPlanRef
|
|
2281
|
+
initialPlanRef,
|
|
2282
|
+
excludePlanRef: resolvedCurrentPlanRef
|
|
2289
2283
|
});
|
|
2290
|
-
const autoCurrentPlanRef = (0, import_react11.useMemo)(() => {
|
|
2291
|
-
const active = purchases.filter((p) => p.status === "active").sort((a, b) => new Date(b.startDate).getTime() - new Date(a.startDate).getTime())[0];
|
|
2292
|
-
return active?.planSnapshot?.reference ?? null;
|
|
2293
|
-
}, [purchases]);
|
|
2294
|
-
const resolvedCurrentPlanRef = currentPlanRef === null ? null : currentPlanRef ?? autoCurrentPlanRef;
|
|
2295
2284
|
const isCurrent = (0, import_react11.useCallback)(
|
|
2296
2285
|
(ref) => resolvedCurrentPlanRef === ref,
|
|
2297
2286
|
[resolvedCurrentPlanRef]
|
|
@@ -2300,19 +2289,17 @@ var Root2 = (0, import_react11.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
2300
2289
|
(ref) => plans.find((p) => p.reference === ref)?.requiresPayment === false,
|
|
2301
2290
|
[plans]
|
|
2302
2291
|
);
|
|
2303
|
-
const isPopular = (0, import_react11.useCallback)(
|
|
2304
|
-
(ref) => popularPlanRef === ref,
|
|
2305
|
-
[popularPlanRef]
|
|
2306
|
-
);
|
|
2292
|
+
const isPopular = (0, import_react11.useCallback)((ref) => popularPlanRef === ref, [popularPlanRef]);
|
|
2307
2293
|
const select = (0, import_react11.useCallback)(
|
|
2308
2294
|
(ref) => {
|
|
2309
2295
|
const plan = plans.find((p) => p.reference === ref);
|
|
2310
2296
|
if (!plan) return;
|
|
2311
2297
|
if (plan.requiresPayment === false) return;
|
|
2298
|
+
if (isCurrent(ref)) return;
|
|
2312
2299
|
selectPlan(ref);
|
|
2313
2300
|
onSelect?.(ref, plan);
|
|
2314
2301
|
},
|
|
2315
|
-
[plans, selectPlan, onSelect]
|
|
2302
|
+
[plans, selectPlan, onSelect, isCurrent]
|
|
2316
2303
|
);
|
|
2317
2304
|
const clearSelection = (0, import_react11.useCallback)(() => {
|
|
2318
2305
|
setSelectedPlanIndex(-1);
|
|
@@ -2335,22 +2322,6 @@ var Root2 = (0, import_react11.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
2335
2322
|
setSelectedCurrencies((current) => ({ ...current, [planRef]: currency }));
|
|
2336
2323
|
}, []);
|
|
2337
2324
|
const selectedCurrency = selectedPlan ? getSelectedOption(selectedPlan).currency : null;
|
|
2338
|
-
const autoCurrentAppliedKeyRef = (0, import_react11.useRef)(null);
|
|
2339
|
-
(0, import_react11.useEffect)(() => {
|
|
2340
|
-
if (autoCurrentAppliedKeyRef.current === productRef) return;
|
|
2341
|
-
if (selectedPlanRef) {
|
|
2342
|
-
autoCurrentAppliedKeyRef.current = productRef;
|
|
2343
|
-
return;
|
|
2344
|
-
}
|
|
2345
|
-
if (!resolvedCurrentPlanRef || plans.length === 0) return;
|
|
2346
|
-
const currentPlan = plans.find((p) => p.reference === resolvedCurrentPlanRef);
|
|
2347
|
-
if (!currentPlan || !isPaygPlan(currentPlan)) {
|
|
2348
|
-
autoCurrentAppliedKeyRef.current = productRef;
|
|
2349
|
-
return;
|
|
2350
|
-
}
|
|
2351
|
-
autoCurrentAppliedKeyRef.current = productRef;
|
|
2352
|
-
select(resolvedCurrentPlanRef);
|
|
2353
|
-
}, [productRef, plans, resolvedCurrentPlanRef, selectedPlanRef, select]);
|
|
2354
2325
|
const ctx = (0, import_react11.useMemo)(
|
|
2355
2326
|
() => ({
|
|
2356
2327
|
plans,
|
|
@@ -2427,9 +2398,8 @@ var Grid = (0, import_react11.forwardRef)(function PlanSelectorGrid({ children,
|
|
|
2427
2398
|
const isFree = ctx.isFree(plan.reference);
|
|
2428
2399
|
const isPopular = ctx.isPopular(plan.reference);
|
|
2429
2400
|
const selected = ctx.selectedPlanRef === plan.reference;
|
|
2430
|
-
const
|
|
2431
|
-
const
|
|
2432
|
-
const state = isCurrent && !isPaygCurrent ? "current" : selected ? "selected" : isCurrent ? "current" : isFree ? "disabled" : "idle";
|
|
2401
|
+
const disabled = isFree || isCurrent;
|
|
2402
|
+
const state = isCurrent ? "current" : selected ? "selected" : isFree ? "disabled" : "idle";
|
|
2433
2403
|
const pricingOptions = getPlanPricingOptions(plan);
|
|
2434
2404
|
const selectedOption = ctx.getSelectedOption(plan);
|
|
2435
2405
|
const cardCtx = {
|
|
@@ -8432,6 +8402,13 @@ function useTransport() {
|
|
|
8432
8402
|
|
|
8433
8403
|
// src/primitives/checkout/shared.ts
|
|
8434
8404
|
var import_core9 = require("@solvapay/core");
|
|
8405
|
+
|
|
8406
|
+
// src/utils/isPayg.ts
|
|
8407
|
+
function isPaygPlan(plan) {
|
|
8408
|
+
return plan?.type === "usage-based" || plan?.type === "hybrid";
|
|
8409
|
+
}
|
|
8410
|
+
|
|
8411
|
+
// src/primitives/checkout/shared.ts
|
|
8435
8412
|
function isPayg(plan) {
|
|
8436
8413
|
return isPaygPlan(plan ?? null);
|
|
8437
8414
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { Ref } from 'react';
|
|
3
|
-
import { b as Plan, z as Product, s as UseTopupAmountSelectorReturn, y as PurchaseInfo, T as TopupFormProps, c as SaveAutoRechargeResponse, u as AutoRechargeConfig } from '../useUsage-
|
|
4
|
-
export { B as BootstrapPlanLike, E as CheckoutStep, O as SuccessMeta } from '../useUsage-
|
|
3
|
+
import { b as Plan, z as Product, s as UseTopupAmountSelectorReturn, y as PurchaseInfo, T as TopupFormProps, c as SaveAutoRechargeResponse, u as AutoRechargeConfig } from '../useUsage-CRd_E6J3.cjs';
|
|
4
|
+
export { B as BootstrapPlanLike, E as CheckoutStep, O as SuccessMeta } from '../useUsage-CRd_E6J3.cjs';
|
|
5
5
|
import { TaxBreakdown, BusinessDetailsInput } from '@solvapay/core';
|
|
6
|
-
import { A as AutoRechargeInputPayload, F as AmountInputUnit, G as AutoRechargeFormState, l as PaywallStructuredContent } from '../index-
|
|
7
|
-
export { H as ActivationFlow, I as ActivationFlowActivateButton, J as ActivationFlowActivated, K as ActivationFlowAmountPicker, L as ActivationFlowContinueButton, N as ActivationFlowError, O as ActivationFlowLoading, Q as ActivationFlowRetrying, R as ActivationFlowRoot, m as ActivationFlowStep, S as ActivationFlowSummary, B as BalanceBadge, n as CancelPlanButton, p as CheckoutStatus, q as CheckoutSteps, T as CheckoutStepsAmountContinueButton, V as CheckoutStepsAmountPicker, W as CheckoutStepsBackLink, X as CheckoutStepsIfStep, Y as CheckoutStepsPayment, Z as CheckoutStepsPlanContinueButton, _ as CheckoutStepsPlanGrid, $ as CheckoutStepsRoot, a0 as CheckoutStepsStepHeading, a1 as CheckoutStepsStepMessage, a2 as CheckoutStepsSuccess, M as MandateText, t as MandateTextProps, a3 as PaymentForm, j as PaymentFormBusinessDetails, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a4 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, k as PaymentFormTaxSummary, e as PaymentFormTermsCheckbox, u as PlanBadge, v as ProductBadge, w as PurchaseGate, a5 as PurchaseGateAllowed, a6 as PurchaseGateBlocked, a7 as PurchaseGateError, a8 as PurchaseGateLoading, a9 as PurchaseGateRoot, aa as useActivationFlow, E as useCheckoutStepsContext, ab as usePurchaseGate } from '../index-
|
|
6
|
+
import { A as AutoRechargeInputPayload, F as AmountInputUnit, G as AutoRechargeFormState, l as PaywallStructuredContent } from '../index-B5QUesJE.cjs';
|
|
7
|
+
export { H as ActivationFlow, I as ActivationFlowActivateButton, J as ActivationFlowActivated, K as ActivationFlowAmountPicker, L as ActivationFlowContinueButton, N as ActivationFlowError, O as ActivationFlowLoading, Q as ActivationFlowRetrying, R as ActivationFlowRoot, m as ActivationFlowStep, S as ActivationFlowSummary, B as BalanceBadge, n as CancelPlanButton, p as CheckoutStatus, q as CheckoutSteps, T as CheckoutStepsAmountContinueButton, V as CheckoutStepsAmountPicker, W as CheckoutStepsBackLink, X as CheckoutStepsIfStep, Y as CheckoutStepsPayment, Z as CheckoutStepsPlanContinueButton, _ as CheckoutStepsPlanGrid, $ as CheckoutStepsRoot, a0 as CheckoutStepsStepHeading, a1 as CheckoutStepsStepMessage, a2 as CheckoutStepsSuccess, M as MandateText, t as MandateTextProps, a3 as PaymentForm, j as PaymentFormBusinessDetails, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a4 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, k as PaymentFormTaxSummary, e as PaymentFormTermsCheckbox, u as PlanBadge, v as ProductBadge, w as PurchaseGate, a5 as PurchaseGateAllowed, a6 as PurchaseGateBlocked, a7 as PurchaseGateError, a8 as PurchaseGateLoading, a9 as PurchaseGateRoot, aa as useActivationFlow, E as useCheckoutStepsContext, ab as usePurchaseGate } from '../index-B5QUesJE.cjs';
|
|
8
8
|
import { PaymentElement } from '@stripe/react-stripe-js';
|
|
9
9
|
import { Stripe, StripeElements } from '@stripe/stripe-js';
|
|
10
|
-
export { a as UsageMeter, B as UsageMeterBar, b as UsageMeterClassNames, E as UsageMeterEmpty, L as UsageMeterLabel, c as UsageMeterLoading, P as UsageMeterPercentage, R as UsageMeterResetsIn, d as UsageMeterRoot, U as UsageMeterRootProps, u as useUsageMeter } from '../UsageMeter-
|
|
10
|
+
export { a as UsageMeter, B as UsageMeterBar, b as UsageMeterClassNames, E as UsageMeterEmpty, L as UsageMeterLabel, c as UsageMeterLoading, P as UsageMeterPercentage, R as UsageMeterResetsIn, d as UsageMeterRoot, U as UsageMeterRootProps, u as useUsageMeter } from '../UsageMeter-BiujMmVR.cjs';
|
|
11
11
|
import '../adapters/auth.cjs';
|
|
12
12
|
|
|
13
13
|
type PlanPricingOption = {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { Ref } from 'react';
|
|
3
|
-
import { b as Plan, z as Product, s as UseTopupAmountSelectorReturn, y as PurchaseInfo, T as TopupFormProps, c as SaveAutoRechargeResponse, u as AutoRechargeConfig } from '../useUsage-
|
|
4
|
-
export { B as BootstrapPlanLike, E as CheckoutStep, O as SuccessMeta } from '../useUsage-
|
|
3
|
+
import { b as Plan, z as Product, s as UseTopupAmountSelectorReturn, y as PurchaseInfo, T as TopupFormProps, c as SaveAutoRechargeResponse, u as AutoRechargeConfig } from '../useUsage-DSPWQ37m.js';
|
|
4
|
+
export { B as BootstrapPlanLike, E as CheckoutStep, O as SuccessMeta } from '../useUsage-DSPWQ37m.js';
|
|
5
5
|
import { TaxBreakdown, BusinessDetailsInput } from '@solvapay/core';
|
|
6
|
-
import { A as AutoRechargeInputPayload, F as AmountInputUnit, G as AutoRechargeFormState, l as PaywallStructuredContent } from '../index-
|
|
7
|
-
export { H as ActivationFlow, I as ActivationFlowActivateButton, J as ActivationFlowActivated, K as ActivationFlowAmountPicker, L as ActivationFlowContinueButton, N as ActivationFlowError, O as ActivationFlowLoading, Q as ActivationFlowRetrying, R as ActivationFlowRoot, m as ActivationFlowStep, S as ActivationFlowSummary, B as BalanceBadge, n as CancelPlanButton, p as CheckoutStatus, q as CheckoutSteps, T as CheckoutStepsAmountContinueButton, V as CheckoutStepsAmountPicker, W as CheckoutStepsBackLink, X as CheckoutStepsIfStep, Y as CheckoutStepsPayment, Z as CheckoutStepsPlanContinueButton, _ as CheckoutStepsPlanGrid, $ as CheckoutStepsRoot, a0 as CheckoutStepsStepHeading, a1 as CheckoutStepsStepMessage, a2 as CheckoutStepsSuccess, M as MandateText, t as MandateTextProps, a3 as PaymentForm, j as PaymentFormBusinessDetails, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a4 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, k as PaymentFormTaxSummary, e as PaymentFormTermsCheckbox, u as PlanBadge, v as ProductBadge, w as PurchaseGate, a5 as PurchaseGateAllowed, a6 as PurchaseGateBlocked, a7 as PurchaseGateError, a8 as PurchaseGateLoading, a9 as PurchaseGateRoot, aa as useActivationFlow, E as useCheckoutStepsContext, ab as usePurchaseGate } from '../index-
|
|
6
|
+
import { A as AutoRechargeInputPayload, F as AmountInputUnit, G as AutoRechargeFormState, l as PaywallStructuredContent } from '../index-BAYpUp5R.js';
|
|
7
|
+
export { H as ActivationFlow, I as ActivationFlowActivateButton, J as ActivationFlowActivated, K as ActivationFlowAmountPicker, L as ActivationFlowContinueButton, N as ActivationFlowError, O as ActivationFlowLoading, Q as ActivationFlowRetrying, R as ActivationFlowRoot, m as ActivationFlowStep, S as ActivationFlowSummary, B as BalanceBadge, n as CancelPlanButton, p as CheckoutStatus, q as CheckoutSteps, T as CheckoutStepsAmountContinueButton, V as CheckoutStepsAmountPicker, W as CheckoutStepsBackLink, X as CheckoutStepsIfStep, Y as CheckoutStepsPayment, Z as CheckoutStepsPlanContinueButton, _ as CheckoutStepsPlanGrid, $ as CheckoutStepsRoot, a0 as CheckoutStepsStepHeading, a1 as CheckoutStepsStepMessage, a2 as CheckoutStepsSuccess, M as MandateText, t as MandateTextProps, a3 as PaymentForm, j as PaymentFormBusinessDetails, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a4 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, k as PaymentFormTaxSummary, e as PaymentFormTermsCheckbox, u as PlanBadge, v as ProductBadge, w as PurchaseGate, a5 as PurchaseGateAllowed, a6 as PurchaseGateBlocked, a7 as PurchaseGateError, a8 as PurchaseGateLoading, a9 as PurchaseGateRoot, aa as useActivationFlow, E as useCheckoutStepsContext, ab as usePurchaseGate } from '../index-BAYpUp5R.js';
|
|
8
8
|
import { PaymentElement } from '@stripe/react-stripe-js';
|
|
9
9
|
import { Stripe, StripeElements } from '@stripe/stripe-js';
|
|
10
|
-
export { a as UsageMeter, B as UsageMeterBar, b as UsageMeterClassNames, E as UsageMeterEmpty, L as UsageMeterLabel, c as UsageMeterLoading, P as UsageMeterPercentage, R as UsageMeterResetsIn, d as UsageMeterRoot, U as UsageMeterRootProps, u as useUsageMeter } from '../UsageMeter-
|
|
10
|
+
export { a as UsageMeter, B as UsageMeterBar, b as UsageMeterClassNames, E as UsageMeterEmpty, L as UsageMeterLabel, c as UsageMeterLoading, P as UsageMeterPercentage, R as UsageMeterResetsIn, d as UsageMeterRoot, U as UsageMeterRootProps, u as useUsageMeter } from '../UsageMeter-BZWfC5KX.js';
|
|
11
11
|
import '../adapters/auth.js';
|
|
12
12
|
|
|
13
13
|
type PlanPricingOption = {
|