@commercelayer/react-components 2.53.3 → 3.0.0-alpha.1
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/LICENSE +2 -2
- package/README.md +3 -3
- package/lib/components/AdyenPayment.d.ts +3 -3
- package/lib/components/AdyenPayment.js +1 -1
- package/lib/components/AvailabilityContainer.d.ts +10 -3
- package/lib/components/AvailabilityContainer.js +1 -1
- package/lib/components/AvailabilityTemplate.d.ts +13 -4
- package/lib/components/AvailabilityTemplate.js +1 -1
- package/lib/components/BillingAddressContainer.d.ts +7 -2
- package/lib/components/BillingAddressContainer.js +1 -1
- package/lib/components/BillingAddressForm.d.ts +8 -3
- package/lib/components/BillingAddressForm.js +1 -1
- package/lib/components/BraintreePayment.d.ts +3 -3
- package/lib/components/BraintreePayment.js +1 -1
- package/lib/components/CheckoutComPayment.d.ts +23 -0
- package/lib/components/CheckoutComPayment.js +1 -0
- package/lib/components/CheckoutLink.d.ts +16 -4
- package/lib/components/CheckoutLink.js +1 -1
- package/lib/components/DeliveryLeadTime.d.ts +11 -4
- package/lib/components/DeliveryLeadTime.js +1 -1
- package/lib/components/DiscountAmount.d.ts +16 -2
- package/lib/components/DiscountAmount.js +1 -1
- package/lib/components/Errors.d.ts +4 -4
- package/lib/components/Errors.js +1 -1
- package/lib/components/ExternalFunction.d.ts +9 -2
- package/lib/components/ExternalFunction.js +1 -1
- package/lib/components/GiftCard.d.ts +13 -3
- package/lib/components/GiftCard.js +1 -1
- package/lib/components/GiftCardContainer.d.ts +9 -3
- package/lib/components/GiftCardContainer.js +1 -1
- package/lib/components/GiftCardCurrencySelector.d.ts +18 -3
- package/lib/components/GiftCardCurrencySelector.js +1 -1
- package/lib/components/GiftCardInput.d.ts +12 -3
- package/lib/components/GiftCardInput.js +1 -1
- package/lib/components/GiftCardOrCouponCode.d.ts +17 -6
- package/lib/components/GiftCardOrCouponCode.js +1 -1
- package/lib/components/GiftCardOrCouponForm.d.ts +9 -4
- package/lib/components/GiftCardOrCouponForm.js +1 -1
- package/lib/components/GiftCardOrCouponInput.d.ts +14 -3
- package/lib/components/GiftCardOrCouponInput.js +1 -1
- package/lib/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
- package/lib/components/GiftCardOrCouponRemoveButton.js +1 -1
- package/lib/components/GiftCardOrCouponSubmit.d.ts +11 -4
- package/lib/components/GiftCardOrCouponSubmit.js +1 -1
- package/lib/components/ItemContainer.d.ts +14 -3
- package/lib/components/ItemContainer.js +1 -1
- package/lib/components/KlarnaPayment.d.ts +10 -0
- package/lib/components/KlarnaPayment.js +1 -0
- package/lib/components/LineItem.d.ts +10 -3
- package/lib/components/LineItem.js +1 -1
- package/lib/components/LineItemAmount.d.ts +16 -3
- package/lib/components/LineItemAmount.js +1 -1
- package/lib/components/LineItemCode.d.ts +10 -4
- package/lib/components/LineItemCode.js +1 -1
- package/lib/components/LineItemImage.d.ts +11 -4
- package/lib/components/LineItemImage.js +1 -1
- package/lib/components/LineItemName.d.ts +11 -5
- package/lib/components/LineItemName.js +1 -1
- package/lib/components/LineItemOption.d.ts +15 -4
- package/lib/components/LineItemOption.js +1 -1
- package/lib/components/LineItemOptions.d.ts +8 -3
- package/lib/components/LineItemOptions.js +1 -1
- package/lib/components/LineItemQuantity.d.ts +16 -4
- package/lib/components/LineItemQuantity.js +1 -1
- package/lib/components/LineItemRemoveLink.d.ts +15 -5
- package/lib/components/LineItemRemoveLink.js +1 -1
- package/lib/components/LineItemsContainer.d.ts +15 -3
- package/lib/components/LineItemsContainer.js +1 -1
- package/lib/components/LineItemsCount.d.ts +14 -4
- package/lib/components/LineItemsCount.js +1 -1
- package/lib/components/LineItemsEmpty.d.ts +13 -2
- package/lib/components/LineItemsEmpty.js +1 -1
- package/lib/components/MetadataInput.d.ts +13 -3
- package/lib/components/MetadataInput.js +1 -1
- package/lib/components/PaymentGateway.d.ts +4 -4
- package/lib/components/PaymentGateway.js +1 -1
- package/lib/components/PaymentMethod.d.ts +9 -3
- package/lib/components/PaymentMethod.js +1 -1
- package/lib/components/PaymentMethodAmount.d.ts +16 -2
- package/lib/components/PaymentMethodAmount.js +1 -1
- package/lib/components/PaymentMethodName.d.ts +10 -4
- package/lib/components/PaymentMethodName.js +1 -1
- package/lib/components/PaymentMethodPrice.d.ts +15 -4
- package/lib/components/PaymentMethodPrice.js +1 -1
- package/lib/components/PaymentMethodRadioButton.d.ts +11 -4
- package/lib/components/PaymentMethodRadioButton.js +1 -1
- package/lib/components/PaymentMethodsContainer.d.ts +9 -3
- package/lib/components/PaymentMethodsContainer.js +1 -1
- package/lib/components/PaymentSource.d.ts +9 -2
- package/lib/components/PaymentSource.js +1 -1
- package/lib/components/PaymentSourceBrandIcon.d.ts +14 -4
- package/lib/components/PaymentSourceBrandIcon.js +1 -1
- package/lib/components/PaymentSourceBrandName.d.ts +11 -4
- package/lib/components/PaymentSourceBrandName.js +1 -1
- package/lib/components/PaymentSourceDetail.d.ts +8 -2
- package/lib/components/PaymentSourceDetail.js +1 -1
- package/lib/components/PaymentSourceEditButton.d.ts +9 -2
- package/lib/components/PaymentSourceEditButton.js +1 -1
- package/lib/components/PaypalPayment.d.ts +2 -2
- package/lib/components/PaypalPayment.js +1 -1
- package/lib/components/Price.d.ts +15 -3
- package/lib/components/Price.js +1 -1
- package/lib/components/PricesContainer.d.ts +19 -3
- package/lib/components/PricesContainer.js +1 -1
- package/lib/components/QuantitySelector.d.ts +19 -5
- package/lib/components/QuantitySelector.js +1 -1
- package/lib/components/SaveAddressesButton.d.ts +18 -5
- package/lib/components/SaveAddressesButton.js +1 -1
- package/lib/components/SaveCustomerButton.d.ts +16 -5
- package/lib/components/SaveCustomerButton.js +1 -1
- package/lib/components/Shipment.d.ts +9 -2
- package/lib/components/Shipment.js +1 -1
- package/lib/components/ShipmentField.d.ts +11 -4
- package/lib/components/ShipmentField.js +1 -1
- package/lib/components/ShipmentsContainer.d.ts +9 -3
- package/lib/components/ShipmentsContainer.js +1 -1
- package/lib/components/ShippingAddressContainer.d.ts +7 -2
- package/lib/components/ShippingAddressContainer.js +1 -1
- package/lib/components/ShippingAddressForm.d.ts +8 -3
- package/lib/components/ShippingAddressForm.js +1 -1
- package/lib/components/ShippingAmount.d.ts +13 -2
- package/lib/components/ShippingAmount.js +1 -1
- package/lib/components/ShippingMethod.d.ts +10 -3
- package/lib/components/ShippingMethod.js +1 -1
- package/lib/components/ShippingMethodName.d.ts +11 -5
- package/lib/components/ShippingMethodName.js +1 -1
- package/lib/components/ShippingMethodPrice.d.ts +15 -3
- package/lib/components/ShippingMethodPrice.js +1 -1
- package/lib/components/ShippingMethodRadioButton.d.ts +11 -5
- package/lib/components/ShippingMethodRadioButton.js +1 -1
- package/lib/components/StockTransfer.d.ts +9 -3
- package/lib/components/StockTransfer.js +1 -1
- package/lib/components/StockTransferField.d.ts +9 -8
- package/lib/components/StockTransferField.js +1 -1
- package/lib/components/StripePayment.d.ts +3 -3
- package/lib/components/StripePayment.js +1 -1
- package/lib/components/SubmitButton.d.ts +15 -5
- package/lib/components/SubmitButton.js +1 -1
- package/lib/components/VariantSelector.d.ts +28 -5
- package/lib/components/VariantSelector.js +1 -1
- package/lib/components/VariantsContainer.d.ts +15 -3
- package/lib/components/VariantsContainer.js +1 -1
- package/lib/components/WireTransferPayment.d.ts +2 -2
- package/lib/components/WireTransferPayment.js +1 -1
- package/lib/components/addresses/Address.d.ts +18 -0
- package/lib/components/addresses/Address.js +1 -0
- package/lib/components/addresses/AddressCountrySelector.d.ts +26 -0
- package/lib/components/addresses/AddressCountrySelector.js +1 -0
- package/lib/components/addresses/AddressField.d.ts +43 -0
- package/lib/components/addresses/AddressField.js +1 -0
- package/lib/components/addresses/AddressInput.d.ts +19 -0
- package/lib/components/addresses/AddressInput.js +1 -0
- package/lib/components/addresses/AddressStateSelector.d.ts +27 -0
- package/lib/components/addresses/AddressStateSelector.js +1 -0
- package/lib/components/addresses/AddressesContainer.d.ts +15 -0
- package/lib/components/addresses/AddressesContainer.js +1 -0
- package/lib/components/auth/CommerceLayer.d.ts +15 -0
- package/lib/components/auth/CommerceLayer.js +1 -0
- package/lib/components/customers/CustomerAddressForm.d.ts +13 -0
- package/lib/components/customers/CustomerAddressForm.js +1 -0
- package/lib/components/customers/CustomerContainer.d.ts +17 -0
- package/lib/components/customers/CustomerContainer.js +1 -0
- package/lib/components/customers/CustomerField.d.ts +10 -0
- package/lib/components/customers/CustomerField.js +1 -0
- package/lib/components/customers/CustomerInput.d.ts +23 -0
- package/lib/components/customers/CustomerInput.js +1 -0
- package/lib/components/gateways/AdyenGateway.d.ts +2 -2
- package/lib/components/gateways/AdyenGateway.js +1 -1
- package/lib/components/gateways/BraintreeGateway.d.ts +2 -2
- package/lib/components/gateways/BraintreeGateway.js +1 -1
- package/lib/components/gateways/CheckoutComGateway.d.ts +5 -0
- package/lib/components/gateways/CheckoutComGateway.js +1 -0
- package/lib/components/gateways/KlarnaGateway.d.ts +5 -0
- package/lib/components/gateways/KlarnaGateway.js +1 -0
- package/lib/components/gateways/PaypalGateway.d.ts +3 -3
- package/lib/components/gateways/PaypalGateway.js +1 -1
- package/lib/components/gateways/StripeGateway.d.ts +2 -2
- package/lib/components/gateways/StripeGateway.js +1 -1
- package/lib/components/gateways/WireTransferGateway.d.ts +2 -2
- package/lib/components/gateways/WireTransferGateway.js +1 -1
- package/lib/components/orders/AddToCartButton.d.ts +34 -0
- package/lib/components/orders/AddToCartButton.js +1 -0
- package/lib/components/orders/AdjustmentAmount.d.ts +18 -0
- package/lib/components/orders/AdjustmentAmount.js +1 -0
- package/lib/components/orders/CartLink.d.ts +12 -0
- package/lib/components/orders/CartLink.js +1 -0
- package/lib/components/orders/GiftCardAmount.d.ts +15 -0
- package/lib/components/orders/GiftCardAmount.js +1 -0
- package/lib/components/orders/OrderContainer.d.ts +26 -0
- package/lib/components/orders/OrderContainer.js +1 -0
- package/lib/components/orders/OrderList.d.ts +61 -0
- package/lib/components/orders/OrderList.js +1 -0
- package/lib/components/orders/OrderListRow.d.ts +30 -0
- package/lib/components/orders/OrderListRow.js +1 -0
- package/lib/components/orders/OrderNumber.d.ts +11 -0
- package/lib/components/orders/OrderNumber.js +1 -0
- package/lib/components/orders/OrderStorage.d.ts +16 -0
- package/lib/components/orders/OrderStorage.js +1 -0
- package/lib/components/orders/PlaceOrderButton.d.ts +24 -0
- package/lib/components/orders/PlaceOrderButton.js +1 -0
- package/lib/components/orders/PlaceOrderContainer.d.ts +14 -0
- package/lib/components/orders/PlaceOrderContainer.js +1 -0
- package/lib/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
- package/lib/components/orders/PrivacyAndTermsCheckbox.js +1 -0
- package/lib/components/orders/SubTotalAmount.d.ts +18 -0
- package/lib/components/orders/SubTotalAmount.js +1 -0
- package/lib/components/orders/TaxesAmount.d.ts +18 -0
- package/lib/components/orders/TaxesAmount.js +1 -0
- package/lib/components/orders/TotalAmount.d.ts +18 -0
- package/lib/components/orders/TotalAmount.js +1 -0
- package/lib/components/skus/SkuField.d.ts +14 -0
- package/lib/components/skus/SkuField.js +1 -0
- package/lib/components/skus/SkuList.d.ts +14 -0
- package/lib/components/skus/SkuList.js +1 -0
- package/lib/components/skus/SkuListsContainer.d.ts +12 -0
- package/lib/components/skus/SkuListsContainer.js +1 -0
- package/lib/components/skus/SkuOption.d.ts +14 -0
- package/lib/components/skus/SkuOption.js +1 -0
- package/lib/components/skus/SkuOptionInput.d.ts +15 -0
- package/lib/components/skus/SkuOptionInput.js +1 -0
- package/lib/components/skus/SkuOptionsContainer.d.ts +14 -0
- package/lib/components/skus/SkuOptionsContainer.js +1 -0
- package/lib/components/skus/Skus.d.ts +11 -0
- package/lib/components/skus/Skus.js +1 -0
- package/lib/components/skus/SkusContainer.d.ts +23 -0
- package/lib/components/skus/SkusContainer.js +1 -0
- package/lib/components/utils/AddressCardsTemplate.d.ts +1 -1
- package/lib/components/utils/AddressCardsTemplate.js +1 -1
- package/lib/components/utils/BaseField.js +1 -1
- package/lib/components/utils/BaseInput.d.ts +1 -1
- package/lib/components/utils/BaseInput.js +1 -1
- package/lib/components/utils/BaseOrderPrice.js +1 -1
- package/lib/components/utils/BaseSelect.js +1 -1
- package/lib/components/utils/GenericFieldComponent.d.ts +42 -0
- package/lib/components/utils/GenericFieldComponent.js +1 -0
- package/lib/components/utils/Parent.d.ts +3 -5
- package/lib/components/utils/Parent.js +1 -1
- package/lib/components/utils/PaymentCardsTemplate.d.ts +2 -2
- package/lib/components/utils/PaymentCardsTemplate.js +1 -1
- package/lib/components/utils/PriceTemplate.d.ts +2 -2
- package/lib/components/utils/PriceTemplate.js +1 -1
- package/lib/components/utils/VariantTemplate.js +1 -1
- package/lib/components/utils/getAllErrors.js +1 -1
- package/lib/config/components.d.ts +77 -35
- package/lib/config/components.js +1 -1
- package/lib/context/AddressChildrenContext.d.ts +1 -1
- package/lib/context/AddressChildrenContext.js +1 -1
- package/lib/context/AddressContext.d.ts +1 -1
- package/lib/context/BillingAddressContext.d.ts +2 -4
- package/lib/context/BillingAddressContext.js +1 -1
- package/lib/context/BillingAddressFormContext.d.ts +17 -10
- package/lib/context/CouponAndGiftCardFormContext.d.ts +2 -0
- package/lib/context/CustomerAddressFormContext.d.ts +20 -0
- package/lib/context/CustomerAddressFormContext.js +1 -0
- package/lib/context/CustomerContext.d.ts +17 -11
- package/lib/context/CustomerContext.js +1 -1
- package/lib/context/OrderContext.d.ts +8 -4
- package/lib/context/OrderContext.js +1 -1
- package/lib/context/OrderListChildrenContext.d.ts +60 -0
- package/lib/context/OrderListChildrenContext.js +1 -0
- package/lib/context/PaymentSourceContext.d.ts +4 -4
- package/lib/context/PlaceOrderContext.d.ts +4 -2
- package/lib/context/ShippingAddressContext.d.ts +1 -1
- package/lib/context/SkuChildrenContext.d.ts +9 -0
- package/lib/context/SkuChildrenContext.js +1 -0
- package/lib/context/SkuContext.d.ts +9 -0
- package/lib/context/SkuContext.js +1 -0
- package/lib/index.d.ts +101 -90
- package/lib/index.js +1 -1
- package/lib/reducers/AddressReducer.d.ts +4 -2
- package/lib/reducers/AddressReducer.js +1 -1
- package/lib/reducers/AvailabilityReducer.d.ts +8 -0
- package/lib/reducers/AvailabilityReducer.js +1 -1
- package/lib/reducers/BillingAddressReducer.js +1 -1
- package/lib/reducers/CustomerReducer.d.ts +98 -17
- package/lib/reducers/CustomerReducer.js +1 -1
- package/lib/reducers/GiftCardReducer.js +1 -1
- package/lib/reducers/LineItemReducer.js +1 -1
- package/lib/reducers/OrderReducer.d.ts +24 -8
- package/lib/reducers/OrderReducer.js +1 -1
- package/lib/reducers/PaymentMethodReducer.d.ts +51 -5
- package/lib/reducers/PaymentMethodReducer.js +1 -1
- package/lib/reducers/PlaceOrderReducer.d.ts +9 -2
- package/lib/reducers/PlaceOrderReducer.js +1 -1
- package/lib/reducers/ShipmentReducer.js +1 -1
- package/lib/reducers/ShippingAddressReducer.js +1 -1
- package/lib/reducers/SkuReducer.d.ts +21 -0
- package/lib/reducers/SkuReducer.js +1 -0
- package/lib/reducers/VariantReducer.d.ts +1 -0
- package/lib/reducers/VariantReducer.js +1 -1
- package/lib/typings/errors.d.ts +13 -4
- package/lib/typings/errors.js +1 -1
- package/lib/typings/index.d.ts +17 -6
- package/lib/utils/addressesManager.d.ts +1 -1
- package/lib/utils/addressesManager.js +1 -1
- package/lib/utils/checkIncludeResource.d.ts +8 -0
- package/lib/utils/checkIncludeResource.js +1 -0
- package/lib/utils/childrenTypes.d.ts +1 -1
- package/lib/utils/childrenTypes.js +1 -1
- package/lib/utils/compareObjAttribute.d.ts +7 -0
- package/lib/utils/compareObjAttribute.js +1 -0
- package/lib/utils/customMessages.d.ts +1 -7
- package/lib/utils/customMessages.js +1 -1
- package/lib/utils/getCardDetails.d.ts +15 -0
- package/lib/utils/getCardDetails.js +1 -0
- package/lib/utils/getCartLink.d.ts +7 -0
- package/lib/utils/getCartLink.js +1 -0
- package/lib/utils/getCurrentItemKey.js +1 -1
- package/lib/utils/getErrors.d.ts +1 -1
- package/lib/utils/getErrors.js +1 -1
- package/lib/utils/getLineItemsCount.d.ts +8 -10
- package/lib/utils/getLineItemsCount.js +1 -1
- package/lib/utils/getLoaderComponent.js +1 -1
- package/lib/utils/getPrices.js +1 -1
- package/lib/utils/getSkus.js +1 -1
- package/lib/utils/hooks/useExternalScript.d.ts +1 -0
- package/lib/utils/hooks/useExternalScript.js +1 -0
- package/lib/utils/icons.d.ts +3 -0
- package/lib/utils/icons.js +1 -0
- package/lib/utils/isDate.d.ts +1 -0
- package/lib/utils/isDate.js +1 -0
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/placeholderImages.d.ts +2 -0
- package/lib/utils/placeholderImages.js +1 -0
- package/lib/utils/promisify.js +1 -1
- package/lib/utils/scrollbarWidth.d.ts +1 -0
- package/lib/utils/scrollbarWidth.js +1 -0
- package/lib/utils/shipments.d.ts +2 -1
- package/lib/utils/shipments.js +1 -1
- package/lib/utils/validateFormFields.d.ts +2 -0
- package/lib/utils/validateFormFields.js +1 -1
- package/package.json +96 -93
- package/lib/components/AddToCartButton.d.ts +0 -20
- package/lib/components/AddToCartButton.js +0 -1
- package/lib/components/Address.d.ts +0 -13
- package/lib/components/Address.js +0 -1
- package/lib/components/AddressCountrySelector.d.ts +0 -9
- package/lib/components/AddressCountrySelector.js +0 -1
- package/lib/components/AddressField.d.ts +0 -15
- package/lib/components/AddressField.js +0 -1
- package/lib/components/AddressInput.d.ts +0 -7
- package/lib/components/AddressInput.js +0 -1
- package/lib/components/AddressStateSelector.d.ts +0 -11
- package/lib/components/AddressStateSelector.js +0 -1
- package/lib/components/AddressesContainer.d.ts +0 -7
- package/lib/components/AddressesContainer.js +0 -1
- package/lib/components/AdjustmentAmount.d.ts +0 -4
- package/lib/components/AdjustmentAmount.js +0 -1
- package/lib/components/CommerceLayer.d.ts +0 -8
- package/lib/components/CommerceLayer.js +0 -1
- package/lib/components/CustomerContainer.d.ts +0 -7
- package/lib/components/CustomerContainer.js +0 -1
- package/lib/components/CustomerInput.d.ts +0 -11
- package/lib/components/CustomerInput.js +0 -1
- package/lib/components/GiftCardAmount.d.ts +0 -4
- package/lib/components/GiftCardAmount.js +0 -1
- package/lib/components/OrderContainer.d.ts +0 -11
- package/lib/components/OrderContainer.js +0 -1
- package/lib/components/OrderNumber.d.ts +0 -5
- package/lib/components/OrderNumber.js +0 -1
- package/lib/components/OrderStorage.d.ts +0 -8
- package/lib/components/OrderStorage.js +0 -1
- package/lib/components/PlaceOrderButton.d.ts +0 -12
- package/lib/components/PlaceOrderButton.js +0 -1
- package/lib/components/PlaceOrderContainer.d.ts +0 -8
- package/lib/components/PlaceOrderContainer.js +0 -1
- package/lib/components/PrivacyAndTermsCheckbox.d.ts +0 -4
- package/lib/components/PrivacyAndTermsCheckbox.js +0 -1
- package/lib/components/SkuList.d.ts +0 -7
- package/lib/components/SkuList.js +0 -1
- package/lib/components/SkuListsContainer.d.ts +0 -6
- package/lib/components/SkuListsContainer.js +0 -1
- package/lib/components/SkuOption.d.ts +0 -7
- package/lib/components/SkuOption.js +0 -1
- package/lib/components/SkuOptionInput.d.ts +0 -5
- package/lib/components/SkuOptionInput.js +0 -1
- package/lib/components/SkuOptionsContainer.d.ts +0 -7
- package/lib/components/SkuOptionsContainer.js +0 -1
- package/lib/components/SubTotalAmount.d.ts +0 -4
- package/lib/components/SubTotalAmount.js +0 -1
- package/lib/components/TaxesAmount.d.ts +0 -4
- package/lib/components/TaxesAmount.js +0 -1
- package/lib/components/TotalAmount.d.ts +0 -4
- package/lib/components/TotalAmount.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../reducers/LineItemReducer";import OrderContext from"../context/OrderContext";import LineItemContext from"../context/LineItemContext";import CommerceLayerContext from"../context/CommerceLayerContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../reducers/LineItemReducer";import OrderContext from"../context/OrderContext";import LineItemContext from"../context/LineItemContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";const propTypes=components.LineItemsContainer.propTypes,defaultProps=components.LineItemsContainer.defaultProps,displayName=components.LineItemsContainer.displayName;export function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),useEffect(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue=Object.assign(Object.assign({},state),{loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})});return _jsx(LineItemContext.Provider,Object.assign({value:lineItemValue},{children:state.loading?loader:children}))}LineItemsContainer.propTypes=propTypes,LineItemsContainer.defaultProps=defaultProps,LineItemsContainer.displayName=displayName;export default LineItemsContainer;
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { TypeAccepted } from '../utils/getLineItemsCount';
|
|
3
3
|
import { FunctionChildren } from '../typings/index';
|
|
4
|
-
declare type LineItemsCountChildrenProps = FunctionChildren<Omit<
|
|
4
|
+
declare type LineItemsCountChildrenProps = FunctionChildren<Omit<Props, 'children'> & {
|
|
5
5
|
quantity: number;
|
|
6
6
|
}>;
|
|
7
|
-
declare type
|
|
7
|
+
declare type Props = {
|
|
8
8
|
children?: LineItemsCountChildrenProps;
|
|
9
9
|
typeAccepted?: TypeAccepted[];
|
|
10
10
|
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare
|
|
11
|
+
export declare function LineItemsCount(props: Props): JSX.Element;
|
|
12
|
+
export declare namespace LineItemsCount {
|
|
13
|
+
var propTypes: {
|
|
14
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
15
|
+
id: import("prop-types").Requireable<string>;
|
|
16
|
+
className: import("prop-types").Requireable<string>;
|
|
17
|
+
name: import("prop-types").Requireable<string>;
|
|
18
|
+
style: import("prop-types").Requireable<object>;
|
|
19
|
+
};
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
12
22
|
export default LineItemsCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsCount.propTypes,displayName=components.LineItemsCount.displayName;export function LineItemsCount(props){const{children,typeAccepted}=props,p=__rest(props,["children","typeAccepted"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0);useEffect(()=>{if(lineItems&&lineItems.length>0){const qty=getLineItemsCount({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps=Object.assign({quantity,typeAccepted},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},p,{children:quantity}))}LineItemsCount.propTypes=propTypes,LineItemsCount.displayName=displayName;export default LineItemsCount;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { FunctionChildren } from '../typings/index';
|
|
3
3
|
export declare type LineItemsCountType = FunctionChildren<Omit<LineItemsCountProps, 'children'> & {
|
|
4
4
|
quantity: number;
|
|
@@ -8,5 +8,16 @@ declare type LineItemsCountProps = {
|
|
|
8
8
|
children?: LineItemsCountType;
|
|
9
9
|
text?: string;
|
|
10
10
|
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare
|
|
11
|
+
export declare function LineItemsEmpty(props: LineItemsCountProps): JSX.Element | null;
|
|
12
|
+
export declare namespace LineItemsEmpty {
|
|
13
|
+
var propTypes: {
|
|
14
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
15
|
+
id: import("prop-types").Requireable<string>;
|
|
16
|
+
className: import("prop-types").Requireable<string>;
|
|
17
|
+
name: import("prop-types").Requireable<string>;
|
|
18
|
+
style: import("prop-types").Requireable<object>;
|
|
19
|
+
text: import("prop-types").Requireable<string>;
|
|
20
|
+
};
|
|
21
|
+
var displayName: string;
|
|
22
|
+
}
|
|
12
23
|
export default LineItemsEmpty;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsEmpty.propTypes,displayName=components.LineItemsEmpty.displayName;export function LineItemsEmpty(props){const{children,text="Your shopping bag is empty"}=props,p=__rest(props,["children","text"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(),emptyText=quantity===0?_jsx("span",Object.assign({},p,{children:text})):null;useEffect(()=>{if(lineItems)if(lineItems.length>0){const qty=getLineItemsCount({lineItems:lineItems||[]});setQuantity(qty)}else setQuantity(0);return()=>{setQuantity(void 0)}},[lineItems]);const parentProps=Object.assign({quantity,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):emptyText}LineItemsEmpty.propTypes=propTypes,LineItemsEmpty.displayName=displayName;export default LineItemsEmpty;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { BaseInputComponentProps } from '../typings/index';
|
|
3
|
-
|
|
4
|
-
declare
|
|
3
|
+
declare type Props = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
|
|
4
|
+
export declare function MetadataInput(props: Props): JSX.Element;
|
|
5
|
+
export declare namespace MetadataInput {
|
|
6
|
+
var propTypes: {
|
|
7
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
8
|
+
name: import("prop-types").Validator<string>;
|
|
9
|
+
type: import("prop-types").Validator<import("../typings/index").BaseInputType>;
|
|
10
|
+
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
11
|
+
placeholder: import("prop-types").Requireable<string>;
|
|
12
|
+
};
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
5
15
|
export default MetadataInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";import components from"../config/components";const propTypes=components.MetadataInput.propTypes,displayName=components.MetadataInput.displayName
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";import components from"../config/components";const propTypes=components.MetadataInput.propTypes,displayName=components.MetadataInput.displayName;export function MetadataInput(props){return _jsx(BaseInput,Object.assign({"data-metadata":!0},props))}MetadataInput.propTypes=propTypes,MetadataInput.displayName=displayName;export default MetadataInput;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { LoaderType } from '../typings/index';
|
|
2
|
-
import { FunctionComponent } from 'react';
|
|
3
3
|
import { PaymentSourceProps } from './PaymentSource';
|
|
4
|
-
export declare type GatewayBaseType =
|
|
4
|
+
export declare type GatewayBaseType = Props & {
|
|
5
5
|
show: boolean;
|
|
6
6
|
loading: boolean;
|
|
7
7
|
loaderComponent: JSX.Element;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
declare type Props = PaymentSourceProps & {
|
|
10
10
|
showCard: boolean;
|
|
11
11
|
handleEditClick: (e: MouseEvent) => void;
|
|
12
12
|
show: boolean;
|
|
13
13
|
loader?: LoaderType;
|
|
14
14
|
};
|
|
15
|
-
declare
|
|
15
|
+
export declare function PaymentGateway({ readonly, showCard, handleEditClick, children, templateCustomerCards, templateCustomerSaveToWallet, onClickCustomerCards, show, loader, ...p }: Props): JSX.Element | null;
|
|
16
16
|
export default PaymentGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../context/OrderContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../context/PaymentMethodContext";import getPaypalConfig from"../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../utils/getLoaderComponent";import
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../context/OrderContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../context/PaymentMethodContext";import getPaypalConfig from"../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../utils/getLoaderComponent";import CustomerContext from"../context/CustomerContext";export function PaymentGateway(_a){var _b,{readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading..."}=_a,p=__rest(_a,["readonly","showCard","handleEditClick","children","templateCustomerCards","templateCustomerSaveToWallet","onClickCustomerCards","show","loader"]);const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{var _a2;if(payment?.id===currentPaymentMethodId&&paymentResource&&((_a2=order?.payment_method)===null||_a2===void 0?void 0:_a2.payment_source_type)===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{},setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[(_b=order?.payment_method)===null||_b===void 0?void 0:_b.id,show,paymentSource]);const gatewayConfig=Object.assign({readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet},p);switch(paymentResource){case"stripe_payments":return _jsx(StripeGateway,Object.assign({},gatewayConfig,{children}));case"klarna_payments":return _jsx(KlarnaGateway,Object.assign({},gatewayConfig,{children}));case"adyen_payments":return _jsx(AdyenGateway,Object.assign({},gatewayConfig,{children}));case"braintree_payments":return _jsx(BraintreeGateway,Object.assign({},gatewayConfig,{children}));case"wire_transfers":return _jsx(WireTransferGateway,Object.assign({},gatewayConfig,{children}));case"paypal_payments":return _jsx(PaypalGateway,Object.assign({},gatewayConfig,{children}));case"checkout_com_payments":return _jsx(CheckoutComGateway,Object.assign({},gatewayConfig,{children}));default:return null}}export default PaymentGateway;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { LoaderType } from '../typings/index';
|
|
3
3
|
import { PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
|
|
4
|
-
declare type
|
|
4
|
+
declare type Props = {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
activeClass?: string;
|
|
7
7
|
loader?: LoaderType;
|
|
@@ -12,5 +12,11 @@ declare type PaymentMethodProps = {
|
|
|
12
12
|
clickableContainer?: never;
|
|
13
13
|
onClick?: never;
|
|
14
14
|
});
|
|
15
|
-
declare
|
|
15
|
+
export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, onClick, ...p }: Props): JSX.Element;
|
|
16
|
+
export declare namespace PaymentMethod {
|
|
17
|
+
var propTypes: {
|
|
18
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
19
|
+
};
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
16
22
|
export default PaymentMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import getLoaderComponent from"../utils/getLoaderComponent";const propTypes=components.PaymentMethod.propTypes,displayName=components.PaymentMethod.displayName
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import getLoaderComponent from"../utils/getLoaderComponent";const propTypes=components.PaymentMethod.propTypes,displayName=components.PaymentMethod.displayName;export function PaymentMethod(_a){var{children,className,activeClass,loader="Loading...",clickableContainer,onClick}=_a,p=__rest(_a,["children","className","activeClass","loader","clickableContainer","onClick"]);const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useContext(PaymentMethodContext);useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components2=paymentMethods&&paymentMethods.map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",Object.assign({"data-test-id":paymentResource,className:`${className} ${isActive?activeClass:""}`,onClick:onClickable},p,{children:_jsx(PaymentMethodChildrenContext.Provider,Object.assign({value:paymentMethodProps},{children}))}),k)});return loading?getLoaderComponent(loader):_jsx(Fragment,{children:components2})}PaymentMethod.propTypes=propTypes,PaymentMethod.displayName=displayName;export default PaymentMethod;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { BaseAmountComponent } from '../typings/index';
|
|
3
|
-
declare
|
|
3
|
+
export declare function PaymentMethodAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
|
+
export declare namespace PaymentMethodAmount {
|
|
5
|
+
var propTypes: {
|
|
6
|
+
id: import("prop-types").Requireable<string>;
|
|
7
|
+
className: import("prop-types").Requireable<string>;
|
|
8
|
+
style: import("prop-types").Requireable<object>;
|
|
9
|
+
name: import("prop-types").Requireable<string>;
|
|
10
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
11
|
+
format: import("prop-types").Requireable<import("../typings/index").BaseFormatPrice>;
|
|
12
|
+
};
|
|
13
|
+
var defaultProps: {
|
|
14
|
+
format: import("../typings/index").BaseFormatPrice;
|
|
15
|
+
};
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
4
18
|
export default PaymentMethodAmount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"./utils/BaseOrderPrice";import components from"../config/components";const propTypes=components.PaymentMethodAmount.propTypes,defaultProps=components.PaymentMethodAmount.defaultProps,displayName=components.PaymentMethodAmount.displayName
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"./utils/BaseOrderPrice";import components from"../config/components";const propTypes=components.PaymentMethodAmount.propTypes,defaultProps=components.PaymentMethodAmount.defaultProps,displayName=components.PaymentMethodAmount.displayName;export function PaymentMethodAmount(props){return _jsx(BaseOrderPrice,Object.assign({base:"amount",type:"payment_method"},props))}PaymentMethodAmount.propTypes=propTypes,PaymentMethodAmount.defaultProps=defaultProps,PaymentMethodAmount.displayName=displayName;export default PaymentMethodAmount;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare type PaymentMethodNameChildrenProps = Omit<
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
declare type PaymentMethodNameChildrenProps = Omit<Props, 'children'> & {
|
|
3
3
|
labelName: string;
|
|
4
4
|
};
|
|
5
|
-
declare type
|
|
5
|
+
declare type Props = {
|
|
6
6
|
children?: (props: PaymentMethodNameChildrenProps) => ReactNode;
|
|
7
7
|
} & JSX.IntrinsicElements['label'];
|
|
8
|
-
declare
|
|
8
|
+
export declare function PaymentMethodName(props: Props): JSX.Element;
|
|
9
|
+
export declare namespace PaymentMethodName {
|
|
10
|
+
var propTypes: {
|
|
11
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
12
|
+
};
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
9
15
|
export default PaymentMethodName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodName.propTypes,displayName=components.PaymentMethodName.displayName
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodName.propTypes,displayName=components.PaymentMethodName.displayName;export function PaymentMethodName(props){const{payment}=useContext(PaymentMethodChildrenContext),labelName=payment?.name,htmlFor=payment?.payment_source_type,parentProps=Object.assign({htmlFor,labelName},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("label",Object.assign({htmlFor},props,{children:labelName}))}PaymentMethodName.propTypes=propTypes,PaymentMethodName.displayName=displayName;export default PaymentMethodName;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { BaseAmountComponent } from '../typings/index';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
type?: 'amount';
|
|
5
5
|
labelFree?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare
|
|
8
|
-
declare
|
|
6
|
+
} & BaseAmountComponent;
|
|
7
|
+
export declare function PaymentMethodPrice(props: Props): JSX.Element;
|
|
8
|
+
export declare namespace PaymentMethodPrice {
|
|
9
|
+
var propTypes: {
|
|
10
|
+
type: import("prop-types").Requireable<"amount">;
|
|
11
|
+
id: import("prop-types").Requireable<string>;
|
|
12
|
+
className: import("prop-types").Requireable<string>;
|
|
13
|
+
style: import("prop-types").Requireable<object>;
|
|
14
|
+
name: import("prop-types").Requireable<string>;
|
|
15
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
16
|
+
format: import("prop-types").Requireable<import("../typings/index").BaseFormatPrice>;
|
|
17
|
+
};
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
|
9
20
|
export default PaymentMethodPrice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../utils/getAmount";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodPrice.propTypes,displayName=components.PaymentMethodPrice.displayName
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../utils/getAmount";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodPrice.propTypes,displayName=components.PaymentMethodPrice.displayName;export function PaymentMethodPrice(props){const{format="formatted",type="amount",labelFree="Free"}=props,p=__rest(props,["format","type","labelFree"]),{payment}=useContext(PaymentMethodChildrenContext),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(payment){const p2=getAmount({base:"price",type,format,obj:payment});setPrice(p2);const c=getAmount({base:"price",type,format:"cents",obj:payment});setPriceCents(c)}return()=>{setPrice(""),setPriceCents(0)}},[payment]);const parentProps=Object.assign({labelFree,price,priceCents},p);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("span",Object.assign({},p,{children:priceCents===0?labelFree:price}))}PaymentMethodPrice.propTypes=propTypes,PaymentMethodPrice.displayName=displayName;export default PaymentMethodPrice;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode, ChangeEvent } from 'react';
|
|
2
2
|
import { PaymentMethod } from '@commercelayer/sdk';
|
|
3
|
-
declare type ShippingMethodRadioButtonChildrenProps = Omit<
|
|
3
|
+
declare type ShippingMethodRadioButtonChildrenProps = Omit<Props, 'children'> & {
|
|
4
4
|
checked: boolean;
|
|
5
|
+
handleOnChange: (event: ChangeEvent<HTMLInputElement>) => Promise<void>;
|
|
5
6
|
};
|
|
6
|
-
declare type
|
|
7
|
+
declare type Props = {
|
|
7
8
|
children?: (props: ShippingMethodRadioButtonChildrenProps) => ReactNode;
|
|
8
9
|
onChange?: (payment?: PaymentMethod | Record<string, any>) => void;
|
|
9
10
|
} & JSX.IntrinsicElements['input'];
|
|
10
|
-
declare
|
|
11
|
+
export declare function PaymentMethodRadioButton(props: Props): JSX.Element;
|
|
12
|
+
export declare namespace PaymentMethodRadioButton {
|
|
13
|
+
var propTypes: {
|
|
14
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
15
|
+
};
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
11
18
|
export default PaymentMethodRadioButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentMethodRadioButton.propTypes,displayName=components.PaymentMethodRadioButton.displayName
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentMethodRadioButton.propTypes,displayName=components.PaymentMethodRadioButton.displayName;export function PaymentMethodRadioButton(props){const{onChange}=props,p=__rest(props,["onChange"]),{payment,paymentSelected,setPaymentSelected,clickableContainer}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{setPaymentMethod,setLoading}=useContext(PaymentMethodContext),orderId=order?.id||"",paymentResource=payment?.payment_source_type,paymentMethodId=payment?.id,name=`payment-${orderId}`,checked=paymentSelected===payment?.id,handleOnChange=async e=>{e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer&&await setPaymentMethod({paymentResource,paymentMethodId}),onChange&&onChange(payment),setLoading({loading:!1})},id=payment?.payment_source_type,parentProps=Object.assign({handleOnChange,checked,id,name},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("input",Object.assign({title:name,type:"radio",id,onChange:handleOnChange,checked},p))}PaymentMethodRadioButton.propTypes=propTypes,PaymentMethodRadioButton.displayName=displayName;export default PaymentMethodRadioButton;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { PaymentMethodConfig } from '../reducers/PaymentMethodReducer';
|
|
3
|
-
declare type
|
|
3
|
+
declare type Props = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
config?: PaymentMethodConfig;
|
|
6
6
|
};
|
|
7
|
-
declare
|
|
7
|
+
export declare function PaymentMethodsContainer(props: Props): JSX.Element;
|
|
8
|
+
export declare namespace PaymentMethodsContainer {
|
|
9
|
+
var propTypes: {
|
|
10
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
11
|
+
};
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
8
14
|
export default PaymentMethodsContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig}from"../reducers/PaymentMethodReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";import{setPaymentRef}from"../reducers/PaymentMethodReducer";const propTypes=components.PaymentMethodsContainer.propTypes,displayName=components.PaymentMethodsContainer.displayName
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig}from"../reducers/PaymentMethodReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";import{setPaymentRef}from"../reducers/PaymentMethodReducer";const propTypes=components.PaymentMethodsContainer.propTypes,displayName=components.PaymentMethodsContainer.displayName;export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useContext(OrderContext),credentials=useContext(CommerceLayerContext);async function getPayMethods(){order&&await getPaymentMethods({order,dispatch})}useEffect(()=>{include?.includes("available_payment_methods")?includeLoaded?.available_payment_methods||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0,"line_items.line_item_options.sku_option":!0,"line_items.item":!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method","line_items.line_item_options.sku_option","line_items.item"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&(state.paymentMethods||getPayMethods()),order?.payment_source&&dispatch({type:"setPaymentSource",payload:{paymentSource:order?.payment_source}}),order?.payment_source===null&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},[order,credentials,include,includeLoaded]);const contextValue=useMemo(()=>Object.assign(Object.assign({},state),{setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod(Object.assign(Object.assign({},args),{config:credentials,updateOrder,order,dispatch,setOrderErrors})),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource(Object.assign(Object.assign(Object.assign({},state),args),{config:credentials,dispatch,getOrder,updateOrder,order})),updatePaymentSource:async args=>await defaultPaymentMethodContext.updatePaymentSource(Object.assign(Object.assign({},args),{config:credentials,dispatch})),destroyPaymentSource:async args=>await defaultPaymentMethodContext.destroyPaymentSource(Object.assign(Object.assign({},args),{dispatch,config:credentials,updateOrder,orderId:order?.id}))}),[state]);return _jsx(PaymentMethodContext.Provider,Object.assign({value:contextValue},{children}))}PaymentMethodsContainer.propTypes=propTypes,PaymentMethodsContainer.displayName=displayName;export default PaymentMethodsContainer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { LoaderType } from '../typings/index';
|
|
3
3
|
import { CustomerCardsTemplateChildren } from './utils/PaymentCardsTemplate';
|
|
4
4
|
export declare type CustomerCardsProps = {
|
|
@@ -15,5 +15,12 @@ export declare type PaymentSourceProps = {
|
|
|
15
15
|
templateCustomerSaveToWallet?: (props: CustomerSaveToWalletProps) => ReactNode;
|
|
16
16
|
loader?: LoaderType;
|
|
17
17
|
} & JSX.IntrinsicElements['div'];
|
|
18
|
-
declare
|
|
18
|
+
export declare function PaymentSource(props: PaymentSourceProps): JSX.Element;
|
|
19
|
+
export declare namespace PaymentSource {
|
|
20
|
+
var propTypes: {
|
|
21
|
+
children: import("prop-types").Requireable<ReactNode | (() => ReactNode)>;
|
|
22
|
+
readonly: import("prop-types").Requireable<boolean>;
|
|
23
|
+
};
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
19
26
|
export default PaymentSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import CustomerContext from"../context/CustomerContext";import PaymentGateway from"./PaymentGateway";import getCardDetails from"../utils/getCardDetails";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentSource.propTypes,displayName=components.PaymentSource.displayName;export function PaymentSource(props){const{readonly}=props,{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!1),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const handleEditClick=async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},gatewayProps=Object.assign(Object.assign({},props),{show,showCard,handleEditClick,readonly});return _jsx(PaymentGateway,Object.assign({},gatewayProps))}PaymentSource.propTypes=propTypes,PaymentSource.displayName=displayName;export default PaymentSource;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconBrand } from '../context/PaymentSourceContext';
|
|
3
3
|
import { FunctionChildren } from '../typings/index';
|
|
4
4
|
declare type CustomComponent = FunctionChildren<Omit<Props & {
|
|
5
|
-
brand:
|
|
5
|
+
brand: IconBrand;
|
|
6
6
|
defaultSrc: string;
|
|
7
7
|
url: string;
|
|
8
8
|
}, 'children'>>;
|
|
@@ -11,5 +11,15 @@ declare type Props = {
|
|
|
11
11
|
width?: number;
|
|
12
12
|
height?: number;
|
|
13
13
|
} & JSX.IntrinsicElements['img'];
|
|
14
|
-
declare
|
|
14
|
+
export declare function PaymentSourceBrandIcon({ src, width, children, ...p }: Props): JSX.Element;
|
|
15
|
+
export declare namespace PaymentSourceBrandIcon {
|
|
16
|
+
var propTypes: {
|
|
17
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
18
|
+
width: import("prop-types").Requireable<number>;
|
|
19
|
+
height: import("prop-types").Requireable<number>;
|
|
20
|
+
src: import("prop-types").Requireable<string>;
|
|
21
|
+
className: import("prop-types").Requireable<string>;
|
|
22
|
+
};
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
15
25
|
export default PaymentSourceBrandIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandIcon.propTypes,displayName=components.PaymentSourceBrandIcon.displayName
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandIcon.propTypes,displayName=components.PaymentSourceBrandIcon.displayName;export function PaymentSourceBrandIcon(_a){var{src,width=32,children}=_a,p=__rest(_a,["src","width","children"]);const{brand}=useContext(PaymentSourceContext),ref=useRef(null),defaultSrc="//data.commercelayer.app/assets/images/icons/credit-cards/color/credit-card.svg",url=src||`//data.commercelayer.app/assets/images/icons/credit-cards/color/${brand}.svg`,handleError=()=>{ref.current&&(ref.current.src=defaultSrc)},parentProps=Object.assign({brand,defaultSrc,url,width},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("img",Object.assign({ref,src:url,onError:handleError,width},p))}PaymentSourceBrandIcon.propTypes=propTypes,PaymentSourceBrandIcon.displayName=displayName;export default PaymentSourceBrandIcon;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconBrand } from '../context/PaymentSourceContext';
|
|
3
3
|
import { FunctionChildren } from '../typings/index';
|
|
4
4
|
declare type CustomComponent = FunctionChildren<Omit<Props & {
|
|
5
|
-
brand:
|
|
5
|
+
brand: IconBrand;
|
|
6
6
|
}, 'children'>>;
|
|
7
7
|
declare type Props = {
|
|
8
8
|
children?: CustomComponent;
|
|
9
9
|
label?: string;
|
|
10
10
|
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare
|
|
11
|
+
export declare function PaymentSourceBrandName({ children, label, ...props }: Props): JSX.Element;
|
|
12
|
+
export declare namespace PaymentSourceBrandName {
|
|
13
|
+
var propTypes: {
|
|
14
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
15
|
+
label: import("prop-types").Requireable<string>;
|
|
16
|
+
};
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
12
19
|
export default PaymentSourceBrandName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{capitalize}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandName.propTypes,displayName=components.PaymentSourceBrandName.displayName
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{capitalize}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandName.propTypes,displayName=components.PaymentSourceBrandName.displayName;export function PaymentSourceBrandName(_a){var{children,label}=_a,props=__rest(_a,["children","label"]);const{brand}=useContext(PaymentSourceContext),brandName=brand&&capitalize(brand.replace("-"," ")),parentProps=Object.assign({brand:brandName,label},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},props,{children:label||capitalize(brandName)}))}PaymentSourceBrandName.propTypes=propTypes,PaymentSourceBrandName.displayName=displayName;export default PaymentSourceBrandName;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { FunctionChildren } from '../typings/index';
|
|
3
3
|
export declare type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
|
|
4
4
|
declare type CustomComponent = FunctionChildren<Omit<Props & {
|
|
@@ -8,5 +8,11 @@ declare type Props = {
|
|
|
8
8
|
children?: CustomComponent;
|
|
9
9
|
type: PaymentSourceDetailType;
|
|
10
10
|
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare
|
|
11
|
+
export declare function PaymentSourceDetail({ type, children, ...p }: Props): JSX.Element;
|
|
12
|
+
export declare namespace PaymentSourceDetail {
|
|
13
|
+
var propTypes: {
|
|
14
|
+
type: import("prop-types").Validator<PaymentSourceDetailType>;
|
|
15
|
+
};
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
12
18
|
export default PaymentSourceDetail;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import PaymentSourceContext from"../context/PaymentSourceContext";import{has}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";const propTypes=components.PaymentSourceDetail.propTypes,displayName=components.PaymentSourceDetail.displayName
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import PaymentSourceContext from"../context/PaymentSourceContext";import{has}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";const propTypes=components.PaymentSourceDetail.propTypes,displayName=components.PaymentSourceDetail.displayName;export function PaymentSourceDetail(_a){var{type,children}=_a,p=__rest(_a,["type","children"]);const card=useContext(PaymentSourceContext),text=has(card,type)?card[type]:type==="last4"?"****":"**",parentProps=Object.assign({type,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},p,{children:text}))}PaymentSourceDetail.propTypes=propTypes,PaymentSourceDetail.displayName=displayName;export default PaymentSourceDetail;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { FunctionChildren } from '../typings/index';
|
|
3
3
|
declare type CustomComponent = FunctionChildren<Omit<Props, 'children'>>;
|
|
4
4
|
declare type Props = {
|
|
5
5
|
children?: CustomComponent;
|
|
6
6
|
label?: string | ReactNode;
|
|
7
7
|
} & Omit<JSX.IntrinsicElements['button'], 'onClick'>;
|
|
8
|
-
declare
|
|
8
|
+
export declare function PaymentSourceEditButton({ children, label, ...props }: Props): JSX.Element | null;
|
|
9
|
+
export declare namespace PaymentSourceEditButton {
|
|
10
|
+
var propTypes: {
|
|
11
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
12
|
+
label: import("prop-types").Requireable<string | import("prop-types").ReactElementLike>;
|
|
13
|
+
};
|
|
14
|
+
var displayName: string;
|
|
15
|
+
}
|
|
9
16
|
export default PaymentSourceEditButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const displayName=components.PaymentSourceEditButton.displayName,propTypes=components.PaymentSourceEditButton.propTypes
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const displayName=components.PaymentSourceEditButton.displayName,propTypes=components.PaymentSourceEditButton.propTypes;export function PaymentSourceEditButton(_a){var{children,label="Edit"}=_a,props=__rest(_a,["children","label"]);const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps=Object.assign({showCard,label,handleEditClick},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):readonly?null:_jsx("button",Object.assign({},props,{onClick:handleEditClick},{children:label}))}PaymentSourceEditButton.propTypes=propTypes,PaymentSourceEditButton.displayName=displayName;export default PaymentSourceEditButton;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
export declare type PaypalConfig = {
|
|
3
3
|
return_url: string;
|
|
4
4
|
cancel_url: string;
|
|
@@ -8,5 +8,5 @@ export declare type PaypalConfig = {
|
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
declare type Props = Omit<PaypalConfig, 'return_url' | 'cancel_url'> & JSX.IntrinsicElements['div'];
|
|
11
|
-
declare
|
|
11
|
+
export declare function PaypalPayment({ infoMessage, ...p }: Props): JSX.Element;
|
|
12
12
|
export default PaypalPayment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../context/PaymentMethodContext";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef}from"react";const defaultMessage="by placing the order, you will be redirected to the PayPal website to sign in and authorize the payment"
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../context/PaymentMethodContext";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef}from"react";const defaultMessage="by placing the order, you will be redirected to the PayPal website to sign in and authorize the payment";export function PaypalPayment(_a){var{infoMessage}=_a,p=__rest(_a,["infoMessage"]);const ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&¤tPaymentMethodType&&paymentSource?.approval_url&&(ref.current.onsubmit=()=>handleClick(),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType]);const handleClick=async()=>{if(paymentSource&¤tPaymentMethodType)try{return await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{metadata:{card:{id:paymentSource.id,brand:"paypal",last4:""}}}}),!0}catch{return!1}return!1};return _jsx("form",Object.assign({ref},{children:_jsx("div",Object.assign({},p,{children:_jsx("span",Object.assign({className:infoMessage?.className},{children:isFunction(infoMessage?.text)?infoMessage?.text():infoMessage?.text||defaultMessage}))}))}))}export default PaypalPayment;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { Price as PriceType } from '@commercelayer/sdk';
|
|
3
3
|
import { FunctionChildren, LoaderType } from '../typings/index';
|
|
4
4
|
declare type PriceChildrenProps = FunctionChildren<{
|
|
@@ -6,11 +6,23 @@ declare type PriceChildrenProps = FunctionChildren<{
|
|
|
6
6
|
loader: LoaderType;
|
|
7
7
|
prices: PriceType[];
|
|
8
8
|
} & Omit<PriceProps, 'children'>>;
|
|
9
|
-
export
|
|
9
|
+
export declare type PriceProps = Partial<JSX.IntrinsicElements['span']> & {
|
|
10
10
|
children?: PriceChildrenProps;
|
|
11
11
|
compareClassName?: string;
|
|
12
12
|
showCompare?: boolean;
|
|
13
13
|
skuCode?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function Price(props: PriceProps): JSX.Element;
|
|
16
|
+
export declare namespace Price {
|
|
17
|
+
var propTypes: {
|
|
18
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
19
|
+
compareClassName: import("prop-types").Requireable<string>;
|
|
20
|
+
skuCode: import("prop-types").Requireable<string>;
|
|
21
|
+
showCompare: import("prop-types").Requireable<boolean>;
|
|
22
|
+
};
|
|
23
|
+
var defaultProps: {
|
|
24
|
+
skuCode: string;
|
|
25
|
+
};
|
|
26
|
+
var displayName: string;
|
|
14
27
|
}
|
|
15
|
-
declare const Price: FunctionComponent<PriceProps>;
|
|
16
28
|
export default Price;
|
package/lib/components/Price.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useState,useEffect,useContext}from"react";import{isEmpty,has,indexOf}from"lodash";import Parent from"./utils/Parent";import PricesContext from"../context/PricesContext";import{getPricesComponent}from"../utils/getPrices";import components from"../config/components";const propTypes=components.Price.propTypes,defaultProps=components.Price.defaultProps,displayName=components.Price.displayName
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useState,useEffect,useContext}from"react";import{isEmpty,has,indexOf}from"lodash";import Parent from"./utils/Parent";import PricesContext from"../context/PricesContext";import{getPricesComponent}from"../utils/getPrices";import components from"../config/components";import SkuChildrenContext from"../context/SkuChildrenContext";const propTypes=components.Price.propTypes,defaultProps=components.Price.defaultProps,displayName=components.Price.displayName;export function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=useContext(PricesContext),{sku}=useContext(SkuChildrenContext),[skuPrices,setSkuPrices]=useState([]),sCode=pricesSkuCode||skuCode||sku?.code;useEffect(()=>(!isEmpty(prices)&&has(prices,`${sCode}`)?setSkuPrices(prices[sCode]):sCode&&indexOf(skuCodes,sCode)===-1&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes(skuCodes)),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps=Object.assign({loading,loader,prices:skuPrices},props),pricesComponent=isEmpty(prices)||isEmpty(skuPrices)?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx(Fragment,{children:loading||isEmpty(pricesComponent)?loader:pricesComponent})}Price.propTypes=propTypes,Price.defaultProps=defaultProps,Price.displayName=displayName;export default Price;
|