@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import React from"react";import KlarnaPayment from"../KlarnaPayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function KlarnaGateway(props){var _a;const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent}=props,p=__rest(props,["readonly","showCard","handleEditClick","children","templateCustomerCards","loading","loaderComponent"]),{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="klarna_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientToken=paymentSource?.client_token,klarnaConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>{var _a2;return((_a2=customerPayment.payment_source)===null||_a2===void 0?void 0:_a2.type)===paymentResource}):[];if(readonly||showCard){const card=(_a=paymentSource?.options)===null||_a===void 0?void 0:_a.card,value=Object.assign(Object.assign({},card),{showCard,handleEditClick,readonly});return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,Object.assign({value},{children}))}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",Object.assign({className:p.className},{children:_jsx(PaymentCardsTemplate,Object.assign({},{paymentResource,customerPayments},{children:templateCustomerCards}))})),_jsx(KlarnaPayment,Object.assign({clientToken,locale},klarnaConfig))]}):clientToken&&!loading?_jsx(KlarnaPayment,Object.assign({clientToken,locale},klarnaConfig)):loaderComponent}export default KlarnaGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../PaymentGateway';
|
|
3
|
-
declare type PaypalGateway = GatewayBaseType
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
declare type PaypalGateway = Partial<GatewayBaseType>;
|
|
4
|
+
export declare function PaypalGateway(props: PaypalGateway): JSX.Element | null;
|
|
5
|
+
export default PaypalGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaypalPayment from"../PaypalPayment";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import{useContext}from"react";export
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaypalPayment from"../PaypalPayment";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import{useContext}from"react";export function PaypalGateway(props){const{readonly,showCard,handleEditClick,children}=props,p=__rest(props,["readonly","showCard","handleEditClick","children"]),{order}=useContext(OrderContext),{payment}=useContext(PaymentMethodChildrenContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="paypal_payments";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:order?.payment_source||paymentSource},paymentType:paymentResource}),value=Object.assign(Object.assign({},card),{showCard,handleEditClick,readonly});return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,Object.assign({value},{children}))}const paypalConfig=config&&getPaymentConfig(paymentResource,config);return delete p.show,delete p.templateCustomerCards,delete p.templateCustomerSaveToWallet,delete p.loading,delete p.loaderComponent,delete p.onClickCustomerCards,_jsx(PaypalPayment,Object.assign({},p,{infoMessage:paypalConfig?.infoMessage}))}export default PaypalGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../PaymentGateway';
|
|
3
3
|
declare type StripeGateway = GatewayBaseType;
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export declare function StripeGateway(props: StripeGateway): JSX.Element | null;
|
|
5
|
+
export default StripeGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function StripeGateway(props){var _a;const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet}=props,p=__rest(props,["readonly","showCard","handleEditClick","children","templateCustomerCards","show","loading","loaderComponent","templateCustomerSaveToWallet"]),{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="stripe_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publishableKey=paymentSource?.publishable_key,paymentSourceId=((_a=order?.payment_source)===null||_a===void 0?void 0:_a.id)||paymentSource?.id,stripeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>{var _a2;return((_a2=customerPayment.payment_source)===null||_a2===void 0?void 0:_a2.type)===paymentResource}):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value=Object.assign(Object.assign({},card),{showCard,handleEditClick,readonly});return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,Object.assign({value},{children}))}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",Object.assign({className:p.className},{children:_jsx(PaymentCardsTemplate,Object.assign({},{paymentResource,customerPayments},{children:templateCustomerCards}))})),_jsx(StripePayment,Object.assign({show,templateCustomerSaveToWallet,publishableKey,locale},stripeConfig))]}):publishableKey&&!loading&&paymentSourceId?_jsx(StripePayment,Object.assign({show,publishableKey,locale},stripeConfig)):loaderComponent}export default StripeGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../PaymentGateway';
|
|
3
3
|
declare type WireTransferGateway = GatewayBaseType;
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export declare function WireTransferGateway(props: WireTransferGateway): JSX.Element | null;
|
|
5
|
+
export default WireTransferGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import WireTransferPayment from"../WireTransferPayment";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import{useContext}from"react";export
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import WireTransferPayment from"../WireTransferPayment";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import{useContext}from"react";export function WireTransferGateway(props){var _a,_b;const{readonly,showCard,handleEditClick,children}=props,p=__rest(props,["readonly","showCard","handleEditClick","children"]),{payment}=useContext(PaymentMethodChildrenContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="wire_transfers";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=((_a=paymentSource?.options)===null||_a===void 0?void 0:_a.card)||((_b=paymentSource?.metadata)===null||_b===void 0?void 0:_b.card),value=Object.assign(Object.assign({},card),{showCard,handleEditClick,readonly});return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,Object.assign({value},{children}))}const wireTransferConfig=config&&paymentResource?getPaymentConfig(paymentResource,config):{};return _jsx(WireTransferPayment,Object.assign({},p,wireTransferConfig))}export default WireTransferGateway;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import { FunctionChildren } from '../../typings/index';
|
|
3
|
+
import { AddToCartReturn } from '../../reducers/OrderReducer';
|
|
4
|
+
import { VariantOption } from '../VariantSelector';
|
|
5
|
+
declare type ChildrenProps = {
|
|
6
|
+
handleClick: () => AddToCartReturn;
|
|
7
|
+
} & Omit<Props, 'children'>;
|
|
8
|
+
declare type AddToCartButtonChildrenProps = FunctionChildren<ChildrenProps>;
|
|
9
|
+
export declare type AddToCartButtonType = ChildrenProps;
|
|
10
|
+
declare type BuyNowMode = {
|
|
11
|
+
buyNowMode: true;
|
|
12
|
+
checkoutUrl?: string;
|
|
13
|
+
} | {
|
|
14
|
+
buyNowMode?: false;
|
|
15
|
+
checkoutUrl?: never;
|
|
16
|
+
};
|
|
17
|
+
declare type THostedCart = {
|
|
18
|
+
redirectToHostedCart: true;
|
|
19
|
+
hostedCartUrl?: string;
|
|
20
|
+
} | {
|
|
21
|
+
redirectToHostedCart?: false;
|
|
22
|
+
hostedCartUrl?: never;
|
|
23
|
+
};
|
|
24
|
+
declare type Props = {
|
|
25
|
+
children?: AddToCartButtonChildrenProps;
|
|
26
|
+
label?: string | ReactNode;
|
|
27
|
+
skuCode?: string;
|
|
28
|
+
bundleCode?: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
skuListId?: string;
|
|
31
|
+
lineItem?: VariantOption['lineItem'];
|
|
32
|
+
} & BuyNowMode & THostedCart & PropsWithoutRef<JSX.IntrinsicElements['button']>;
|
|
33
|
+
export declare function AddToCartButton(props: Props): JSX.Element;
|
|
34
|
+
export default AddToCartButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderContext from"../../context/OrderContext";import isEmpty from"lodash/isEmpty";import has from"lodash/has";import ItemContext from"../../context/ItemContext";import getCurrentItemKey from"../../utils/getCurrentItemKey";import SkuListsContext from"../../context/SkuListsContext";import ExternalFunctionContext from"../../context/ExternalFunctionContext";import isFunction from"lodash/isFunction";import SkuChildrenContext from"../../context/SkuChildrenContext";import getCartLink from"../../utils/getCartLink";import CommerceLayerContext from"../../context/CommerceLayerContext";export function AddToCartButton(props){var _a,_b,_c;const{label="Add to cart",children,skuCode,bundleCode,disabled,skuListId,lineItem,buyNowMode=!1,checkoutUrl,redirectToHostedCart,hostedCartUrl}=props,p=__rest(props,["label","children","skuCode","bundleCode","disabled","skuListId","lineItem","buyNowMode","checkoutUrl","redirectToHostedCart","hostedCartUrl"]),{accessToken,endpoint}=useContext(CommerceLayerContext),{addToCart,orderId,getOrder,setOrderErrors}=useContext(OrderContext),{url,callExternalFunction}=useContext(ExternalFunctionContext),{item,items,quantity,option,prices,lineItems,lineItem:lineItemContext,skuCode:itemSkuCode}=useContext(ItemContext),{skuLists}=useContext(SkuListsContext),{sku}=useContext(SkuChildrenContext),[slug]=endpoint.split(".commercelayer"),sCode=!isEmpty(items)&&skuCode?(_a=items[skuCode])===null||_a===void 0?void 0:_a.code:sku?.code||skuCode||getCurrentItemKey(item)||itemSkuCode,availabilityQuantity=(_c=(_b=item[sCode])===null||_b===void 0?void 0:_b.inventory)===null||_c===void 0?void 0:_c.quantity,handleClick=async()=>{var _a2,_b2;const qty=quantity[sCode],opt=option[sCode],customLineItem=isEmpty(lineItem||lineItemContext)?lineItems[sCode]:lineItem||lineItemContext;if(!isEmpty(skuLists)&&skuListId&&url){const slQty=quantity[skuListId]||1;if(has(skuLists,skuListId)){const lineItems2=skuLists&&skuLists[skuListId].map(skuCode2=>({skuCode:skuCode2,quantity:slQty,_update_quantity:1}));return callExternalFunction({url,data:{resourceType:"orders",inputs:[{id:orderId,lineItems:lineItems2}]}}).then(async res=>(getOrder&&orderId&&await getOrder(orderId),res)).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))}}if(!url&&addToCart){const res=await addToCart({bundleCode,skuCode:sCode,skuId:(_a2=item[sCode])===null||_a2===void 0?void 0:_a2.id,quantity:qty,option:opt,lineItem:customLineItem,buyNowMode,checkoutUrl});if(redirectToHostedCart){const orderId2=res.orderId;hostedCartUrl?location.href=`https://${hostedCartUrl}/${orderId2}?accessToken=${accessToken}`:orderId2&&slug&&(location.href=getCartLink({orderId:orderId2,slug,accessToken}))}return res}else if(url)return callExternalFunction({url,data:{bundleCode,skuCode:sCode,skuId:(_b2=item[sCode])===null||_b2===void 0?void 0:_b2.id,quantity:qty,option:opt,lineItem:customLineItem,buyNowMode,checkoutUrl}}).then(async res=>(getOrder&&orderId&&await getOrder(orderId),res)).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))},autoDisabled=!isEmpty(skuLists)||skuListId?!1:disabled||!prices[sCode]||!sCode||availabilityQuantity===0,parentProps=Object.assign({handleClick,disabled:disabled||autoDisabled,label},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("button",Object.assign({},p,{disabled:autoDisabled,onClick:handleClick},{children:isFunction(label)?label():label}))}export default AddToCartButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
|
+
export declare function AdjustmentAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
|
+
export declare namespace AdjustmentAmount {
|
|
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
|
+
}
|
|
18
|
+
export default AdjustmentAmount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.AdjustmentAmount.propTypes,defaultProps=components.AdjustmentAmount.defaultProps,displayName=components.AdjustmentAmount.displayName;export function AdjustmentAmount(props){return _jsx(BaseOrderPrice,Object.assign({base:"amount",type:"adjustment"},props))}AdjustmentAmount.propTypes=propTypes,AdjustmentAmount.defaultProps=defaultProps,AdjustmentAmount.displayName=displayName;export default AdjustmentAmount;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import { FunctionChildren } from '../../typings/index';
|
|
3
|
+
declare type TChildren = FunctionChildren<Omit<Props, 'children'> & {
|
|
4
|
+
href: string;
|
|
5
|
+
handleClick?: (e: MouseEvent<HTMLAnchorElement>) => Promise<void>;
|
|
6
|
+
}>;
|
|
7
|
+
declare type Props = {
|
|
8
|
+
children?: TChildren;
|
|
9
|
+
label?: string | ReactNode;
|
|
10
|
+
} & JSX.IntrinsicElements['a'];
|
|
11
|
+
export declare function CartLink(props: Props): JSX.Element | null;
|
|
12
|
+
export default CartLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import getCartLink from"../../utils/getCartLink";export function CartLink(props){const{label,children}=props,p=__rest(props,["label","children"]),{order,createOrder}=useContext(OrderContext),{accessToken,endpoint}=useContext(CommerceLayerContext),[slug]=endpoint.split(".commercelayer"),href=slug&&order?.id?getCartLink({slug,orderId:order?.id,accessToken}):"",handleClick=async event=>{if(event.preventDefault(),order?.id)location.href=href;else{const orderId=await createOrder();slug&&(location.href=getCartLink({slug,orderId,accessToken}))}},parentProps=Object.assign({handleClick,label,href},p);return accessToken?children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("a",Object.assign({href},p,{onClick:handleClick},{children:typeof label=="function"?label():label})):null}export default CartLink;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
|
+
export declare function GiftCardAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
|
+
export declare namespace GiftCardAmount {
|
|
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 displayName: string;
|
|
14
|
+
}
|
|
15
|
+
export default GiftCardAmount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.GiftCardAmount.propTypes,displayName=components.GiftCardAmount.displayName;export function GiftCardAmount(props){return _jsx(BaseOrderPrice,Object.assign({base:"amount",type:"gift_card"},props))}GiftCardAmount.propTypes=propTypes,GiftCardAmount.displayName=displayName;export default GiftCardAmount;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseMetadataObject } from '../../typings/index';
|
|
3
|
+
import type { OrderCreate, Order } from '@commercelayer/sdk';
|
|
4
|
+
declare type Props = {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
metadata?: BaseMetadataObject;
|
|
7
|
+
attributes?: OrderCreate;
|
|
8
|
+
orderId?: string;
|
|
9
|
+
fetchOrder?: (order: Order) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function OrderContainer(props: Props): JSX.Element;
|
|
12
|
+
export declare namespace OrderContainer {
|
|
13
|
+
var propTypes: {
|
|
14
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
15
|
+
orderId: import("prop-types").Requireable<string>;
|
|
16
|
+
metadata: import("prop-types").Requireable<{
|
|
17
|
+
[x: string]: string | null | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
attributes: import("prop-types").Requireable<object>;
|
|
20
|
+
};
|
|
21
|
+
var defaultProps: {
|
|
22
|
+
metadata: {};
|
|
23
|
+
};
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
export default OrderContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext,useMemo,useState}from"react";import orderReducer,{createOrder,getApiOrder,setOrderErrors,setOrder,orderInitialState,updateOrder}from"../../reducers/OrderReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext,{defaultOrderContext}from"../../context/OrderContext";import components from"../../config/components";import OrderStorageContext from"../../context/OrderStorageContext";import compareObjAttribute from"../../utils/compareObjAttribute";const propTypes=components.OrderContainer.propTypes,defaultProps=components.OrderContainer.defaultProps,displayName=components.OrderContainer.displayName;export function OrderContainer(props){const{orderId,children,metadata,attributes,fetchOrder}=props,[state,dispatch]=useReducer(orderReducer,orderInitialState),[lock,setLock]=useState(!1),[lockOrder,setLockOrder]=useState(!0),config=useContext(CommerceLayerContext),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=useContext(OrderStorageContext);useEffect(()=>{state.withoutIncludes||dispatch({type:"setLoading",payload:{loading:!0}})},[state.withoutIncludes]),useEffect(()=>{if(attributes&&state?.order&&!lock){const updateAttributes=compareObjAttribute({attributes,object:state.order});Object.keys(updateAttributes).length>0&&(updateOrder({id:state.order.id,attributes:updateAttributes,dispatch,config,include:state.include,state}),setLock(!0))}return()=>{if(attributes&&state?.order){const updateAttributes=compareObjAttribute({attributes,object:state.order});state.order&&Object.keys(updateAttributes).length===0&&setLock(!1)}}},[attributes,state?.order,lock]),useEffect(()=>{var _a,_b;const localOrder=persistKey?getLocalOrder(persistKey):orderId,startRequest=Object.keys(state?.includeLoaded||{}).filter(key=>{var _a2;return((_a2=state?.includeLoaded)===null||_a2===void 0?void 0:_a2[key])===!0}),getOrder=async()=>{localOrder&&await getApiOrder({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:!!(persistKey&&clearWhenPlaced),deleteLocalOrder,state})};return config.accessToken&&!state.loading?localOrder&&!state.order&&((_a=state.include)===null||_a===void 0?void 0:_a.length)===startRequest.length&&!state.withoutIncludes&&!lockOrder?getOrder():state?.order?fetchOrder&&fetchOrder(state.order):state.withoutIncludes&&!(!((_b=state.include)===null||_b===void 0)&&_b.length)&&startRequest.length===0&&getOrder():[config.accessToken,!state.order,state.loading,state.withoutIncludes].every(Boolean)?dispatch({type:"setLoading",payload:{loading:!1}}):[config.accessToken,!state.order,state.loading,!state.withoutIncludes].every(Boolean)&&dispatch({type:"setLoading",payload:{loading:!1}}),()=>{var _a2,_b2;!state.order&&state.loading&&!state.withoutIncludes&&(((_a2=state.include)===null||_a2===void 0?void 0:_a2.length)===0&&startRequest.length>0?dispatch({type:"setLoading",payload:{loading:!1}}):state.include&&((_b2=state.include)===null||_b2===void 0?void 0:_b2.length)>0&&(dispatch({type:"setIncludesResource",payload:{include:[]}}),setLockOrder(!1)))}},[config.accessToken,state.includeLoaded,state.include,orderId,state.order,state.loading,state.withoutIncludes,lockOrder]);const orderValue=useMemo(()=>Object.assign(Object.assign({},state),{setOrder:order=>setOrder(order,dispatch),getOrder:id=>getApiOrder({id,dispatch,config,state}),setOrderErrors:errors=>setOrderErrors({dispatch,errors}),createOrder:()=>createOrder({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes,setLocalOrder}),addToCart:values=>defaultOrderContext.addToCart(Object.assign(Object.assign({},values),{persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder})),saveAddressToCustomerAddressBook:args=>defaultOrderContext.saveAddressToCustomerAddressBook(Object.assign(Object.assign({},args),{dispatch})),setGiftCardOrCouponCode:({code,codeType})=>defaultOrderContext.setGiftCardOrCouponCode({code,codeType,dispatch,order:state.order,config,include:state.include,state}),removeGiftCardOrCouponCode:({codeType})=>defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include,state}),addResourceToInclude:args=>defaultOrderContext.addResourceToInclude(Object.assign(Object.assign({},args),{dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded})),updateOrder:async args=>await defaultOrderContext.updateOrder(Object.assign(Object.assign({},args),{dispatch,config,include:state.include,state}))}),[state,config.accessToken]);return _jsx(OrderContext.Provider,Object.assign({value:orderValue},{children}))}OrderContainer.propTypes=propTypes,OrderContainer.defaultProps=defaultProps,OrderContainer.displayName=displayName;export default OrderContainer;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { InitialOrderListContext } from '../../context/OrderListChildrenContext';
|
|
3
|
+
import { Column } from 'react-table';
|
|
4
|
+
declare type Props = {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Columns to show
|
|
8
|
+
*/
|
|
9
|
+
columns: (Column & {
|
|
10
|
+
className?: string;
|
|
11
|
+
})[];
|
|
12
|
+
/**
|
|
13
|
+
* Custom loader component
|
|
14
|
+
*/
|
|
15
|
+
loadingElement?: ReactElement;
|
|
16
|
+
/**
|
|
17
|
+
* Function to assign as custom row renderer
|
|
18
|
+
*/
|
|
19
|
+
actionsComponent?: InitialOrderListContext['actionsComponent'];
|
|
20
|
+
/**
|
|
21
|
+
* Class name to assign to the custom row container
|
|
22
|
+
*/
|
|
23
|
+
actionsContainerClassName?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Show actions column
|
|
26
|
+
*/
|
|
27
|
+
showActions?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Class name to assign to the table header
|
|
30
|
+
*/
|
|
31
|
+
theadClassName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Class name to assign to the table row
|
|
34
|
+
*/
|
|
35
|
+
rowTrClassName?: string;
|
|
36
|
+
} & JSX.IntrinsicElements['table'] & ({
|
|
37
|
+
/**
|
|
38
|
+
* Activate infinity scroll
|
|
39
|
+
*/
|
|
40
|
+
infiniteScroll: true;
|
|
41
|
+
/**
|
|
42
|
+
* The window options to use for the infinite scroll
|
|
43
|
+
*/
|
|
44
|
+
windowOptions?: {
|
|
45
|
+
height?: number;
|
|
46
|
+
itemSize?: number;
|
|
47
|
+
width?: number;
|
|
48
|
+
column?: number;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
infiniteScroll?: false;
|
|
52
|
+
windowOptions?: never;
|
|
53
|
+
});
|
|
54
|
+
export declare function OrderList({ children, columns, loadingElement, showActions, actionsComponent, actionsContainerClassName, infiniteScroll, windowOptions, theadClassName, rowTrClassName, ...p }: Props): JSX.Element;
|
|
55
|
+
export declare namespace OrderList {
|
|
56
|
+
var propTypes: {
|
|
57
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
58
|
+
};
|
|
59
|
+
var displayName: string;
|
|
60
|
+
}
|
|
61
|
+
export default OrderList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{createElement as _createElement}from"react";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useMemo,useState,useEffect,useCallback}from"react";import components from"../../config/components";import CustomerContext from"../../context/CustomerContext";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import{useTable,useSortBy,useBlockLayout}from"react-table";import{FixedSizeList}from"react-window";import scrollbarWidth from"../../utils/scrollbarWidth";import{sortDescIcon,sortAscIcon}from"../../utils/icons";const propTypes=components.OrderList.propTypes,displayName=components.OrderList.displayName;export function OrderList(_a){var{children,columns,loadingElement,showActions=!1,actionsComponent,actionsContainerClassName,infiniteScroll,windowOptions,theadClassName,rowTrClassName}=_a,p=__rest(_a,["children","columns","loadingElement","showActions","actionsComponent","actionsContainerClassName","infiniteScroll","windowOptions","theadClassName","rowTrClassName"]);const[loading,setLoading]=useState(!0),{orders}=useContext(CustomerContext),data=useMemo(()=>orders,[orders]),cols=useMemo(()=>columns,[columns]),tablePlugins=[useSortBy];infiniteScroll&&tablePlugins.push(useBlockLayout);const defaultColumn=useMemo(()=>({width:windowOptions?.column||150}),[windowOptions?.column]),table=useTable(Object.assign({data,columns:cols},infiniteScroll&&{defaultColumn}),...tablePlugins),TableHtmlElement=infiniteScroll?"div":"table",TheadHtmlElement=infiniteScroll?"div":"thead",TbodyHtmlElement=infiniteScroll?"div":"tbody",ThHtmlElement=infiniteScroll?"div":"th",TrHtmlElement=infiniteScroll?"div":"tr";useEffect(()=>(orders&&orders.length>0&&setLoading(!1),()=>{setLoading(!0)}),[orders]);const scrollBarSize=infiniteScroll?useMemo(()=>scrollbarWidth(),[]):0,LoadingComponent=loadingElement||_jsx("div",{children:"Loading..."}),headerComponent=table.headerGroups.map((headerGroup,i)=>{const columns2=headerGroup.headers.map((column,k)=>_createElement(ThHtmlElement,Object.assign({className:column?.className},column.getHeaderProps(column?.getSortByToggleProps&&column?.getSortByToggleProps()),{key:k}),_jsxs("span",Object.assign({className:column?.titleClassName},{children:[column.render("Header"),column.isSorted?column.isSortedDesc?sortDescIcon:sortAscIcon:""]}))));return _createElement(TrHtmlElement,Object.assign({},headerGroup.getHeaderGroupProps(),{key:i}),columns2)}),components2=infiniteScroll?useCallback(({index,style})=>{const row=table.rows[index];row&&table.prepareRow(row);const childProps={order:orders?.[index],row,showActions,actionsComponent,actionsContainerClassName,infiniteScroll};return _jsx(TrHtmlElement,Object.assign({},row&&row.getRowProps({style}),{className:rowTrClassName},{children:_jsx(OrderListChildrenContext.Provider,Object.assign({value:childProps},{children}))}))},[table.prepareRow,table.rows]):table.rows.map((row,i)=>{table.prepareRow(row);const childProps={order:orders?.[i],row,showActions,actionsComponent,actionsContainerClassName,infiniteScroll};return _createElement(TrHtmlElement,Object.assign({},row.getRowProps(),{className:rowTrClassName,key:i}),_jsx(OrderListChildrenContext.Provider,Object.assign({value:childProps},{children})))});return loading?LoadingComponent:_jsxs(TableHtmlElement,Object.assign({},p,table.getTableProps(),{children:[_jsx(TheadHtmlElement,Object.assign({className:theadClassName},{children:headerComponent})),_jsx(TbodyHtmlElement,Object.assign({},table.getTableBodyProps(),{children:infiniteScroll?_jsx(FixedSizeList,Object.assign({height:windowOptions?.height||400,itemCount:table.rows.length,itemSize:windowOptions?.itemSize||100,width:windowOptions?.width||table.totalColumnsWidth+scrollBarSize},{children:components2})):components2}))]}))}OrderList.propTypes=propTypes,OrderList.displayName=displayName;export default OrderList;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Cell, Row } from 'react-table';
|
|
3
|
+
import type { Order } from '@commercelayer/sdk';
|
|
4
|
+
declare type ChildrenProps = Omit<Props, 'children'> & {
|
|
5
|
+
/**
|
|
6
|
+
* The order resource
|
|
7
|
+
*/
|
|
8
|
+
order: Order;
|
|
9
|
+
/**
|
|
10
|
+
* The current row
|
|
11
|
+
*/
|
|
12
|
+
row: Row;
|
|
13
|
+
/**
|
|
14
|
+
* The current cell
|
|
15
|
+
*/
|
|
16
|
+
cell: Cell[];
|
|
17
|
+
/**
|
|
18
|
+
* Infinite scroll enabled
|
|
19
|
+
*/
|
|
20
|
+
infiniteScroll: boolean;
|
|
21
|
+
};
|
|
22
|
+
declare type Props = {
|
|
23
|
+
children?: (props: ChildrenProps) => ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* The order field to show
|
|
26
|
+
*/
|
|
27
|
+
field: keyof Order;
|
|
28
|
+
} & JSX.IntrinsicElements['td'];
|
|
29
|
+
export declare function OrderListRow({ field, children, ...p }: Props): JSX.Element;
|
|
30
|
+
export default OrderListRow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{createElement as _createElement}from"react";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import isDate from"../../utils/isDate";import last from"lodash/last";export function OrderListRow(_a){var _b,{field,children}=_a,p=__rest(_a,["field","children"]);const{order,row,showActions,actionsComponent,actionsContainerClassName,infiniteScroll}=useContext(OrderListChildrenContext),cell=row?.cells.filter(cell2=>cell2.column.id===field),isLastRow=((_b=last(row?.cells))===null||_b===void 0?void 0:_b.column.id)===field,As=infiniteScroll?"div":"td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&_jsx(As,Object.assign({},p,{className:actionsContainerClassName},{children:_jsx(Parent,Object.assign({},parentProps,{children:actionsComponent}))}))||null,parentProps=Object.assign(Object.assign({},p),{field,order,row,cell,infiniteScroll});return children?_jsxs(_Fragment,{children:[_jsx(Parent,Object.assign({},parentProps,{children})),_jsx(ActionRow,{})]}):_jsxs(_Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.value,value=isDate(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():cell2.render("Cell");return _createElement(As,Object.assign({},p,cell2.getCellProps(),{key:k}),value)}),_jsx(ActionRow,{})]})}export default OrderListRow;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseFieldProps } from '../utils/BaseField';
|
|
3
|
+
declare type Props = Omit<BaseFieldProps, 'attribute'>;
|
|
4
|
+
export declare function OrderNumber(props: Props): JSX.Element;
|
|
5
|
+
export declare namespace OrderNumber {
|
|
6
|
+
var propTypes: {
|
|
7
|
+
className: import("prop-types").Requireable<string>;
|
|
8
|
+
};
|
|
9
|
+
var displayName: string;
|
|
10
|
+
}
|
|
11
|
+
export default OrderNumber;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import components from"../../config/components";import BaseField from"../utils/BaseField";const propTypes=components.OrderNumber.propTypes,displayName=components.OrderNumber.displayName;export function OrderNumber(props){return _jsx(BaseField,Object.assign({attribute:"number"},props))}OrderNumber.propTypes=propTypes,OrderNumber.displayName=displayName;export default OrderNumber;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
persistKey: string;
|
|
5
|
+
clearWhenPlaced?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function OrderStorage(props: Props): JSX.Element;
|
|
8
|
+
export declare namespace OrderStorage {
|
|
9
|
+
var propTypes: {
|
|
10
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
11
|
+
clearWhenPlaced: import("prop-types").Requireable<boolean>;
|
|
12
|
+
persistKey: import("prop-types").Validator<string>;
|
|
13
|
+
};
|
|
14
|
+
var displayName: string;
|
|
15
|
+
}
|
|
16
|
+
export default OrderStorage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderStorageContext from"../../context/OrderStorageContext";import components from"../../config/components";import{getLocalOrder,setLocalOrder,deleteLocalOrder}from"../../utils/localStorage";const propTypes=components.OrderStorage.propTypes,displayName=components.OrderStorage.displayName;export function OrderStorage(props){const{children,clearWhenPlaced=!0}=props,p=__rest(props,["children","clearWhenPlaced"]);return _jsx(OrderStorageContext.Provider,Object.assign({value:Object.assign(Object.assign({},p),{setLocalOrder,getLocalOrder,deleteLocalOrder,clearWhenPlaced})},{children}))}OrderStorage.propTypes=propTypes,OrderStorage.displayName=displayName;export default OrderStorage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FunctionChildren } from '../../typings/index';
|
|
3
|
+
declare type ChildrenProps = FunctionChildren<Omit<Props, 'children'> & {
|
|
4
|
+
handleClick: () => Promise<void>;
|
|
5
|
+
}>;
|
|
6
|
+
declare type Props = {
|
|
7
|
+
children?: ChildrenProps;
|
|
8
|
+
label?: string | ReactNode;
|
|
9
|
+
onClick?: (response: {
|
|
10
|
+
placed: boolean;
|
|
11
|
+
}) => void;
|
|
12
|
+
} & JSX.IntrinsicElements['button'];
|
|
13
|
+
export declare function PlaceOrderButton(props: Props): JSX.Element;
|
|
14
|
+
export declare namespace PlaceOrderButton {
|
|
15
|
+
var propTypes: {
|
|
16
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
17
|
+
label: import("prop-types").Requireable<string | import("prop-types").ReactElementLike>;
|
|
18
|
+
};
|
|
19
|
+
var defaultProps: {
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
24
|
+
export default PlaceOrderButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import Parent from"../utils/Parent";import components from"../../config/components";import PlaceOrderContext from"../../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import getCardDetails from"../../utils/getCardDetails";const propTypes=components.PlaceOrderButton.propTypes,defaultProps=components.PlaceOrderButton.defaultProps,displayName=components.PlaceOrderButton.displayName;export function PlaceOrderButton(props){var _a;const{children,label="Place order",disabled,onClick}=props,p=__rest(props,["children","label","disabled","onClick"]),{isPermitted,setPlaceOrder,options,paymentType}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{var _a2;if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree&&isPermitted||((_a2=currentPaymentMethodRef?.current)===null||_a2===void 0?void 0:_a2.onsubmit)||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,(_a=currentPaymentMethodRef?.current)===null||_a===void 0?void 0:_a.onsubmit,loading,currentPaymentMethodType,order,paymentSource]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.paypalPayerId,paymentType]),useEffect(()=>{var _a2,_b;paymentType==="adyen_payments"&&((_a2=options?.adyen)===null||_a2===void 0?void 0:_a2.MD)&&((_b=options?.adyen)===null||_b===void 0?void 0:_b.PaRes)&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.adyen,paymentType]),useEffect(()=>{var _a2;paymentType==="checkout_com_payments"&&((_a2=options?.checkoutCom)===null||_a2===void 0?void 0:_a2.session_id)&&order?.status&&["draft","pending"].includes(order?.status)&&handleClick()},[options?.checkoutCom,paymentType]);const handleClick=async()=>{var _a2,_b,_c,_d;let isValid=!0;setForceDisable(!0);const card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:paymentSource}});((_a2=currentPaymentMethodRef?.current)===null||_a2===void 0?void 0:_a2.onsubmit)&&[!options?.paypalPayerId,!(!((_b=options?.adyen)===null||_b===void 0)&&_b.MD),!(!((_c=options?.checkoutCom)===null||_c===void 0)&&_c.session_id)].every(Boolean)?isValid=await((_d=currentPaymentMethodRef.current)===null||_d===void 0?void 0:_d.onsubmit(paymentSource)):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(paymentSource||isFree)&&await setPlaceOrder({paymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps=Object.assign(Object.assign({},p),{label,disabled:disabledButton,handleClick});return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("button",Object.assign({type:"button",disabled:disabledButton||forceDisable,onClick:handleClick},p,{children:isFunction(label)?label():label}))}PlaceOrderButton.propTypes=propTypes,PlaceOrderButton.defaultProps=defaultProps,PlaceOrderButton.displayName=displayName;export default PlaceOrderButton;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PlaceOrderOptions } from '../../reducers/PlaceOrderReducer';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
options?: PlaceOrderOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare function PlaceOrderContainer(props: Props): JSX.Element;
|
|
8
|
+
export declare namespace PlaceOrderContainer {
|
|
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
|
+
}
|
|
14
|
+
export default PlaceOrderContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PlaceOrderContext from"../../context/PlaceOrderContext";import{useContext,useEffect,useReducer}from"react";import placeOrderReducer,{placeOrderInitialState,placeOrderPermitted}from"../../reducers/PlaceOrderReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import components from"../../config/components";import{setPlaceOrder}from"../../reducers/PlaceOrderReducer";const propTypes=components.PlaceOrderContainer.propTypes,displayName=components.PlaceOrderContainer.displayName;export function PlaceOrderContainer(props){const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrder,setOrderErrors,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.shipment_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location"]}),include?.includes("billing_address")?includeLoaded?.billing_address||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address",resourcesIncluded:include}),order&&placeOrderPermitted({config,dispatch,order,options:Object.assign({},options)})},[order,include,includeLoaded]);const contextValue=Object.assign(Object.assign({},state),{setPlaceOrder:({paymentSource})=>setPlaceOrder({config,order,state,setOrderErrors,paymentSource,include,setOrder}),placeOrderPermitted:()=>placeOrderPermitted({config,dispatch,order,options:Object.assign({},options)})});return _jsx(PlaceOrderContext.Provider,Object.assign({value:contextValue},{children}))}PlaceOrderContainer.propTypes=propTypes,PlaceOrderContainer.displayName=displayName;export default PlaceOrderContainer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseInputProps } from '../utils/BaseInput';
|
|
3
|
+
export declare function PrivacyAndTermsCheckbox(props: Partial<BaseInputProps>): JSX.Element;
|
|
4
|
+
export declare namespace PrivacyAndTermsCheckbox {
|
|
5
|
+
var propTypes: {
|
|
6
|
+
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
7
|
+
};
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export default PrivacyAndTermsCheckbox;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import components from"../../config/components";import OrderContext from"../../context/OrderContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import{useContext,useEffect,useState}from"react";import BaseInput from"../utils/BaseInput";const propTypes=components.PrivacyAndTermsCheckbox.propTypes,displayName=components.PrivacyAndTermsCheckbox.displayName;export function PrivacyAndTermsCheckbox(props){const{order}=useContext(OrderContext),{placeOrderPermitted}=useContext(PlaceOrderContext),[forceDisabled,setForceDisabled]=useState(!0),[checked,setChecked]=useState(!1),fieldName="privacy-terms",handleChange=e=>{var _a;const v=(_a=e.target)===null||_a===void 0?void 0:_a.checked;setChecked(v),localStorage.setItem(fieldName,`${v}`),placeOrderPermitted&&placeOrderPermitted()};return useEffect(()=>(order?.privacy_url&&order?.terms_url&&setForceDisabled(!1),checked||localStorage.setItem(fieldName,`${checked}`),()=>{setForceDisabled(!0),localStorage.removeItem(fieldName)}),[order?.privacy_url,order?.terms_url]),_jsx(BaseInput,Object.assign({type:"checkbox",name:fieldName,disabled:forceDisabled,onChange:handleChange,checked},props))}PrivacyAndTermsCheckbox.propTypes=propTypes,PrivacyAndTermsCheckbox.displayName=displayName;export default PrivacyAndTermsCheckbox;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
|
+
export declare function SubTotalAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
|
+
export declare namespace SubTotalAmount {
|
|
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
|
+
}
|
|
18
|
+
export default SubTotalAmount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.SubTotalAmount.propTypes,defaultProps=components.SubTotalAmount.defaultProps,displayName=components.SubTotalAmount.displayName;export function SubTotalAmount(props){return _jsx(BaseOrderPrice,Object.assign({base:"amount",type:"subtotal"},props))}SubTotalAmount.propTypes=propTypes,SubTotalAmount.defaultProps=defaultProps,SubTotalAmount.displayName=displayName;export default SubTotalAmount;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
|
+
export declare function TaxesAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
|
+
export declare namespace TaxesAmount {
|
|
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
|
+
}
|
|
18
|
+
export default TaxesAmount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.TaxesAmount.propTypes,defaultProps=components.TaxesAmount.defaultProps,displayName=components.TaxesAmount.displayName;export function TaxesAmount(props){return _jsx(BaseOrderPrice,Object.assign({base:"amount",type:"total_tax"},props))}TaxesAmount.propTypes=propTypes,TaxesAmount.defaultProps=defaultProps,TaxesAmount.displayName=displayName;export default TaxesAmount;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseAmountComponent } from '../../typings/index';
|
|
3
|
+
export declare function TotalAmount(props: BaseAmountComponent): JSX.Element;
|
|
4
|
+
export declare namespace TotalAmount {
|
|
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
|
+
}
|
|
18
|
+
export default TotalAmount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";import components from"../../config/components";const propTypes=components.TotalAmount.propTypes,defaultProps=components.TotalAmount.defaultProps,displayName=components.TotalAmount.displayName;export function TotalAmount(props){return _jsx(BaseOrderPrice,Object.assign({base:"total_amount",type:"with_taxes"},props))}TotalAmount.propTypes=propTypes,TotalAmount.defaultProps=defaultProps,TotalAmount.displayName=displayName;export default TotalAmount;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ConditionalElement } from '../../typings/index';
|
|
3
|
+
import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
|
|
4
|
+
declare type SkuFieldChildrenProps = TGenericChildrenProps<TResources['Sku']>;
|
|
5
|
+
declare type TCondition = ConditionalElement<Exclude<TResources['Sku'], 'resource'>>;
|
|
6
|
+
declare type Props = {
|
|
7
|
+
children?: (props: SkuFieldChildrenProps) => JSX.Element;
|
|
8
|
+
} & TCondition;
|
|
9
|
+
/**
|
|
10
|
+
* @param props {@link Props}
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function SkuField<P extends Props>(props: P): JSX.Element;
|
|
14
|
+
export default SkuField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function SkuField(props){const{attribute,tagElement,children}=props,p=__rest(props,["attribute","tagElement","children"]);return _jsx(GenericFieldComponent,Object.assign({resource:"skus",attribute,tagElement,context:SkuChildrenContext},p,{children}))}export default SkuField;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function SkuList(props: Props): JSX.Element;
|
|
7
|
+
export declare namespace SkuList {
|
|
8
|
+
var propTypes: {
|
|
9
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
10
|
+
id: import("prop-types").Validator<string>;
|
|
11
|
+
};
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export default SkuList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,Fragment}from"react";import SkuListsContext from"../../context/SkuListsContext";import components from"../../config/components";const propTypes=components.SkuList.propTypes,displayName=components.SkuList.displayName;export function SkuList(props){const{id,children}=props,{listIds}=useContext(SkuListsContext);return useEffect(()=>{listIds&&!listIds.includes(id)&&listIds.push(id)},[]),_jsx(Fragment,{children})}SkuList.propTypes=propTypes,SkuList.displayName=displayName;export default SkuList;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
};
|
|
5
|
+
export declare function SkuListsContainer(props: Props): JSX.Element;
|
|
6
|
+
export declare namespace SkuListsContainer {
|
|
7
|
+
var propTypes: {
|
|
8
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
9
|
+
};
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
export default SkuListsContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useReducer,useContext,useEffect}from"react";import SkuListsContext from"../../context/SkuListsContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import skuListsReducer,{skuListsInitialState,getSkuList}from"../../reducers/SkuListsReducer";import components from"../../config/components";const propTypes=components.SkuListsContainer.propTypes,displayName=components.SkuListsContainer.displayName;export function SkuListsContainer(props){const{children}=props,[state,dispatch]=useReducer(skuListsReducer,skuListsInitialState),config=useContext(CommerceLayerContext);return useEffect(()=>{state.listIds&&state.listIds.length>0&&config.accessToken&&getSkuList({listIds:state.listIds,dispatch,config,state})},[config.accessToken]),_jsx(SkuListsContext.Provider,Object.assign({value:state},{children}))}SkuListsContainer.propTypes=propTypes,SkuListsContainer.displayName=displayName;export default SkuListsContainer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function SkuOption(props: Props): JSX.Element;
|
|
7
|
+
export declare namespace SkuOption {
|
|
8
|
+
var propTypes: {
|
|
9
|
+
children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
|
|
10
|
+
id: import("prop-types").Validator<string>;
|
|
11
|
+
};
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export default SkuOption;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext}from"react";import SkuOptionChildrenContext from"../../context/SkuOptionChildrenContext";import SkuOptionsContext from"../../context/SkuOptionsContext";import components from"../../config/components";const propTypes=components.SkuOption.propTypes,displayName=components.SkuOption.displayName;export function SkuOption(props){const{id}=props,{skuOptions,skuCode}=useContext(SkuOptionsContext),items=skuOptions&&skuOptions.filter(l=>l.id===id).map((skuOption,k)=>_jsx(SkuOptionChildrenContext.Provider,Object.assign({value:{skuOption,skuCode}},{children:props.children}),k));return _jsx(Fragment,{children:items})}SkuOption.propTypes=propTypes,SkuOption.displayName=displayName;export default SkuOption;
|