@b3dotfun/sdk 0.1.66 → 0.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +40 -11
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +16 -14
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +40 -10
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +10 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +5 -4
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AddressForm.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/checkout/AddressForm.js +14 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +117 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +158 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +81 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +61 -0
- package/dist/cjs/anyspend/react/components/checkout/CartItemRow.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/checkout/CartItemRow.js +9 -0
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.d.ts +30 -0
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.js +20 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +32 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.js +27 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormField.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormField.js +31 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +39 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.js +75 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutLayout.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutLayout.js +13 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutOrderStatus.d.ts +28 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutOrderStatus.js +65 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +31 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +64 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +31 -0
- package/dist/cjs/anyspend/react/components/checkout/CoinbaseCheckoutPanel.d.ts +20 -0
- package/dist/cjs/anyspend/react/components/checkout/CoinbaseCheckoutPanel.js +170 -0
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.d.ts +23 -0
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +324 -0
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.d.ts +12 -0
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.js +62 -0
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +20 -0
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +269 -0
- package/dist/cjs/anyspend/react/components/checkout/PoweredByBranding.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/checkout/PoweredByBranding.js +9 -0
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.js +20 -0
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +19 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +4 -4
- package/dist/cjs/anyspend/react/components/common/OrderStatus.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +93 -19
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +4 -4
- package/dist/cjs/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/StepProgress.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +6 -11
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TransferResultScreen.js +5 -1
- package/dist/cjs/anyspend/react/components/context/AnySpendCustomizationContext.d.ts +16 -0
- package/dist/cjs/anyspend/react/components/context/AnySpendCustomizationContext.js +92 -0
- package/dist/cjs/anyspend/react/components/icons/AnimatedCheckmark.d.ts +23 -0
- package/dist/cjs/anyspend/react/components/icons/AnimatedCheckmark.js +71 -0
- package/dist/cjs/anyspend/react/components/index.d.ts +8 -1
- package/dist/cjs/anyspend/react/components/index.js +10 -1
- package/dist/cjs/anyspend/react/components/types/classes.d.ts +50 -0
- package/dist/cjs/anyspend/react/components/types/customization.d.ts +75 -0
- package/dist/cjs/anyspend/react/components/types/customization.js +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +8 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +8 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +15 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +3 -2
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +9 -2
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -0
- package/dist/cjs/anyspend/services/anyspend.js +17 -2
- package/dist/cjs/anyspend/types/forms.d.ts +92 -0
- package/dist/cjs/anyspend/types/forms.js +8 -0
- package/dist/cjs/anyspend/utils/format.js +12 -3
- package/dist/cjs/app.shared.js +8 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +9 -3
- package/dist/cjs/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/cjs/global-account/react/components/ui/dialog.d.ts +2 -0
- package/dist/cjs/global-account/react/components/ui/dialog.js +2 -2
- package/dist/cjs/global-account/react/components/ui/drawer.d.ts +3 -1
- package/dist/cjs/global-account/react/components/ui/drawer.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +4 -4
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +53 -1
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +3 -3
- package/dist/cjs/shared/utils/number.d.ts +5 -0
- package/dist/cjs/shared/utils/number.js +13 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +41 -12
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +6 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +16 -14
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +42 -12
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +10 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +5 -4
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AddressForm.d.ts +9 -0
- package/dist/esm/anyspend/react/components/checkout/AddressForm.js +11 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +117 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +155 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +81 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +58 -0
- package/dist/esm/anyspend/react/components/checkout/CartItemRow.d.ts +8 -0
- package/dist/esm/anyspend/react/components/checkout/CartItemRow.js +6 -0
- package/dist/esm/anyspend/react/components/checkout/CartSummary.d.ts +30 -0
- package/dist/esm/anyspend/react/components/checkout/CartSummary.js +17 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +32 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.js +24 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormField.d.ts +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormField.js +28 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +39 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.js +72 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutLayout.d.ts +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutLayout.js +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutOrderStatus.d.ts +28 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutOrderStatus.js +62 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +31 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +61 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +28 -0
- package/dist/esm/anyspend/react/components/checkout/CoinbaseCheckoutPanel.d.ts +20 -0
- package/dist/esm/anyspend/react/components/checkout/CoinbaseCheckoutPanel.js +167 -0
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.d.ts +23 -0
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +321 -0
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.d.ts +12 -0
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.js +59 -0
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +20 -0
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +266 -0
- package/dist/esm/anyspend/react/components/checkout/PoweredByBranding.d.ts +8 -0
- package/dist/esm/anyspend/react/components/checkout/PoweredByBranding.js +6 -0
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.d.ts +11 -0
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.js +17 -0
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +19 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +4 -4
- package/dist/esm/anyspend/react/components/common/OrderStatus.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +96 -22
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +4 -4
- package/dist/esm/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/StepProgress.d.ts +5 -1
- package/dist/esm/anyspend/react/components/common/StepProgress.js +6 -11
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/TransferResultScreen.js +7 -3
- package/dist/esm/anyspend/react/components/context/AnySpendCustomizationContext.d.ts +16 -0
- package/dist/esm/anyspend/react/components/context/AnySpendCustomizationContext.js +88 -0
- package/dist/esm/anyspend/react/components/icons/AnimatedCheckmark.d.ts +23 -0
- package/dist/esm/anyspend/react/components/icons/AnimatedCheckmark.js +68 -0
- package/dist/esm/anyspend/react/components/index.d.ts +8 -1
- package/dist/esm/anyspend/react/components/index.js +5 -0
- package/dist/esm/anyspend/react/components/types/classes.d.ts +50 -0
- package/dist/esm/anyspend/react/components/types/customization.d.ts +75 -0
- package/dist/esm/anyspend/react/components/types/customization.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +8 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +8 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +15 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +3 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +9 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -0
- package/dist/esm/anyspend/services/anyspend.js +17 -2
- package/dist/esm/anyspend/types/forms.d.ts +92 -0
- package/dist/esm/anyspend/types/forms.js +7 -0
- package/dist/esm/anyspend/utils/format.js +12 -3
- package/dist/esm/app.shared.js +8 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +9 -3
- package/dist/esm/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/esm/global-account/react/components/ui/dialog.d.ts +2 -0
- package/dist/esm/global-account/react/components/ui/dialog.js +2 -2
- package/dist/esm/global-account/react/components/ui/drawer.d.ts +3 -1
- package/dist/esm/global-account/react/components/ui/drawer.js +1 -1
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +4 -4
- package/dist/esm/global-account/react/hooks/useUser.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +53 -1
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +3 -3
- package/dist/esm/shared/utils/number.d.ts +5 -0
- package/dist/esm/shared/utils/number.js +12 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +6 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +10 -1
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendTournament.d.ts +11 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/AddressForm.d.ts +9 -0
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +117 -0
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +81 -0
- package/dist/types/anyspend/react/components/checkout/CartItemRow.d.ts +8 -0
- package/dist/types/anyspend/react/components/checkout/CartSummary.d.ts +30 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +32 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutFormField.d.ts +10 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +39 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutLayout.d.ts +10 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutOrderStatus.d.ts +28 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +31 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +10 -0
- package/dist/types/anyspend/react/components/checkout/CoinbaseCheckoutPanel.d.ts +20 -0
- package/dist/types/anyspend/react/components/checkout/CryptoPayPanel.d.ts +23 -0
- package/dist/types/anyspend/react/components/checkout/DiscountCodeInput.d.ts +12 -0
- package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +20 -0
- package/dist/types/anyspend/react/components/checkout/PoweredByBranding.d.ts +8 -0
- package/dist/types/anyspend/react/components/checkout/ShippingSelector.d.ts +11 -0
- package/dist/types/anyspend/react/components/common/OrderStatus.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/StepProgress.d.ts +5 -1
- package/dist/types/anyspend/react/components/context/AnySpendCustomizationContext.d.ts +16 -0
- package/dist/types/anyspend/react/components/icons/AnimatedCheckmark.d.ts +23 -0
- package/dist/types/anyspend/react/components/index.d.ts +8 -1
- package/dist/types/anyspend/react/components/types/classes.d.ts +50 -0
- package/dist/types/anyspend/react/components/types/customization.d.ts +75 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +8 -2
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +8 -2
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +15 -3
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +9 -2
- package/dist/types/anyspend/services/anyspend.d.ts +1 -0
- package/dist/types/anyspend/types/forms.d.ts +92 -0
- package/dist/types/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/types/global-account/react/components/ui/dialog.d.ts +2 -0
- package/dist/types/global-account/react/components/ui/drawer.d.ts +3 -1
- package/dist/types/global-account/react/hooks/useAuth.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +4 -4
- package/dist/types/global-account/react/hooks/useUser.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +53 -1
- package/dist/types/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/types/shared/constants/chains/supported.d.ts +3 -3
- package/dist/types/shared/utils/number.d.ts +5 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +84 -37
- package/src/anyspend/react/components/AnySpendBondKit.tsx +12 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +14 -0
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +10 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +38 -20
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +82 -35
- package/src/anyspend/react/components/AnySpendDeposit.tsx +24 -2
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +14 -0
- package/src/anyspend/react/components/AnySpendNFT.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +14 -0
- package/src/anyspend/react/components/AnySpendTournament.tsx +19 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +14 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +10 -0
- package/src/anyspend/react/components/checkout/AddressForm.tsx +98 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +398 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +221 -0
- package/src/anyspend/react/components/checkout/CartItemRow.tsx +58 -0
- package/src/anyspend/react/components/checkout/CartSummary.tsx +158 -0
- package/src/anyspend/react/components/checkout/CheckoutCartPanel.tsx +98 -0
- package/src/anyspend/react/components/checkout/CheckoutFormField.tsx +129 -0
- package/src/anyspend/react/components/checkout/CheckoutFormPanel.tsx +241 -0
- package/src/anyspend/react/components/checkout/CheckoutLayout.tsx +52 -0
- package/src/anyspend/react/components/checkout/CheckoutOrderStatus.tsx +224 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +341 -0
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +110 -0
- package/src/anyspend/react/components/checkout/CoinbaseCheckoutPanel.tsx +279 -0
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +630 -0
- package/src/anyspend/react/components/checkout/DiscountCodeInput.tsx +127 -0
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +612 -0
- package/src/anyspend/react/components/checkout/PoweredByBranding.tsx +42 -0
- package/src/anyspend/react/components/checkout/ShippingSelector.tsx +73 -0
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +29 -7
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethodDisplay.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +5 -5
- package/src/anyspend/react/components/common/OrderStatus.tsx +140 -34
- package/src/anyspend/react/components/common/PanelOnramp.tsx +9 -9
- package/src/anyspend/react/components/common/PaySection.tsx +1 -1
- package/src/anyspend/react/components/common/StepProgress.tsx +40 -52
- package/src/anyspend/react/components/common/TokenBalance.tsx +0 -12
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +1 -9
- package/src/anyspend/react/components/common/TransferResultScreen.tsx +19 -11
- package/src/anyspend/react/components/context/AnySpendCustomizationContext.tsx +124 -0
- package/src/anyspend/react/components/icons/AnimatedCheckmark.tsx +119 -0
- package/src/anyspend/react/components/index.ts +33 -0
- package/src/anyspend/react/components/types/classes.ts +70 -0
- package/src/anyspend/react/components/types/customization.ts +99 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +3 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +3 -2
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +5 -1
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +5 -2
- package/src/anyspend/services/anyspend.ts +19 -2
- package/src/anyspend/types/forms.ts +97 -0
- package/src/anyspend/utils/format.ts +12 -3
- package/src/app.shared.ts +11 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +13 -4
- package/src/global-account/react/components/ui/dialog.tsx +17 -8
- package/src/global-account/react/components/ui/drawer.tsx +2 -2
- package/src/global-account/react/stores/useModalStore.ts +52 -1
- package/src/shared/utils/number.ts +12 -0
- package/src/styles/index.css +48 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
+
import { formatTokenAmount, safeBigInt } from "../../../../shared/utils/number.js";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
export function CartSummary({ total, tokenSymbol, classes, subtotal, tokenDecimals = 18, shipping, tax, discount, summaryLines, usdEquivalent, }) {
|
|
7
|
+
const hasAdjustments = !!shipping?.amount || !!tax?.amount || !!discount?.amount || (summaryLines && summaryLines.length > 0);
|
|
8
|
+
const formattedShipping = useMemo(() => (shipping?.amount ? formatTokenAmount(safeBigInt(shipping.amount), tokenDecimals) : null), [shipping?.amount, tokenDecimals]);
|
|
9
|
+
const formattedTax = useMemo(() => (tax?.amount ? formatTokenAmount(safeBigInt(tax.amount), tokenDecimals) : null), [tax?.amount, tokenDecimals]);
|
|
10
|
+
const formattedDiscount = useMemo(() => (discount?.amount ? formatTokenAmount(safeBigInt(discount.amount), tokenDecimals) : null), [discount?.amount, tokenDecimals]);
|
|
11
|
+
const formattedSummaryLines = useMemo(() => summaryLines?.map(line => ({
|
|
12
|
+
...line,
|
|
13
|
+
formattedAmount: formatTokenAmount(safeBigInt(line.amount), tokenDecimals),
|
|
14
|
+
isNegative: safeBigInt(line.amount) < BigInt(0),
|
|
15
|
+
})), [summaryLines, tokenDecimals]);
|
|
16
|
+
return (_jsxs("div", { className: cn("border-t border-gray-200 pt-3 dark:border-neutral-700", classes?.cartSummary), children: [hasAdjustments && subtotal && (_jsxs("div", { className: cn("flex items-center justify-between py-1", classes?.cartSubtotal), children: [_jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Subtotal" }), _jsxs("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: [subtotal, " ", tokenSymbol] })] })), formattedShipping && (_jsxs("div", { className: cn("flex items-center justify-between py-1", classes?.cartSummaryLine), children: [_jsx("span", { className: cn("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineLabel), children: shipping?.label || "Shipping" }), _jsxs("span", { className: cn("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineAmount), children: [formattedShipping, " ", tokenSymbol] })] })), formattedTax && (_jsxs("div", { className: cn("flex items-center justify-between py-1", classes?.cartSummaryLine), children: [_jsxs("span", { className: cn("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineLabel), children: [tax?.label || "Tax", tax?.rate && _jsxs("span", { className: "ml-1 text-xs text-gray-400 dark:text-gray-500", children: ["(", tax.rate, ")"] })] }), _jsxs("span", { className: cn("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineAmount), children: [formattedTax, " ", tokenSymbol] })] })), formattedDiscount && (_jsxs("div", { className: cn("flex items-center justify-between py-1", classes?.cartDiscount), children: [_jsxs("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: [discount?.label || "Discount", discount?.code && (_jsx("span", { className: "ml-1 rounded bg-green-50 px-1.5 py-0.5 text-xs font-medium text-green-600 dark:bg-green-900/20 dark:text-green-400", children: discount.code }))] }), _jsxs("span", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: ["-", formattedDiscount, " ", tokenSymbol] })] })), formattedSummaryLines?.map(line => (_jsxs("div", { className: cn("flex items-center justify-between py-1", classes?.cartSummaryLine), children: [_jsxs("span", { className: cn("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineLabel), children: [line.label, line.description && (_jsxs("span", { className: "ml-1 text-xs text-gray-400 dark:text-gray-500", children: ["(", line.description, ")"] }))] }), _jsxs("span", { className: cn("text-sm", line.isNegative ? "font-medium text-green-600 dark:text-green-400" : "text-gray-500 dark:text-gray-400", classes?.cartSummaryLineAmount), children: [line.formattedAmount, " ", tokenSymbol] })] }, line.label))), _jsxs("div", { className: cn("flex flex-col", hasAdjustments && "mt-1 border-t border-gray-100 pt-2 dark:border-neutral-800"), children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: "Total" }), _jsxs("span", { className: cn("text-base font-semibold text-gray-900 dark:text-gray-100", classes?.cartTotal), children: [total, " ", tokenSymbol] })] }), usdEquivalent && (_jsx("div", { className: "flex justify-end", children: _jsxs("span", { className: "text-xs text-gray-400 dark:text-gray-500", children: ["~", usdEquivalent, " USD"] }) }))] })] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { CheckoutItem, CheckoutSummaryLine, AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
3
|
+
interface CheckoutCartPanelProps {
|
|
4
|
+
items: CheckoutItem[];
|
|
5
|
+
totalAmount: string;
|
|
6
|
+
tokenSymbol?: string;
|
|
7
|
+
tokenDecimals?: number;
|
|
8
|
+
organizationName?: string;
|
|
9
|
+
organizationLogo?: string;
|
|
10
|
+
classes?: AnySpendCheckoutClasses;
|
|
11
|
+
/** Custom footer. Pass `null` to hide, or a ReactNode to replace the default PoweredByBranding. */
|
|
12
|
+
footer?: ReactNode | null;
|
|
13
|
+
shipping?: {
|
|
14
|
+
amount: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
};
|
|
17
|
+
tax?: {
|
|
18
|
+
amount: string;
|
|
19
|
+
label?: string;
|
|
20
|
+
rate?: string;
|
|
21
|
+
};
|
|
22
|
+
discount?: {
|
|
23
|
+
amount: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
code?: string;
|
|
26
|
+
};
|
|
27
|
+
summaryLines?: CheckoutSummaryLine[];
|
|
28
|
+
/** Formatted USD equivalent (e.g. "$5.56") — shown for non-stablecoin tokens */
|
|
29
|
+
usdEquivalent?: string | null;
|
|
30
|
+
}
|
|
31
|
+
export declare function CheckoutCartPanel({ items, totalAmount, tokenSymbol, tokenDecimals, organizationName, organizationLogo, classes, footer, shipping, tax, discount, summaryLines, usdEquivalent, }: CheckoutCartPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
+
import { formatTokenAmount, safeBigInt } from "../../../../shared/utils/number.js";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { CartItemRow } from "./CartItemRow.js";
|
|
7
|
+
import { CartSummary } from "./CartSummary.js";
|
|
8
|
+
import { PoweredByBranding } from "./PoweredByBranding.js";
|
|
9
|
+
export function CheckoutCartPanel({ items, totalAmount, tokenSymbol = "", tokenDecimals = 18, organizationName, organizationLogo, classes, footer, shipping, tax, discount, summaryLines, usdEquivalent, }) {
|
|
10
|
+
const formattedTotal = useMemo(() => formatTokenAmount(safeBigInt(totalAmount), tokenDecimals), [totalAmount, tokenDecimals]);
|
|
11
|
+
// Compute subtotal from items only (before adjustments)
|
|
12
|
+
const formattedSubtotal = useMemo(() => {
|
|
13
|
+
let subtotal = BigInt(0);
|
|
14
|
+
for (const item of items) {
|
|
15
|
+
subtotal += safeBigInt(item.amount) * BigInt(item.quantity);
|
|
16
|
+
}
|
|
17
|
+
return formatTokenAmount(subtotal, tokenDecimals);
|
|
18
|
+
}, [items, tokenDecimals]);
|
|
19
|
+
return (_jsxs("div", { className: cn("anyspend-cart-panel flex flex-col", classes?.cartPanel), children: [_jsx("h2", { className: cn("anyspend-cart-title mb-4 text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.cartTitle), children: "Order Summary" }), _jsx("div", { className: "anyspend-cart-items divide-y divide-gray-100 dark:divide-gray-800", children: items.map((item, index) => {
|
|
20
|
+
const itemTotal = safeBigInt(item.amount) * BigInt(item.quantity);
|
|
21
|
+
const formattedPrice = `${formatTokenAmount(itemTotal, tokenDecimals)} ${tokenSymbol}`;
|
|
22
|
+
return _jsx(CartItemRow, { item: item, formattedPrice: formattedPrice, classes: classes }, item.id || index);
|
|
23
|
+
}) }), _jsx(CartSummary, { total: formattedTotal, tokenSymbol: tokenSymbol, classes: classes, subtotal: formattedSubtotal, tokenDecimals: tokenDecimals, shipping: shipping, tax: tax, discount: discount, summaryLines: summaryLines, usdEquivalent: usdEquivalent }), footer === undefined ? (_jsx(PoweredByBranding, { organizationName: organizationName, organizationLogo: organizationLogo, classes: classes })) : (footer)] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CheckoutFormField as FormFieldType } from "../../../types/forms";
|
|
2
|
+
interface CheckoutFormFieldProps {
|
|
3
|
+
field: FormFieldType;
|
|
4
|
+
value: unknown;
|
|
5
|
+
onChange: (id: string, value: unknown) => void;
|
|
6
|
+
error?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function CheckoutFormFieldComponent({ field, value, onChange, error, className }: CheckoutFormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
+
const inputBaseClass = "w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 dark:border-neutral-600 dark:bg-neutral-800 dark:text-gray-100 dark:placeholder:text-gray-500 dark:focus:border-blue-400";
|
|
5
|
+
const labelClass = "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300";
|
|
6
|
+
export function CheckoutFormFieldComponent({ field, value, onChange, error, className }) {
|
|
7
|
+
const handleChange = (val) => {
|
|
8
|
+
onChange(field.id, val);
|
|
9
|
+
};
|
|
10
|
+
const renderField = () => {
|
|
11
|
+
switch (field.type) {
|
|
12
|
+
case "text":
|
|
13
|
+
case "email":
|
|
14
|
+
case "phone":
|
|
15
|
+
case "number":
|
|
16
|
+
return (_jsx("input", { type: field.type === "phone" ? "tel" : field.type, value: value || "", onChange: e => handleChange(e.target.value), placeholder: field.placeholder, required: field.required, className: cn("anyspend-form-input", inputBaseClass, error && "border-red-400 focus:border-red-500 focus:ring-red-500"), minLength: field.validation?.minLength, maxLength: field.validation?.maxLength, min: field.validation?.min, max: field.validation?.max, pattern: field.validation?.pattern }));
|
|
17
|
+
case "textarea":
|
|
18
|
+
return (_jsx("textarea", { value: value || "", onChange: e => handleChange(e.target.value), placeholder: field.placeholder, required: field.required, rows: 3, className: cn("anyspend-form-textarea", inputBaseClass, "resize-y", error && "border-red-400 focus:border-red-500 focus:ring-red-500"), minLength: field.validation?.minLength, maxLength: field.validation?.maxLength }));
|
|
19
|
+
case "select":
|
|
20
|
+
return (_jsxs("select", { value: value || "", onChange: e => handleChange(e.target.value), required: field.required, className: cn("anyspend-form-select", inputBaseClass, "cursor-pointer", error && "border-red-400"), children: [_jsx("option", { value: "", children: field.placeholder || "Select..." }), field.options?.map(opt => (_jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }));
|
|
21
|
+
case "checkbox":
|
|
22
|
+
return (_jsxs("label", { className: "anyspend-form-checkbox flex cursor-pointer items-center gap-2", children: [_jsx("input", { type: "checkbox", checked: !!value, onChange: e => handleChange(e.target.checked), className: "h-4 w-4 rounded border-gray-300 text-blue-500 focus:ring-blue-500" }), _jsx("span", { className: "text-sm text-gray-700 dark:text-gray-300", children: field.placeholder || field.label })] }));
|
|
23
|
+
default:
|
|
24
|
+
return (_jsx("input", { type: "text", value: value || "", onChange: e => handleChange(e.target.value), placeholder: field.placeholder, required: field.required, className: cn("anyspend-form-input", inputBaseClass, error && "border-red-400") }));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return (_jsxs("div", { className: cn("anyspend-form-field space-y-1", className), "data-field-id": field.id, "data-field-type": field.type, children: [field.type !== "checkbox" && (_jsxs("label", { className: cn("anyspend-form-label", labelClass), children: [field.label, field.required && _jsx("span", { className: "ml-0.5 text-red-500", children: "*" })] })), renderField(), error && _jsx("p", { className: "anyspend-form-error text-xs text-red-500", children: error })] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CheckoutFormSchema, CheckoutFormComponentProps, AddressData, ShippingOption, DiscountResult } from "../../../types/forms";
|
|
2
|
+
import type { AnySpendCheckoutClasses } from "../types/classes";
|
|
3
|
+
interface CheckoutFormPanelProps {
|
|
4
|
+
/** JSON form definition */
|
|
5
|
+
formSchema?: CheckoutFormSchema | null;
|
|
6
|
+
/** Custom React component to render instead of schema-based form */
|
|
7
|
+
formComponent?: React.ComponentType<CheckoutFormComponentProps>;
|
|
8
|
+
/** Shipping options */
|
|
9
|
+
shippingOptions?: ShippingOption[] | null;
|
|
10
|
+
/** Whether to collect a shipping address */
|
|
11
|
+
collectShippingAddress?: boolean;
|
|
12
|
+
/** Enable discount code input */
|
|
13
|
+
enableDiscountCode?: boolean;
|
|
14
|
+
/** Validate a discount code */
|
|
15
|
+
validateDiscount?: (code: string) => Promise<DiscountResult>;
|
|
16
|
+
/** Token info for display */
|
|
17
|
+
tokenSymbol?: string;
|
|
18
|
+
tokenDecimals?: number;
|
|
19
|
+
/** CSS class overrides */
|
|
20
|
+
classes?: AnySpendCheckoutClasses;
|
|
21
|
+
/** Current form data (lifted state) */
|
|
22
|
+
formData: Record<string, unknown>;
|
|
23
|
+
/** Update form data */
|
|
24
|
+
onFormDataChange: (data: Record<string, unknown>) => void;
|
|
25
|
+
/** Shipping selection */
|
|
26
|
+
selectedShipping: ShippingOption | null;
|
|
27
|
+
onShippingChange: (option: ShippingOption) => void;
|
|
28
|
+
/** Discount state */
|
|
29
|
+
appliedDiscount: DiscountResult | null;
|
|
30
|
+
onDiscountApplied: (result: DiscountResult) => void;
|
|
31
|
+
onDiscountRemoved: () => void;
|
|
32
|
+
/** Shipping address */
|
|
33
|
+
shippingAddress: AddressData;
|
|
34
|
+
onShippingAddressChange: (address: AddressData) => void;
|
|
35
|
+
/** Slot overrides */
|
|
36
|
+
checkoutFormSlot?: (props: CheckoutFormComponentProps) => React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export declare function CheckoutFormPanel({ formSchema, formComponent: FormComponent, shippingOptions, collectShippingAddress, enableDiscountCode, validateDiscount, tokenSymbol, tokenDecimals, classes, formData, onFormDataChange, selectedShipping, onShippingChange, appliedDiscount, onDiscountApplied, onDiscountRemoved, shippingAddress, onShippingAddressChange, checkoutFormSlot, }: CheckoutFormPanelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { CheckoutFormFieldComponent } from "./CheckoutFormField.js";
|
|
6
|
+
import { AddressForm } from "./AddressForm.js";
|
|
7
|
+
import { ShippingSelector } from "./ShippingSelector.js";
|
|
8
|
+
import { DiscountCodeInput } from "./DiscountCodeInput.js";
|
|
9
|
+
const emptyAddress = { street: "", city: "", state: "", zip: "", country: "" };
|
|
10
|
+
export function CheckoutFormPanel({ formSchema, formComponent: FormComponent, shippingOptions, collectShippingAddress, enableDiscountCode, validateDiscount, tokenSymbol, tokenDecimals, classes, formData, onFormDataChange, selectedShipping, onShippingChange, appliedDiscount, onDiscountApplied, onDiscountRemoved, shippingAddress, onShippingAddressChange, checkoutFormSlot, }) {
|
|
11
|
+
const [errors, setErrors] = useState({});
|
|
12
|
+
const hasFormFields = formSchema && formSchema.fields.length > 0;
|
|
13
|
+
const hasShipping = shippingOptions && shippingOptions.length > 0;
|
|
14
|
+
const hasAnyContent = hasFormFields || FormComponent || checkoutFormSlot || hasShipping || collectShippingAddress || enableDiscountCode;
|
|
15
|
+
// All hooks must be called before any early returns
|
|
16
|
+
const formDataRef = useRef(formData);
|
|
17
|
+
formDataRef.current = formData;
|
|
18
|
+
const handleFieldChange = useCallback((id, value) => {
|
|
19
|
+
onFormDataChange({ ...formDataRef.current, [id]: value });
|
|
20
|
+
setErrors(prev => {
|
|
21
|
+
if (!prev[id])
|
|
22
|
+
return prev;
|
|
23
|
+
const next = { ...prev };
|
|
24
|
+
delete next[id];
|
|
25
|
+
return next;
|
|
26
|
+
});
|
|
27
|
+
}, [onFormDataChange]);
|
|
28
|
+
const handleFormSubmit = useCallback((data) => {
|
|
29
|
+
onFormDataChange(data);
|
|
30
|
+
}, [onFormDataChange]);
|
|
31
|
+
const handleValidationChange = useCallback((_isValid) => {
|
|
32
|
+
// Validation is handled internally via errors state
|
|
33
|
+
}, []);
|
|
34
|
+
const handleDiscountApply = useCallback(async (code) => {
|
|
35
|
+
if (!validateDiscount) {
|
|
36
|
+
return { valid: false, error: "Discount validation not available" };
|
|
37
|
+
}
|
|
38
|
+
const result = await validateDiscount(code);
|
|
39
|
+
if (result.valid) {
|
|
40
|
+
onDiscountApplied(result);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}, [validateDiscount, onDiscountApplied]);
|
|
44
|
+
// Separate address fields from regular fields
|
|
45
|
+
const { regularFields, addressFields } = useMemo(() => {
|
|
46
|
+
if (!formSchema)
|
|
47
|
+
return { regularFields: [], addressFields: [] };
|
|
48
|
+
return {
|
|
49
|
+
regularFields: formSchema.fields.filter(f => f.type !== "address"),
|
|
50
|
+
addressFields: formSchema.fields.filter(f => f.type === "address"),
|
|
51
|
+
};
|
|
52
|
+
}, [formSchema]);
|
|
53
|
+
if (!hasAnyContent)
|
|
54
|
+
return null;
|
|
55
|
+
// Shared shipping + discount section
|
|
56
|
+
const shippingAndDiscount = (_jsxs(_Fragment, { children: [hasShipping && shippingOptions && (_jsx(ShippingSelector, { options: shippingOptions, selectedId: selectedShipping?.id || null, onSelect: onShippingChange, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals })), enableDiscountCode && validateDiscount && (_jsx(DiscountCodeInput, { onApply: handleDiscountApply, appliedDiscount: appliedDiscount, onRemove: onDiscountRemoved, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals }))] }));
|
|
57
|
+
// Render custom form slot if provided
|
|
58
|
+
if (checkoutFormSlot) {
|
|
59
|
+
return (_jsxs("div", { className: cn("anyspend-form-panel space-y-4", classes?.formPanel), children: [_jsx("div", { className: "anyspend-form-slot", children: checkoutFormSlot({
|
|
60
|
+
onSubmit: handleFormSubmit,
|
|
61
|
+
onValidationChange: handleValidationChange,
|
|
62
|
+
formData,
|
|
63
|
+
setFormData: onFormDataChange,
|
|
64
|
+
}) }), shippingAndDiscount] }));
|
|
65
|
+
}
|
|
66
|
+
// Render custom form component if provided
|
|
67
|
+
if (FormComponent) {
|
|
68
|
+
return (_jsxs("div", { className: cn("anyspend-form-panel space-y-4", classes?.formPanel), children: [_jsx("div", { className: "anyspend-form-component", children: _jsx(FormComponent, { onSubmit: handleFormSubmit, onValidationChange: handleValidationChange, formData: formData, setFormData: onFormDataChange }) }), shippingAndDiscount] }));
|
|
69
|
+
}
|
|
70
|
+
// Schema-based form rendering
|
|
71
|
+
return (_jsxs("div", { className: cn("anyspend-form-panel space-y-4", classes?.formPanel), children: [regularFields.length > 0 && (_jsx("div", { className: "anyspend-form-fields space-y-3", children: regularFields.map(field => (_jsx(CheckoutFormFieldComponent, { field: field, value: formData[field.id], onChange: handleFieldChange, error: errors[field.id] }, field.id))) })), addressFields.map(field => (_jsxs("div", { className: "anyspend-form-address space-y-2", children: [_jsx("h3", { className: "anyspend-form-address-title text-sm font-semibold text-gray-900 dark:text-gray-100", children: field.label }), _jsx(AddressForm, { value: formData[field.id] || emptyAddress, onChange: addr => handleFieldChange(field.id, addr), required: field.required })] }, field.id))), collectShippingAddress && addressFields.length === 0 && (_jsxs("div", { className: "anyspend-shipping-address space-y-2", children: [_jsx("h3", { className: "anyspend-shipping-address-title text-sm font-semibold text-gray-900 dark:text-gray-100", children: "Shipping Address" }), _jsx(AddressForm, { value: shippingAddress, onChange: onShippingAddressChange, required: true })] })), shippingAndDiscount] }));
|
|
72
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
3
|
+
interface CheckoutLayoutProps {
|
|
4
|
+
mode: "page" | "embedded";
|
|
5
|
+
paymentPanel: ReactNode;
|
|
6
|
+
cartPanel: ReactNode;
|
|
7
|
+
classes?: AnySpendCheckoutClasses;
|
|
8
|
+
}
|
|
9
|
+
export declare function CheckoutLayout({ mode, paymentPanel, cartPanel, classes }: CheckoutLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
+
export function CheckoutLayout({ mode, paymentPanel, cartPanel, classes }) {
|
|
5
|
+
const rightColumnWidth = mode === "page" ? 380 : 340;
|
|
6
|
+
return (_jsx("div", { className: cn("anyspend-checkout mx-auto w-full", classes?.root), style: {
|
|
7
|
+
...(mode === "page" ? { maxWidth: 1100, padding: "2rem 1rem" } : undefined),
|
|
8
|
+
"--anyspend-cart-width": `${rightColumnWidth}px`,
|
|
9
|
+
}, children: _jsxs("div", { className: cn("anyspend-checkout-grid", classes?.layout), children: [_jsx("div", { className: cn("anyspend-payment-col order-2", "rounded-2xl border border-gray-200 bg-white p-6 shadow-sm dark:border-neutral-700 dark:bg-neutral-900", classes?.paymentColumn), children: paymentPanel }), _jsx("div", { className: cn("anyspend-cart-col order-1", "rounded-2xl border border-gray-200 bg-gray-50 p-6 dark:border-neutral-700 dark:bg-neutral-800/50", classes?.cartColumn), children: cartPanel })] }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
interface CheckoutOrderStatusProps {
|
|
3
|
+
/** The order ID to track */
|
|
4
|
+
orderId: string;
|
|
5
|
+
/** Theme color (hex) */
|
|
6
|
+
themeColor?: string;
|
|
7
|
+
/** Return URL for the terminal success state */
|
|
8
|
+
returnUrl?: string;
|
|
9
|
+
/** Label for the return button */
|
|
10
|
+
returnLabel?: string;
|
|
11
|
+
/** Called when the order reaches "executed" */
|
|
12
|
+
onSuccess?: (result: {
|
|
13
|
+
txHash?: string;
|
|
14
|
+
orderId?: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
/** Called when the order reaches a failure/expired/refunded terminal state */
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
/** Called when the user clicks "Try again" on failure */
|
|
19
|
+
onRetry?: () => void;
|
|
20
|
+
/** Show the points row in the order status summary. Defaults to false. */
|
|
21
|
+
showPoints?: boolean;
|
|
22
|
+
/** Show the order ID row in the order status summary. Defaults to false. */
|
|
23
|
+
showOrderId?: boolean;
|
|
24
|
+
/** Custom class names */
|
|
25
|
+
classes?: AnySpendCheckoutClasses;
|
|
26
|
+
}
|
|
27
|
+
export declare function CheckoutOrderStatus({ orderId, themeColor, returnUrl, returnLabel, onSuccess, onError, onRetry, showPoints, showOrderId, classes, }: CheckoutOrderStatusProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { getErrorDisplay, getExplorerTxUrl, getStatusDisplay } from "../../../../anyspend/index.js";
|
|
4
|
+
import { useAnyspendOrderAndTransactions } from "../../../../anyspend/react/hooks/useAnyspendOrderAndTransactions.js";
|
|
5
|
+
import { useOnOrderSuccess } from "../../../../anyspend/react/hooks/useOnOrderSuccess.js";
|
|
6
|
+
import { TextShimmer } from "../../../../global-account/react/index.js";
|
|
7
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
8
|
+
import { formatNumber } from "../../../../shared/utils/formatNumber.js";
|
|
9
|
+
import { ExternalLink, Loader2, RefreshCcw } from "lucide-react";
|
|
10
|
+
import { motion } from "motion/react";
|
|
11
|
+
import { useEffect, useRef } from "react";
|
|
12
|
+
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext.js";
|
|
13
|
+
import { OrderStatus } from "../common/OrderStatus.js";
|
|
14
|
+
export function CheckoutOrderStatus({ orderId, themeColor, returnUrl, returnLabel, onSuccess, onError, onRetry, showPoints = false, showOrderId = false, classes, }) {
|
|
15
|
+
// Stable refs for callback props to avoid re-triggering effects
|
|
16
|
+
const onErrorRef = useRef(onError);
|
|
17
|
+
onErrorRef.current = onError;
|
|
18
|
+
const { orderAndTransactions, isLoadingOrderAndTransactions } = useAnyspendOrderAndTransactions(orderId);
|
|
19
|
+
const order = orderAndTransactions?.data?.order;
|
|
20
|
+
const executeTx = orderAndTransactions?.data?.executeTx;
|
|
21
|
+
const points = orderAndTransactions?.data?.points;
|
|
22
|
+
const { content } = useAnySpendCustomization();
|
|
23
|
+
// Fire onSuccess when order reaches "executed"
|
|
24
|
+
useOnOrderSuccess({
|
|
25
|
+
orderData: orderAndTransactions,
|
|
26
|
+
orderId,
|
|
27
|
+
onSuccess: (txHash) => onSuccess?.({ orderId, txHash }),
|
|
28
|
+
});
|
|
29
|
+
// Fire onError once for terminal failure states
|
|
30
|
+
const onErrorCalled = useRef(false);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!order || onErrorCalled.current)
|
|
33
|
+
return;
|
|
34
|
+
if (order.status === "failure" || order.status === "expired" || order.status === "refunded") {
|
|
35
|
+
const { description } = getStatusDisplay(order);
|
|
36
|
+
onErrorRef.current?.(new Error(description || `Order ${order.status}`));
|
|
37
|
+
onErrorCalled.current = true;
|
|
38
|
+
}
|
|
39
|
+
}, [order]);
|
|
40
|
+
// Reset error flag if orderId changes
|
|
41
|
+
const prevOrderId = useRef(orderId);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (prevOrderId.current !== orderId) {
|
|
44
|
+
onErrorCalled.current = false;
|
|
45
|
+
prevOrderId.current = orderId;
|
|
46
|
+
}
|
|
47
|
+
}, [orderId]);
|
|
48
|
+
// Clear persisted orderId when order reaches a terminal state
|
|
49
|
+
const orderStatus = order?.status;
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (orderStatus && ["executed", "failure", "expired", "refunded"].includes(orderStatus)) {
|
|
52
|
+
sessionStorage.removeItem("anyspend_checkout_orderId");
|
|
53
|
+
}
|
|
54
|
+
}, [orderStatus]);
|
|
55
|
+
// Loading state
|
|
56
|
+
if (isLoadingOrderAndTransactions || !order) {
|
|
57
|
+
return (_jsxs("div", { className: cn("flex flex-col items-center gap-3 py-12", classes?.orderStatusPanel), children: [_jsx(Loader2, { className: "h-6 w-6 animate-spin text-gray-400" }), _jsx(TextShimmer, { duration: 1.5, className: "text-sm", children: "Loading order status..." })] }));
|
|
58
|
+
}
|
|
59
|
+
const isExecuted = order.status === "executed";
|
|
60
|
+
const isRefunding = order.status === "refunding";
|
|
61
|
+
return (_jsxs(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, ease: "easeOut" }, className: cn("anyspend-checkout-order-status flex flex-col items-center gap-5 py-6", classes?.orderStatusPanel), children: [_jsx(OrderStatus, { order: order }), (showPoints || showOrderId) && (_jsx(motion.div, { initial: { opacity: 0, y: 8 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, delay: 0.15 }, className: "bg-as-surface-secondary border-as-border-secondary w-full rounded-xl border px-4 py-3", children: _jsxs("div", { className: "flex flex-col gap-2 text-sm", children: [showPoints && points != null && points > 0 && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex w-full justify-between", children: [_jsx("span", { className: "text-as-tertiary", children: "Points" }), _jsxs("span", { className: "text-as-brand font-semibold", children: ["+", formatNumber(points), " pts"] })] }), showOrderId && _jsx("div", { className: "divider w-full" })] })), showOrderId && (_jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [_jsx("span", { className: "text-as-tertiary shrink-0", children: "Order ID" }), _jsx("span", { className: "text-as-primary min-w-0 overflow-hidden text-ellipsis whitespace-nowrap", children: order.id })] }))] }) })), isExecuted && executeTx && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.3, ease: "easeOut" }, href: getExplorerTxUrl(order.dstChain, executeTx.txHash), target: "_blank", rel: "noopener noreferrer", className: cn("flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400", classes?.transactionLink), children: ["View Transaction", _jsx(ExternalLink, { className: "h-3.5 w-3.5" })] })), order.status === "failure" && order.errorDetails && (_jsx(motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.2, delay: 0.2 }, className: "max-w-[40ch] text-center text-sm text-red-500 dark:text-red-400", children: getErrorDisplay(order.errorDetails) })), (order.status === "failure" || order.status === "expired") && onRetry && (_jsxs(motion.button, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, delay: 0.3 }, onClick: onRetry, className: cn("flex items-center gap-2 rounded-xl px-6 py-3 text-sm font-medium transition-colors", "bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-neutral-800 dark:text-gray-300 dark:hover:bg-neutral-700", classes?.retryButton), children: [_jsx(RefreshCcw, { className: "h-4 w-4" }), content.retryButtonLabel || "Try Again"] })), (isExecuted || order.status === "refunded") && returnUrl && (_jsx(motion.a, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, delay: 0.4 }, href: returnUrl, className: cn("inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors", classes?.returnButton), style: { backgroundColor: themeColor || "#111827", color: "#fff" }, children: content.returnButtonLabel || returnLabel || "Return to Store" })), isRefunding && (_jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Please wait while your funds are being returned." }))] }));
|
|
62
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
export type PaymentMethod = "crypto" | "card" | "coinbase";
|
|
3
|
+
interface CheckoutPaymentPanelProps {
|
|
4
|
+
recipientAddress: string;
|
|
5
|
+
destinationTokenAddress: string;
|
|
6
|
+
destinationTokenChainId: number;
|
|
7
|
+
totalAmount: string;
|
|
8
|
+
buttonText?: string;
|
|
9
|
+
themeColor?: string;
|
|
10
|
+
returnUrl?: string;
|
|
11
|
+
returnLabel?: string;
|
|
12
|
+
onSuccess?: (result: {
|
|
13
|
+
txHash?: string;
|
|
14
|
+
orderId?: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
callbackMetadata?: Record<string, unknown>;
|
|
18
|
+
classes?: AnySpendCheckoutClasses;
|
|
19
|
+
/** Which payment method to expand initially. Defaults to none (all collapsed). */
|
|
20
|
+
defaultPaymentMethod?: PaymentMethod;
|
|
21
|
+
/** Optional sender (payer) address — pre-fills token balances in the crypto panel */
|
|
22
|
+
senderAddress?: string;
|
|
23
|
+
/** Show the points row in the order status summary. Defaults to false. */
|
|
24
|
+
showPoints?: boolean;
|
|
25
|
+
/** Show the order ID row in the order status summary. Defaults to false. */
|
|
26
|
+
showOrderId?: boolean;
|
|
27
|
+
/** Whether the checkout form is valid. When false, payment methods are disabled. */
|
|
28
|
+
isFormValid?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid, }: CheckoutPaymentPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
+
import { CreditCard, Wallet } from "lucide-react";
|
|
5
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
6
|
+
import { useCallback, useEffect, useState } from "react";
|
|
7
|
+
import { CheckoutOrderStatus } from "./CheckoutOrderStatus.js";
|
|
8
|
+
import { CoinbaseCheckoutPanel } from "./CoinbaseCheckoutPanel.js";
|
|
9
|
+
import { CryptoPayPanel } from "./CryptoPayPanel.js";
|
|
10
|
+
import { FiatCheckoutPanel } from "./FiatCheckoutPanel.js";
|
|
11
|
+
const SESSION_STORAGE_KEY = "anyspend_checkout_orderId";
|
|
12
|
+
function RadioCircle({ selected, themeColor }) {
|
|
13
|
+
return (_jsx("div", { className: cn("flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2 transition-colors", selected ? "border-blue-600" : "border-gray-300 dark:border-neutral-600"), style: selected && themeColor ? { borderColor: themeColor } : undefined, children: selected && (_jsx("div", { className: "h-2 w-2 rounded-full bg-blue-600", style: themeColor ? { backgroundColor: themeColor } : undefined })) }));
|
|
14
|
+
}
|
|
15
|
+
/** Card brand logos - all use consistent 32x20 viewBox */
|
|
16
|
+
function VisaLogo() {
|
|
17
|
+
return (_jsxs("svg", { viewBox: "0 0 32 20", style: { width: 32, height: 20 }, "aria-label": "Visa", children: [_jsx("rect", { width: "32", height: "20", rx: "3", fill: "#1A1F71" }), _jsx("text", { x: "16", y: "13.5", textAnchor: "middle", fill: "white", fontSize: "9", fontWeight: "bold", fontFamily: "sans-serif", fontStyle: "italic", children: "VISA" })] }));
|
|
18
|
+
}
|
|
19
|
+
function MastercardLogo() {
|
|
20
|
+
return (_jsxs("svg", { viewBox: "0 0 32 20", style: { width: 32, height: 20 }, "aria-label": "Mastercard", children: [_jsx("rect", { width: "32", height: "20", rx: "3", fill: "#252525" }), _jsx("circle", { cx: "12.5", cy: "10", r: "6", fill: "#EB001B" }), _jsx("circle", { cx: "19.5", cy: "10", r: "6", fill: "#F79E1B" }), _jsx("path", { d: "M16 5.6a6 6 0 0 1 0 8.8 6 6 0 0 1 0-8.8z", fill: "#FF5F00" })] }));
|
|
21
|
+
}
|
|
22
|
+
function AmexLogo() {
|
|
23
|
+
return (_jsxs("svg", { viewBox: "0 0 32 20", style: { width: 32, height: 20 }, "aria-label": "Amex", children: [_jsx("rect", { width: "32", height: "20", rx: "3", fill: "#006FCF" }), _jsx("text", { x: "16", y: "13", textAnchor: "middle", fill: "white", fontSize: "7", fontWeight: "bold", fontFamily: "sans-serif", children: "AMEX" })] }));
|
|
24
|
+
}
|
|
25
|
+
/** Coinbase mark */
|
|
26
|
+
function CoinbaseLogo() {
|
|
27
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", style: { width: 20, height: 20 }, "aria-label": "Coinbase", children: [_jsx("circle", { cx: "12", cy: "12", r: "12", fill: "#0052FF" }), _jsx("path", { d: "M12 4.5a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15zm-1.8 4.8h3.6c.33 0 .6.27.6.6v4.2c0 .33-.27.6-.6.6h-3.6a.6.6 0 0 1-.6-.6V9.9c0-.33.27-.6.6-.6z", fill: "white" })] }));
|
|
28
|
+
}
|
|
29
|
+
export function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid = true, }) {
|
|
30
|
+
const [paymentMethod, setPaymentMethod] = useState(defaultPaymentMethod ?? null);
|
|
31
|
+
// Restore activeOrderId from sessionStorage (handles page refresh / Coinbase return)
|
|
32
|
+
const [activeOrderId, setActiveOrderId] = useState(() => {
|
|
33
|
+
if (typeof window !== "undefined") {
|
|
34
|
+
return sessionStorage.getItem(SESSION_STORAGE_KEY) || null;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
});
|
|
38
|
+
// Persist activeOrderId to sessionStorage
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (activeOrderId) {
|
|
41
|
+
sessionStorage.setItem(SESSION_STORAGE_KEY, activeOrderId);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
sessionStorage.removeItem(SESSION_STORAGE_KEY);
|
|
45
|
+
}
|
|
46
|
+
}, [activeOrderId]);
|
|
47
|
+
const handleOrderCreated = useCallback((orderId) => {
|
|
48
|
+
setActiveOrderId(orderId);
|
|
49
|
+
}, []);
|
|
50
|
+
const handleRetry = useCallback(() => {
|
|
51
|
+
setActiveOrderId(null);
|
|
52
|
+
}, []);
|
|
53
|
+
if (activeOrderId) {
|
|
54
|
+
return (_jsx(CheckoutOrderStatus, { orderId: activeOrderId, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, onRetry: handleRetry, showPoints: showPoints, showOrderId: showOrderId, classes: classes }));
|
|
55
|
+
}
|
|
56
|
+
const accordionButtonClass = (active) => cn("anyspend-payment-method-btn flex w-full items-center gap-3 px-4 py-4 text-left transition-colors", active
|
|
57
|
+
? "bg-white dark:bg-neutral-900"
|
|
58
|
+
: "bg-white hover:bg-gray-50 dark:bg-neutral-900 dark:hover:bg-neutral-800", classes?.paymentMethodButton);
|
|
59
|
+
const expandedPanelClass = cn("anyspend-payment-method-panel border-t border-gray-100 bg-white px-4 py-4 dark:border-neutral-800 dark:bg-neutral-900");
|
|
60
|
+
return (_jsxs("div", { className: cn("anyspend-payment-panel flex flex-col gap-5", classes?.paymentPanel), children: [_jsx("h2", { className: cn("anyspend-payment-title text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.paymentTitle), children: "Payment" }), !isFormValid && (_jsx("p", { className: "text-sm text-amber-600 dark:text-amber-400", children: "Please complete the required fields above before proceeding to payment." })), _jsxs("div", { className: cn("anyspend-payment-methods divide-y divide-gray-200 overflow-hidden rounded-xl border border-gray-200 dark:divide-neutral-700 dark:border-neutral-700", !isFormValid && "pointer-events-none opacity-50", classes?.paymentMethodSelector), children: [_jsxs("div", { className: "anyspend-method-crypto", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "crypto" ? null : "crypto"), className: accordionButtonClass(paymentMethod === "crypto"), children: [_jsx(RadioCircle, { selected: paymentMethod === "crypto", themeColor: themeColor }), _jsx(Wallet, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Pay with crypto" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "crypto" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CryptoPayPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, buttonText: buttonText, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes, senderAddress: senderAddress }) }) }, "crypto-panel")) })] }), _jsxs("div", { className: "anyspend-method-card", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "card" ? null : "card"), className: accordionButtonClass(paymentMethod === "card"), children: [_jsx(RadioCircle, { selected: paymentMethod === "card", themeColor: themeColor }), _jsx(CreditCard, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Credit or debit card" }), _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [_jsx(VisaLogo, {}), _jsx(MastercardLogo, {}), _jsx(AmexLogo, {})] })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "card" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(FiatCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "card-panel")) })] }), _jsxs("div", { className: "anyspend-method-coinbase", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "coinbase" ? null : "coinbase"), className: accordionButtonClass(paymentMethod === "coinbase"), children: [_jsx(RadioCircle, { selected: paymentMethod === "coinbase", themeColor: themeColor }), _jsx(CoinbaseLogo, {}), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Coinbase Pay" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "coinbase" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CoinbaseCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "coinbase-panel")) })] })] })] }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
interface CheckoutSuccessProps {
|
|
3
|
+
txHash?: string;
|
|
4
|
+
orderId?: string;
|
|
5
|
+
returnUrl?: string;
|
|
6
|
+
returnLabel?: string;
|
|
7
|
+
classes?: AnySpendCheckoutClasses;
|
|
8
|
+
}
|
|
9
|
+
export declare function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
+
import { ExternalLink } from "lucide-react";
|
|
5
|
+
import { motion } from "motion/react";
|
|
6
|
+
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext.js";
|
|
7
|
+
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark.js";
|
|
8
|
+
export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
9
|
+
const { content, slots } = useAnySpendCustomization();
|
|
10
|
+
if (slots.successScreen) {
|
|
11
|
+
return (_jsx(_Fragment, { children: slots.successScreen({
|
|
12
|
+
title: typeof content.successTitle === "string" ? content.successTitle : "Payment Successful",
|
|
13
|
+
description: typeof content.successDescription === "string"
|
|
14
|
+
? content.successDescription
|
|
15
|
+
: "Your payment has been processed successfully.",
|
|
16
|
+
txHash,
|
|
17
|
+
orderId,
|
|
18
|
+
explorerUrl: txHash ? `https://explorer.b3.fun/tx/${txHash}` : undefined,
|
|
19
|
+
onDone: () => {
|
|
20
|
+
if (returnUrl)
|
|
21
|
+
window.location.href = returnUrl;
|
|
22
|
+
},
|
|
23
|
+
returnUrl,
|
|
24
|
+
returnLabel: content.returnButtonLabel || returnLabel,
|
|
25
|
+
}) }));
|
|
26
|
+
}
|
|
27
|
+
return (_jsxs("div", { className: cn("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [_jsx("div", { className: "anyspend-success-icon mb-4", children: _jsx(AnimatedCheckmark, { className: "h-16 w-16" }) }), _jsx(motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), _jsx(motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href: `https://explorer.b3.fun/tx/${txHash}`, target: "_blank", rel: "noopener noreferrer", className: "anyspend-success-tx-link mt-4 flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400", children: ["View Transaction", _jsx(ExternalLink, { className: "h-3.5 w-3.5" })] })), !txHash && orderId && (_jsxs(motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, className: "anyspend-success-order-id mt-4 text-xs text-gray-400 dark:text-gray-500", children: ["Order ID: ", orderId] })), returnUrl && (_jsx(motion.a, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.6, ease: "easeOut" }, href: returnUrl, className: cn("anyspend-success-return-btn mt-6 inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors", classes?.returnButton), style: { backgroundColor: "#111827", color: "#fff" }, children: content.returnButtonLabel || returnLabel || "Return to Store" }))] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
interface CoinbaseCheckoutPanelProps {
|
|
3
|
+
recipientAddress: string;
|
|
4
|
+
destinationTokenAddress: string;
|
|
5
|
+
destinationTokenChainId: number;
|
|
6
|
+
totalAmount: string;
|
|
7
|
+
themeColor?: string;
|
|
8
|
+
/** @deprecated Use onOrderCreated instead. Kept for backward compatibility. */
|
|
9
|
+
onSuccess?: (result: {
|
|
10
|
+
txHash?: string;
|
|
11
|
+
orderId?: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
/** Called when order is created — triggers lifecycle tracking in parent */
|
|
14
|
+
onOrderCreated?: (orderId: string) => void;
|
|
15
|
+
onError?: (error: Error) => void;
|
|
16
|
+
callbackMetadata?: Record<string, unknown>;
|
|
17
|
+
classes?: AnySpendCheckoutClasses;
|
|
18
|
+
}
|
|
19
|
+
export declare function CoinbaseCheckoutPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, }: CoinbaseCheckoutPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|