@commercelayer/react-components 3.0.0-beta.9 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist → lib}/components/AddToCartButton.d.ts +20 -17
- package/lib/components/AddToCartButton.js +1 -0
- package/{dist → lib}/components/Address.d.ts +13 -12
- package/lib/components/Address.js +1 -0
- package/{dist → lib}/components/AddressCountrySelector.d.ts +9 -9
- package/lib/components/AddressCountrySelector.js +1 -0
- package/lib/components/AddressField.d.ts +15 -0
- package/lib/components/AddressField.js +1 -0
- package/{dist → lib}/components/AddressInput.d.ts +7 -7
- package/lib/components/AddressInput.js +1 -0
- package/{dist → lib}/components/AddressStateSelector.d.ts +11 -11
- package/lib/components/AddressStateSelector.js +1 -0
- package/{dist → lib}/components/AddressesContainer.d.ts +8 -7
- package/lib/components/AddressesContainer.js +1 -0
- package/lib/components/AdjustmentAmount.d.ts +4 -0
- package/lib/components/AdjustmentAmount.js +1 -0
- package/lib/components/AdyenPayment.d.ts +25 -0
- package/lib/components/AdyenPayment.js +1 -0
- package/{dist → lib}/components/AvailabilityContainer.d.ts +7 -7
- package/lib/components/AvailabilityContainer.js +1 -0
- package/{dist → lib}/components/AvailabilityTemplate.d.ts +15 -16
- package/lib/components/AvailabilityTemplate.js +1 -0
- package/{dist → lib}/components/BillingAddressContainer.d.ts +6 -6
- package/lib/components/BillingAddressContainer.js +1 -0
- package/{dist → lib}/components/BillingAddressForm.d.ts +8 -8
- package/lib/components/BillingAddressForm.js +1 -0
- package/{dist → lib}/components/BraintreePayment.d.ts +30 -30
- package/lib/components/BraintreePayment.js +1 -0
- package/{dist → lib}/components/CheckoutLink.d.ts +11 -11
- package/lib/components/CheckoutLink.js +1 -0
- package/{dist → lib}/components/CommerceLayer.d.ts +8 -9
- package/lib/components/CommerceLayer.js +1 -0
- package/{dist → lib}/components/CustomerContainer.d.ts +7 -7
- package/lib/components/CustomerContainer.js +1 -0
- package/{dist → lib}/components/CustomerInput.d.ts +11 -11
- package/lib/components/CustomerInput.js +1 -0
- package/{dist → lib}/components/DeliveryLeadTime.d.ts +10 -10
- package/lib/components/DeliveryLeadTime.js +1 -0
- package/{dist → lib}/components/DiscountAmount.d.ts +4 -4
- package/lib/components/DiscountAmount.js +1 -0
- package/{dist → lib}/components/Errors.d.ts +5 -5
- package/lib/components/Errors.js +1 -0
- package/{dist → lib}/components/ExternalFunction.d.ts +7 -7
- package/lib/components/ExternalFunction.js +1 -0
- package/{dist → lib}/components/GiftCard.d.ts +8 -8
- package/lib/components/GiftCard.js +1 -0
- package/{dist → lib}/components/GiftCardAmount.d.ts +4 -4
- package/lib/components/GiftCardAmount.js +1 -0
- package/{dist → lib}/components/GiftCardContainer.d.ts +6 -6
- package/lib/components/GiftCardContainer.js +1 -0
- package/{dist → lib}/components/GiftCardCurrencySelector.d.ts +7 -7
- package/lib/components/GiftCardCurrencySelector.js +1 -0
- package/{dist → lib}/components/GiftCardInput.d.ts +7 -7
- package/lib/components/GiftCardInput.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponCode.d.ts +13 -13
- package/lib/components/GiftCardOrCouponCode.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponForm.d.ts +10 -10
- package/lib/components/GiftCardOrCouponForm.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponInput.d.ts +8 -8
- package/lib/components/GiftCardOrCouponInput.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponRemoveButton.d.ts +16 -16
- package/lib/components/GiftCardOrCouponRemoveButton.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponSubmit.d.ts +9 -9
- package/lib/components/GiftCardOrCouponSubmit.js +1 -0
- package/{dist → lib}/components/GiftCardRecipient.d.ts +0 -0
- package/lib/components/GiftCardRecipient.js +1 -0
- package/{dist → lib}/components/GiftCardRecipientInput.d.ts +0 -0
- package/lib/components/GiftCardRecipientInput.js +1 -0
- package/{dist → lib}/components/ItemContainer.d.ts +11 -11
- package/lib/components/ItemContainer.js +1 -0
- package/{dist → lib}/components/LineItem.d.ts +8 -8
- package/lib/components/LineItem.js +1 -0
- package/{dist → lib}/components/LineItemAmount.d.ts +7 -7
- package/lib/components/LineItemAmount.js +1 -0
- package/lib/components/LineItemCode.d.ts +12 -0
- package/lib/components/LineItemCode.js +1 -0
- package/lib/components/LineItemImage.d.ts +16 -0
- package/lib/components/LineItemImage.js +1 -0
- package/lib/components/LineItemName.d.ts +11 -0
- package/lib/components/LineItemName.js +1 -0
- package/{dist → lib}/components/LineItemOption.d.ts +19 -19
- package/lib/components/LineItemOption.js +1 -0
- package/{dist → lib}/components/LineItemOptions.d.ts +14 -14
- package/lib/components/LineItemOptions.js +1 -0
- package/{dist → lib}/components/LineItemQuantity.d.ts +14 -14
- package/lib/components/LineItemQuantity.js +1 -0
- package/{dist → lib}/components/LineItemRemoveLink.d.ts +12 -12
- package/lib/components/LineItemRemoveLink.js +1 -0
- package/{dist → lib}/components/LineItemsContainer.d.ts +8 -8
- package/lib/components/LineItemsContainer.js +1 -0
- package/{dist → lib}/components/LineItemsCount.d.ts +12 -10
- package/lib/components/LineItemsCount.js +1 -0
- package/lib/components/LineItemsEmpty.d.ts +12 -0
- package/lib/components/LineItemsEmpty.js +1 -0
- package/{dist → lib}/components/MetadataInput.d.ts +5 -5
- package/lib/components/MetadataInput.js +1 -0
- package/{dist → lib}/components/OrderContainer.d.ts +11 -10
- package/lib/components/OrderContainer.js +1 -0
- package/{dist → lib}/components/OrderNumber.d.ts +5 -5
- package/lib/components/OrderNumber.js +1 -0
- package/{dist → lib}/components/OrderStorage.d.ts +8 -8
- package/lib/components/OrderStorage.js +1 -0
- package/lib/components/PaymentGateway.d.ts +16 -0
- package/lib/components/PaymentGateway.js +1 -0
- package/{dist → lib}/components/PaymentMethod.d.ts +16 -16
- package/lib/components/PaymentMethod.js +1 -0
- package/{dist → lib}/components/PaymentMethodAmount.d.ts +4 -4
- package/lib/components/PaymentMethodAmount.js +1 -0
- package/{dist → lib}/components/PaymentMethodName.d.ts +9 -9
- package/lib/components/PaymentMethodName.js +1 -0
- package/{dist → lib}/components/PaymentMethodPrice.d.ts +9 -9
- package/lib/components/PaymentMethodPrice.js +1 -0
- package/{dist → lib}/components/PaymentMethodRadioButton.d.ts +11 -11
- package/lib/components/PaymentMethodRadioButton.js +1 -0
- package/{dist → lib}/components/PaymentMethodsContainer.d.ts +8 -8
- package/lib/components/PaymentMethodsContainer.js +1 -0
- package/{dist → lib}/components/PaymentSource.d.ts +19 -18
- package/lib/components/PaymentSource.js +1 -0
- package/{dist → lib}/components/PaymentSourceBrandIcon.d.ts +15 -15
- package/lib/components/PaymentSourceBrandIcon.js +1 -0
- package/{dist → lib}/components/PaymentSourceBrandName.d.ts +12 -12
- package/lib/components/PaymentSourceBrandName.js +1 -0
- package/{dist → lib}/components/PaymentSourceDetail.d.ts +12 -12
- package/lib/components/PaymentSourceDetail.js +1 -0
- package/{dist → lib}/components/PaymentSourceEditButton.d.ts +9 -9
- package/lib/components/PaymentSourceEditButton.js +1 -0
- package/{dist → lib}/components/PaypalPayment.d.ts +12 -12
- package/lib/components/PaypalPayment.js +1 -0
- package/{dist → lib}/components/PlaceOrderButton.d.ts +12 -12
- package/lib/components/PlaceOrderButton.js +1 -0
- package/{dist → lib}/components/PlaceOrderContainer.d.ts +8 -8
- package/lib/components/PlaceOrderContainer.js +1 -0
- package/{dist → lib}/components/Price.d.ts +16 -14
- package/lib/components/Price.js +1 -0
- package/{dist → lib}/components/PricesContainer.d.ts +11 -11
- package/lib/components/PricesContainer.js +1 -0
- package/{dist → lib}/components/PrivacyAndTermsCheckbox.d.ts +4 -4
- package/lib/components/PrivacyAndTermsCheckbox.js +1 -0
- package/{dist → lib}/components/QuantitySelector.d.ts +17 -17
- package/lib/components/QuantitySelector.js +1 -0
- package/{dist → lib}/components/SaveAddressesButton.d.ts +10 -11
- package/lib/components/SaveAddressesButton.js +1 -0
- package/{dist → lib}/components/SaveCustomerButton.d.ts +13 -13
- package/lib/components/SaveCustomerButton.js +1 -0
- package/{dist → lib}/components/Shipment.d.ts +8 -8
- package/lib/components/Shipment.js +1 -0
- package/{dist → lib}/components/ShipmentField.d.ts +12 -12
- package/lib/components/ShipmentField.js +1 -0
- package/{dist → lib}/components/ShipmentsContainer.d.ts +6 -6
- package/lib/components/ShipmentsContainer.js +1 -0
- package/{dist → lib}/components/ShippingAddressContainer.d.ts +6 -6
- package/lib/components/ShippingAddressContainer.js +1 -0
- package/{dist → lib}/components/ShippingAddressForm.d.ts +8 -8
- package/lib/components/ShippingAddressForm.js +1 -0
- package/{dist → lib}/components/ShippingAmount.d.ts +4 -4
- package/lib/components/ShippingAmount.js +1 -0
- package/{dist → lib}/components/ShippingMethod.d.ts +8 -8
- package/lib/components/ShippingMethod.js +1 -0
- package/{dist → lib}/components/ShippingMethodName.d.ts +11 -7
- package/lib/components/ShippingMethodName.js +1 -0
- package/{dist → lib}/components/ShippingMethodPrice.d.ts +13 -13
- package/lib/components/ShippingMethodPrice.js +1 -0
- package/lib/components/ShippingMethodRadioButton.d.ts +13 -0
- package/lib/components/ShippingMethodRadioButton.js +1 -0
- package/{dist → lib}/components/SkuList.d.ts +7 -7
- package/lib/components/SkuList.js +1 -0
- package/{dist → lib}/components/SkuListsContainer.d.ts +6 -6
- package/lib/components/SkuListsContainer.js +1 -0
- package/{dist → lib}/components/SkuOption.d.ts +7 -7
- package/lib/components/SkuOption.js +1 -0
- package/{dist → lib}/components/SkuOptionInput.d.ts +5 -5
- package/lib/components/SkuOptionInput.js +1 -0
- package/{dist → lib}/components/SkuOptionsContainer.d.ts +7 -7
- package/lib/components/SkuOptionsContainer.js +1 -0
- package/{dist → lib}/components/StockTransfer.d.ts +6 -6
- package/lib/components/StockTransfer.js +1 -0
- package/{dist → lib}/components/StockTransferField.d.ts +9 -9
- package/lib/components/StockTransferField.js +1 -0
- package/{dist → lib}/components/StripePayment.d.ts +18 -18
- package/lib/components/StripePayment.js +1 -0
- package/{dist → lib}/components/SubTotalAmount.d.ts +4 -4
- package/lib/components/SubTotalAmount.js +1 -0
- package/{dist → lib}/components/SubmitButton.d.ts +9 -9
- package/lib/components/SubmitButton.js +1 -0
- package/{dist → lib}/components/TaxesAmount.d.ts +4 -4
- package/lib/components/TaxesAmount.js +1 -0
- package/{dist → lib}/components/TotalAmount.d.ts +4 -4
- package/lib/components/TotalAmount.js +1 -0
- package/{dist → lib}/components/VariantSelector.d.ts +29 -27
- package/lib/components/VariantSelector.js +1 -0
- package/{dist → lib}/components/VariantsContainer.d.ts +8 -8
- package/lib/components/VariantsContainer.js +1 -0
- package/{dist → lib}/components/WireTransferPayment.d.ts +10 -10
- package/lib/components/WireTransferPayment.js +1 -0
- package/lib/components/gateways/AdyenGateway.d.ts +5 -0
- package/lib/components/gateways/AdyenGateway.js +1 -0
- package/lib/components/gateways/BraintreeGateway.d.ts +5 -0
- package/lib/components/gateways/BraintreeGateway.js +1 -0
- package/lib/components/gateways/PaypalGateway.d.ts +5 -0
- package/lib/components/gateways/PaypalGateway.js +1 -0
- package/lib/components/gateways/StripeGateway.d.ts +5 -0
- package/lib/components/gateways/StripeGateway.js +1 -0
- package/lib/components/gateways/WireTransferGateway.d.ts +5 -0
- package/lib/components/gateways/WireTransferGateway.js +1 -0
- package/lib/components/utils/AddressCardsTemplate.d.ts +27 -0
- package/lib/components/utils/AddressCardsTemplate.js +1 -0
- package/{dist → lib}/components/utils/BaseField.d.ts +8 -8
- package/lib/components/utils/BaseField.js +1 -0
- package/lib/components/utils/BaseInput.d.ts +5 -0
- package/lib/components/utils/BaseInput.js +1 -0
- package/{dist → lib}/components/utils/BaseOrderPrice.d.ts +6 -6
- package/lib/components/utils/BaseOrderPrice.js +1 -0
- package/{dist → lib}/components/utils/BaseSelect.d.ts +5 -5
- package/lib/components/utils/BaseSelect.js +1 -0
- package/{dist → lib}/components/utils/Parent.d.ts +8 -8
- package/lib/components/utils/Parent.js +1 -0
- package/lib/components/utils/PaymentCardsTemplate.d.ts +23 -0
- package/lib/components/utils/PaymentCardsTemplate.js +1 -0
- package/{dist → lib}/components/utils/PriceTemplate.d.ts +8 -8
- package/lib/components/utils/PriceTemplate.js +1 -0
- package/{dist → lib}/components/utils/VariantTemplate.d.ts +36 -34
- package/lib/components/utils/VariantTemplate.js +1 -0
- package/{dist → lib}/components/utils/getAllErrors.d.ts +17 -17
- package/lib/components/utils/getAllErrors.js +1 -0
- package/{dist → lib}/config/components.d.ts +892 -887
- package/lib/config/components.js +1 -0
- package/lib/config/currency.d.ts +5 -0
- package/lib/config/currency.js +1 -0
- package/{dist → lib}/context/AddressChildrenContext.d.ts +7 -7
- package/lib/context/AddressChildrenContext.js +1 -0
- package/{dist → lib}/context/AddressContext.d.ts +17 -17
- package/lib/context/AddressContext.js +1 -0
- package/{dist → lib}/context/AvailabilityContext.d.ts +3 -3
- package/lib/context/AvailabilityContext.js +1 -0
- package/{dist → lib}/context/BillingAddressContext.d.ts +12 -12
- package/lib/context/BillingAddressContext.js +1 -0
- package/{dist → lib}/context/BillingAddressFormContext.d.ts +19 -18
- package/lib/context/BillingAddressFormContext.js +1 -0
- package/{dist → lib}/context/CommerceLayerContext.d.ts +7 -8
- package/lib/context/CommerceLayerContext.js +1 -0
- package/{dist → lib}/context/CouponAndGiftCardFormContext.d.ts +7 -7
- package/lib/context/CouponAndGiftCardFormContext.js +1 -0
- package/{dist → lib}/context/CustomerContext.d.ts +16 -18
- package/lib/context/CustomerContext.js +1 -0
- package/{dist → lib}/context/ExternalFunctionContext.d.ts +12 -12
- package/lib/context/ExternalFunctionContext.js +1 -0
- package/{dist → lib}/context/GiftCardContext.d.ts +11 -11
- package/lib/context/GiftCardContext.js +1 -0
- package/{dist → lib}/context/ItemContext.d.ts +13 -13
- package/lib/context/ItemContext.js +1 -0
- package/lib/context/LineItemChildrenContext.d.ts +9 -0
- package/lib/context/LineItemChildrenContext.js +1 -0
- package/{dist → lib}/context/LineItemContext.d.ts +8 -8
- package/lib/context/LineItemContext.js +1 -0
- package/{dist → lib}/context/LineItemOptionChildrenContext.d.ts +8 -8
- package/lib/context/LineItemOptionChildrenContext.js +1 -0
- package/lib/context/OrderContext.d.ts +26 -0
- package/lib/context/OrderContext.js +1 -0
- package/{dist → lib}/context/OrderStorageContext.d.ts +11 -11
- package/lib/context/OrderStorageContext.js +1 -0
- package/{dist → lib}/context/PaymentMethodChildrenContext.d.ts +10 -10
- package/lib/context/PaymentMethodChildrenContext.js +1 -0
- package/{dist → lib}/context/PaymentMethodContext.d.ts +23 -20
- package/lib/context/PaymentMethodContext.js +1 -0
- package/{dist → lib}/context/PaymentSourceContext.d.ts +14 -14
- package/lib/context/PaymentSourceContext.js +1 -0
- package/{dist → lib}/context/PlaceOrderContext.d.ts +16 -16
- package/lib/context/PlaceOrderContext.js +1 -0
- package/{dist → lib}/context/PricesContext.d.ts +7 -7
- package/lib/context/PricesContext.js +1 -0
- package/lib/context/ShipmentChildrenContext.d.ts +13 -0
- package/lib/context/ShipmentChildrenContext.js +1 -0
- package/{dist → lib}/context/ShipmentContext.d.ts +12 -12
- package/lib/context/ShipmentContext.js +1 -0
- package/{dist → lib}/context/ShippingAddressContext.d.ts +10 -10
- package/lib/context/ShippingAddressContext.js +1 -0
- package/{dist → lib}/context/ShippingAddressFormContext.d.ts +4 -4
- package/lib/context/ShippingAddressFormContext.js +1 -0
- package/lib/context/ShippingMethodChildrenContext.d.ts +10 -0
- package/lib/context/ShippingMethodChildrenContext.js +1 -0
- package/lib/context/SkuListsContext.d.ts +6 -0
- package/lib/context/SkuListsContext.js +1 -0
- package/{dist → lib}/context/SkuOptionChildrenContext.d.ts +8 -8
- package/lib/context/SkuOptionChildrenContext.js +1 -0
- package/{dist → lib}/context/SkuOptionsContext.d.ts +3 -3
- package/lib/context/SkuOptionsContext.js +1 -0
- package/{dist → lib}/context/StockTransferChildrenContext.d.ts +7 -7
- package/lib/context/StockTransferChildrenContext.js +1 -0
- package/{dist → lib}/context/VariantsContext.d.ts +3 -3
- package/lib/context/VariantsContext.js +1 -0
- package/lib/index.d.ts +99 -0
- package/lib/index.js +1 -0
- package/{dist → lib}/reducers/AddressReducer.d.ts +59 -61
- package/lib/reducers/AddressReducer.js +1 -0
- package/lib/reducers/AvailabilityReducer.d.ts +53 -0
- package/lib/reducers/AvailabilityReducer.js +1 -0
- package/{dist → lib}/reducers/BillingAddressReducer.d.ts +31 -32
- package/lib/reducers/BillingAddressReducer.js +1 -0
- package/{dist → lib}/reducers/CustomerReducer.d.ts +50 -67
- package/lib/reducers/CustomerReducer.js +1 -0
- package/{dist → lib}/reducers/GiftCardReducer.d.ts +76 -75
- package/lib/reducers/GiftCardReducer.js +1 -0
- package/{dist → lib}/reducers/ItemReducer.d.ts +69 -68
- package/lib/reducers/ItemReducer.js +1 -0
- package/{dist → lib}/reducers/LineItemReducer.d.ts +52 -52
- package/lib/reducers/LineItemReducer.js +1 -0
- package/lib/reducers/OrderReducer.d.ts +133 -0
- package/lib/reducers/OrderReducer.js +1 -0
- package/{dist → lib}/reducers/PaymentMethodReducer.d.ts +105 -95
- package/lib/reducers/PaymentMethodReducer.js +1 -0
- package/{dist → lib}/reducers/PlaceOrderReducer.d.ts +52 -50
- package/lib/reducers/PlaceOrderReducer.js +1 -0
- package/{dist → lib}/reducers/PriceReducer.d.ts +44 -45
- package/lib/reducers/PriceReducer.js +1 -0
- package/{dist → lib}/reducers/ShipmentReducer.d.ts +40 -37
- package/lib/reducers/ShipmentReducer.js +1 -0
- package/{dist → lib}/reducers/ShippingAddressReducer.d.ts +32 -31
- package/lib/reducers/ShippingAddressReducer.js +1 -0
- package/{dist → lib}/reducers/SkuListsReducer.d.ts +21 -22
- package/lib/reducers/SkuListsReducer.js +1 -0
- package/{dist → lib}/reducers/SkuOptionsReducer.d.ts +26 -26
- package/lib/reducers/SkuOptionsReducer.js +1 -0
- package/{dist → lib}/reducers/VariantReducer.d.ts +71 -71
- package/lib/reducers/VariantReducer.js +1 -0
- package/{dist → lib}/typings/errors.d.ts +42 -40
- package/lib/typings/errors.js +1 -0
- package/{dist → lib}/typings/index.d.ts +127 -151
- package/lib/typings/index.js +1 -0
- package/{dist → lib}/utils/PropsType.d.ts +33 -33
- package/lib/utils/PropsType.js +1 -0
- package/{dist → lib}/utils/addressesManager.d.ts +28 -27
- package/lib/utils/addressesManager.js +1 -0
- package/{dist → lib}/utils/baseReducer.d.ts +3 -3
- package/lib/utils/baseReducer.js +1 -0
- package/lib/utils/browserInfo.d.ts +9 -0
- package/lib/utils/browserInfo.js +1 -0
- package/{dist → lib}/utils/childrenTypes.d.ts +9 -9
- package/lib/utils/childrenTypes.js +1 -0
- package/{dist → lib}/utils/countryStateCity.d.ts +9 -9
- package/lib/utils/countryStateCity.js +1 -0
- package/{dist → lib}/utils/customMessages.d.ts +8 -8
- package/lib/utils/customMessages.js +1 -0
- package/lib/utils/customerOrderOptions.d.ts +3 -0
- package/lib/utils/customerOrderOptions.js +1 -0
- package/{dist → lib}/utils/getAmount.d.ts +9 -9
- package/lib/utils/getAmount.js +1 -0
- package/{dist → lib}/utils/getCurrentItemKey.d.ts +6 -6
- package/lib/utils/getCurrentItemKey.js +1 -0
- package/lib/utils/getErrors.d.ts +11 -0
- package/lib/utils/getErrors.js +1 -0
- package/lib/utils/getLineItemsCount.d.ts +12 -0
- package/lib/utils/getLineItemsCount.js +1 -0
- package/{dist → lib}/utils/getLoaderComponent.d.ts +3 -3
- package/lib/utils/getLoaderComponent.js +1 -0
- package/lib/utils/getPrices.d.ts +17 -0
- package/lib/utils/getPrices.js +1 -0
- package/lib/utils/getSdk.d.ts +3 -0
- package/lib/utils/getSdk.js +1 -0
- package/lib/utils/getSkus.d.ts +3 -0
- package/lib/utils/getSkus.js +1 -0
- package/{dist → lib}/utils/isEmptyStates.d.ts +1 -1
- package/lib/utils/isEmptyStates.js +1 -0
- package/{dist → lib}/utils/isJSON.d.ts +1 -1
- package/lib/utils/isJSON.js +1 -0
- package/lib/utils/jwt.d.ts +27 -0
- package/lib/utils/jwt.js +1 -0
- package/{dist → lib}/utils/localStorage.d.ts +17 -18
- package/lib/utils/localStorage.js +1 -0
- package/lib/utils/organization.d.ts +6 -0
- package/lib/utils/organization.js +1 -0
- package/lib/utils/paypalPayment.d.ts +3 -0
- package/lib/utils/paypalPayment.js +1 -0
- package/{dist → lib}/utils/promisify.d.ts +1 -1
- package/lib/utils/promisify.js +1 -0
- package/lib/utils/shipments.d.ts +2 -0
- package/lib/utils/shipments.js +1 -0
- package/{dist → lib}/utils/validateFormFields.d.ts +22 -19
- package/lib/utils/validateFormFields.js +1 -0
- package/package.json +99 -85
- package/dist/components/AddressField.d.ts +0 -37
- package/dist/components/CustomerAddressForm.d.ts +0 -8
- package/dist/components/CustomerField.d.ts +0 -10
- package/dist/components/LineItemImage.d.ts +0 -10
- package/dist/components/LineItemName.d.ts +0 -7
- package/dist/components/LineItemSkuCode.d.ts +0 -7
- package/dist/components/OrderList.d.ts +0 -28
- package/dist/components/OrderListRow.d.ts +0 -14
- package/dist/components/PaymentGateway.d.ts +0 -11
- package/dist/components/ShippingMethodRadioButton.d.ts +0 -9
- package/dist/components/utils/BaseInput.d.ts +0 -5
- package/dist/context/CustomerAddressFormContext.d.ts +0 -18
- package/dist/context/LineItemChildrenContext.d.ts +0 -7
- package/dist/context/OrderContext.d.ts +0 -4
- package/dist/context/OrderListChildrenContext.d.ts +0 -14
- package/dist/context/ShipmentChildrenContext.d.ts +0 -13
- package/dist/context/ShippingMethodChildrenContext.d.ts +0 -9
- package/dist/context/SkuListsContext.d.ts +0 -3
- package/dist/index.d.ts +0 -91
- package/dist/index.js +0 -8
- package/dist/react-components.cjs.development.js +0 -12778
- package/dist/react-components.cjs.development.js.map +0 -1
- package/dist/react-components.cjs.production.min.js +0 -2
- package/dist/react-components.cjs.production.min.js.map +0 -1
- package/dist/react-components.esm.js +0 -12680
- package/dist/react-components.esm.js.map +0 -1
- package/dist/reducers/AvailabilityReducer.d.ts +0 -40
- package/dist/reducers/OrderReducer.d.ts +0 -131
- package/dist/typings/order.d.ts +0 -120
- package/dist/utils/customerOrderOptions.d.ts +0 -4
- package/dist/utils/dynamicNaming.d.ts +0 -5
- package/dist/utils/getErrorsByCollection.d.ts +0 -11
- package/dist/utils/getLineItemsCount.d.ts +0 -6
- package/dist/utils/getPrices.d.ts +0 -18
- package/dist/utils/getSkus.d.ts +0 -3
- package/dist/utils/icons.d.ts +0 -3
- package/dist/utils/isDate.d.ts +0 -1
- package/dist/utils/paypalPayment.d.ts +0 -3
- package/dist/utils/scrollbarWidth.d.ts +0 -1
- package/dist/utils/shipments.d.ts +0 -5
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { FunctionComponent, PropsWithoutRef, ReactNode } from 'react';
|
|
2
|
-
import { FunctionChildren } from
|
|
3
|
-
import { AddToCartReturn } from
|
|
4
|
-
import {
|
|
5
|
-
declare type
|
|
6
|
-
handleClick: () => AddToCartReturn;
|
|
7
|
-
} & Omit<AddToCartButtonProps, 'children'
|
|
8
|
-
declare type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { FunctionComponent, 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<AddToCartButtonProps, 'children'>;
|
|
8
|
+
declare type AddToCartButtonChildrenProps = FunctionChildren<ChildrenProps>;
|
|
9
|
+
export declare type AddToCartButtonType = ChildrenProps;
|
|
10
|
+
declare type AddToCartButtonProps = {
|
|
11
|
+
children?: AddToCartButtonChildrenProps;
|
|
12
|
+
label?: string | ReactNode;
|
|
13
|
+
skuCode?: string;
|
|
14
|
+
bundleCode?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
skuListId?: string;
|
|
17
|
+
lineItem?: VariantOption['lineItem'];
|
|
18
|
+
} & PropsWithoutRef<JSX.IntrinsicElements['button']>;
|
|
19
|
+
declare const AddToCartButton: FunctionComponent<AddToCartButtonProps>;
|
|
20
|
+
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,has}from"lodash";import ItemContext from"../context/ItemContext";import getCurrentItemKey from"../utils/getCurrentItemKey";import components from"../config/components";import SkuListsContext from"../context/SkuListsContext";import ExternalFunctionContext from"../context/ExternalFunctionContext";import isFunction from"lodash/isFunction";const propTypes=components.AddToCartButton.propTypes,defaultProps=components.AddToCartButton.defaultProps,displayName=components.AddToCartButton.displayName,AddToCartButton=props=>{var _a,_b,_c;const{label="Add to cart",children,skuCode,bundleCode,disabled,skuListId,lineItem}=props,p=__rest(props,["label","children","skuCode","bundleCode","disabled","skuListId","lineItem"]),{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),sCode=!isEmpty(items)&&skuCode?(_a=items[skuCode])===null||_a===void 0?void 0:_a.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=()=>{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(res=>(getOrder&&orderId&&getOrder(orderId),res)).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))}}return url?callExternalFunction({url,data:{bundleCode,skuCode:sCode,skuId:(_b2=item[sCode])===null||_b2===void 0?void 0:_b2.id,quantity:qty,option:opt,lineItem:customLineItem}}).then(res=>(getOrder&&orderId&&getOrder(orderId),res)).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response)):addToCart&&addToCart({bundleCode,skuCode:sCode,skuId:(_a2=item[sCode])===null||_a2===void 0?void 0:_a2.id,quantity:qty,option:opt,lineItem:customLineItem})},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}),void 0):_jsx("button",Object.assign({},p,{disabled:autoDisabled,onClick:handleClick},{children:isFunction(label)?label():label}),void 0)};AddToCartButton.propTypes=propTypes,AddToCartButton.defaultProps=defaultProps,AddToCartButton.displayName=displayName;export default AddToCartButton;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
import { Address as AddressType } from '@commercelayer/sdk';
|
|
3
|
+
import { AddressCardsTemplateChildren } from './utils/AddressCardsTemplate';
|
|
4
|
+
declare type Props = {
|
|
5
|
+
children: ReactNode | AddressCardsTemplateChildren;
|
|
6
|
+
selectedClassName?: string;
|
|
7
|
+
disabledClassName?: string;
|
|
8
|
+
onSelect?: (address: AddressType) => void;
|
|
9
|
+
addresses?: AddressType[];
|
|
10
|
+
deselect?: boolean;
|
|
11
|
+
} & JSX.IntrinsicElements['div'];
|
|
12
|
+
declare const Address: FunctionComponent<Props>;
|
|
13
|
+
export default Address;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import AddressChildrenContext from"../context/AddressChildrenContext";import components from"../config/components";import CustomerContext from"../context/CustomerContext";import BillingAddressContext from"../context/BillingAddressContext";import ShippingAddressContext from"../context/ShippingAddressContext";import isEmpty from"lodash/isEmpty";import AddressContext from"../context/AddressContext";import OrderContext from"../context/OrderContext";import AddressCardsTemplate from"./utils/AddressCardsTemplate";const propTypes=components.Address.propTypes,Address=props=>{const{children,className,selectedClassName="",disabledClassName="",onSelect,addresses=[],deselect=!1}=props,p=__rest(props,["children","className","selectedClassName","disabledClassName","onSelect","addresses","deselect"]),{addresses:addressesContext}=useContext(CustomerContext),{setBillingAddress,billingCustomerAddressId}=useContext(BillingAddressContext),{setShippingAddress,shippingCustomerAddressId}=useContext(ShippingAddressContext),{shipToDifferentAddress,billingAddressId,shippingAddressId}=useContext(AddressContext),{order}=useContext(OrderContext),[selected,setSelected]=useState(null),items=isEmpty(addresses)?addressesContext&&addressesContext||[]:addresses;useEffect(()=>{items&&!deselect&&items.map((address,k)=>{billingCustomerAddressId&&address.reference===billingCustomerAddressId&&selected===null&&setSelected(k),!billingAddressId&&k===selected&&setBillingAddress&&setBillingAddress(address.id,{customerAddressId:address.reference}),shippingCustomerAddressId&&address.reference===shippingCustomerAddressId&&selected===null&&setSelected(k),!shippingAddressId&&k===selected&&setShippingAddress&&setShippingAddress(address.id,{customerAddressId:address.reference})}),deselect&&(async()=>{setBillingAddress&&await setBillingAddress(""),setShippingAddress&&await setShippingAddress("")})()},[deselect,billingCustomerAddressId,shippingCustomerAddressId,addressesContext,shipToDifferentAddress]);const handleSelect=async(k,addressId,customerAddressId,disabled,address)=>{!disabled&&setSelected(k),setBillingAddress&&await setBillingAddress(addressId,{customerAddressId}),!disabled&&setShippingAddress&&await setShippingAddress(addressId,{customerAddressId}),onSelect&&onSelect(address)},countryLock=order==null?void 0:order.shipping_country_code_lock,components2=typeof children=="function"?[]:items.filter(address=>!(setShippingAddress&&countryLock&&countryLock!==address.country_code)).map((address,k)=>{const addressProps={address},disabled=setShippingAddress&&countryLock&&countryLock!==address.country_code||!1,addressSelectedClass=selected===k?`${className} ${deselect?"":selectedClassName}`:className,customerAddressId=(address==null?void 0:address.reference)||"",finalClassName=disabled?`${className} ${disabledClassName}`:addressSelectedClass;return _jsx(AddressChildrenContext.Provider,Object.assign({value:addressProps},{children:_jsx("div",Object.assign({className:finalClassName,onClick:()=>handleSelect(k,address.id,customerAddressId,disabled,address),"data-disabled":disabled},p,{children}),void 0)}),k)}),parentProps=Object.assign({customerAddresses:items,selected,handleSelect,countryLock},props);return typeof children=="function"?_jsx(AddressCardsTemplate,Object.assign({},parentProps,{children}),void 0):_jsx(Fragment,{children:components2},void 0)};Address.propTypes=propTypes;export default Address;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { AddressCountrySelectName, BaseSelectComponentProps } from
|
|
3
|
-
declare type AddressCountrySelectorProps = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
|
|
4
|
-
name: AddressCountrySelectName;
|
|
5
|
-
required?: boolean;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
} & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
|
|
8
|
-
declare const AddressCountrySelector: FunctionComponent<AddressCountrySelectorProps>;
|
|
9
|
-
export default AddressCountrySelector;
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { AddressCountrySelectName, BaseSelectComponentProps } from '../typings/index';
|
|
3
|
+
declare type AddressCountrySelectorProps = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
|
|
4
|
+
name: AddressCountrySelectName;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
} & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
|
|
8
|
+
declare const AddressCountrySelector: FunctionComponent<AddressCountrySelectorProps>;
|
|
9
|
+
export default AddressCountrySelector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"./utils/BaseSelect";import components from"../config/components";import BillingAddressFormContext from"../context/BillingAddressFormContext";import ShippingAddressFormContext from"../context/ShippingAddressFormContext";import isEmpty from"lodash/isEmpty";import{getCountries}from"../utils/countryStateCity";const propTypes=components.AddressCountrySelector.propTypes,defaultProps=components.AddressCountrySelector.defaultProps,displayName=components.AddressCountrySelector.displayName,AddressCountrySelector=props=>{const{required=!0,value,name,className}=props,p=__rest(props,["required","value","name","className"]),billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),[hasError,setHasError]=useState(!1);useEffect(()=>{var _a,_b,_c,_d,_e,_f;return value&&(billingAddress==null?void 0:billingAddress.setValue)&&billingAddress.setValue(name,value),value&&(shippingAddress==null?void 0:shippingAddress.setValue)&&shippingAddress.setValue(name,value),!isEmpty(billingAddress.errors)&&((_b=(_a=billingAddress==null?void 0:billingAddress.errors)===null||_a===void 0?void 0:_a[name])===null||_b===void 0?void 0:_b.error)&&setHasError(!0),isEmpty((_c=billingAddress==null?void 0:billingAddress.errors)===null||_c===void 0?void 0:_c[name])&&hasError&&setHasError(!1),!isEmpty(shippingAddress.errors)&&((_e=(_d=shippingAddress==null?void 0:shippingAddress.errors)===null||_d===void 0?void 0:_d[name])===null||_e===void 0?void 0:_e.error)&&setHasError(!0),isEmpty((_f=shippingAddress==null?void 0:shippingAddress.errors)===null||_f===void 0?void 0:_f[name])&&hasError&&setHasError(!1),()=>{setHasError(!1)}},[value,billingAddress==null?void 0:billingAddress.errors,shippingAddress==null?void 0:shippingAddress.errors]);const errorClassName=(billingAddress==null?void 0:billingAddress.errorClassName)||(shippingAddress==null?void 0:shippingAddress.errorClassName),classNameComputed=`${className} ${hasError?errorClassName:""}`;return _jsx(BaseSelect,Object.assign({className:classNameComputed,ref:(billingAddress==null?void 0:billingAddress.validation)||(shippingAddress==null?void 0:shippingAddress.validation),required,options:getCountries(),name,value},p),void 0)};AddressCountrySelector.propTypes=propTypes,AddressCountrySelector.defaultProps=defaultProps,AddressCountrySelector.displayName=displayName;export default AddressCountrySelector;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
import { AddressFieldView } from '../reducers/AddressReducer';
|
|
3
|
+
import { Address } from '@commercelayer/sdk';
|
|
4
|
+
declare type AddressFieldChildrenProps = Omit<AddressFieldProps, 'children' | 'name'> & {
|
|
5
|
+
address: Address;
|
|
6
|
+
};
|
|
7
|
+
declare type AddressFieldProps = ({
|
|
8
|
+
children?: (props: AddressFieldChildrenProps) => ReactNode;
|
|
9
|
+
name: AddressFieldView;
|
|
10
|
+
} | {
|
|
11
|
+
children: (props: AddressFieldChildrenProps) => ReactNode;
|
|
12
|
+
name?: AddressFieldView;
|
|
13
|
+
}) & JSX.IntrinsicElements['p'];
|
|
14
|
+
declare const AddressField: FunctionComponent<AddressFieldProps>;
|
|
15
|
+
export default AddressField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import AddressChildrenContext from"../context/AddressChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";import get from"lodash/get";const propTypes=components.AddressField.propTypes,displayName=components.AddressField.displayName,AddressField=props=>{const{name}=props,{address}=useContext(AddressChildrenContext),text=get(address,name),parentProps=Object.assign({address},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children}),void 0):_jsx("p",Object.assign({},props,{children:text}),void 0)};AddressField.propTypes=propTypes,AddressField.displayName=displayName;export default AddressField;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { BaseInputComponentProps, AddressInputName } from
|
|
3
|
-
export declare type AddressInputProps = {
|
|
4
|
-
name: AddressInputName;
|
|
5
|
-
} & Omit<BaseInputComponentProps, 'name'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
|
|
6
|
-
declare const AddressInput: FunctionComponent<AddressInputProps>;
|
|
7
|
-
export default AddressInput;
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { BaseInputComponentProps, AddressInputName } from '../typings/index';
|
|
3
|
+
export declare type AddressInputProps = {
|
|
4
|
+
name: AddressInputName;
|
|
5
|
+
} & Omit<BaseInputComponentProps, 'name'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
|
|
6
|
+
declare const AddressInput: FunctionComponent<AddressInputProps>;
|
|
7
|
+
export default AddressInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseInput from"./utils/BaseInput";import components from"../config/components";import BillingAddressFormContext from"../context/BillingAddressFormContext";import ShippingAddressFormContext from"../context/ShippingAddressFormContext";import isEmpty from"lodash/isEmpty";import{businessMandatoryField}from"../utils/validateFormFields";const propTypes=components.AddressInput.propTypes,displayName=components.AddressInput.displayName,AddressInput=props=>{const{placeholder="",required,value,className}=props,p=__rest(props,["placeholder","required","value","className"]),billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),[hasError,setHasError]=useState(!1);useEffect(()=>{var _a,_b,_c,_d,_e,_f;return value&&(billingAddress==null?void 0:billingAddress.setValue)&&billingAddress.setValue(p.name,value),value&&(shippingAddress==null?void 0:shippingAddress.setValue)&&shippingAddress.setValue(p.name,value),!isEmpty(billingAddress.errors)&&((_b=(_a=billingAddress==null?void 0:billingAddress.errors)===null||_a===void 0?void 0:_a[p.name])===null||_b===void 0?void 0:_b.error)&&setHasError(!0),!isEmpty(billingAddress)&&isEmpty((_c=billingAddress==null?void 0:billingAddress.errors)===null||_c===void 0?void 0:_c[p.name])&&hasError&&setHasError(!1),!isEmpty(shippingAddress.errors)&&((_e=(_d=shippingAddress==null?void 0:shippingAddress.errors)===null||_d===void 0?void 0:_d[p.name])===null||_e===void 0?void 0:_e.error)&&setHasError(!0),!isEmpty(shippingAddress)&&isEmpty((_f=shippingAddress==null?void 0:shippingAddress.errors)===null||_f===void 0?void 0:_f[p.name])&&hasError&&setHasError(!1),()=>{setHasError(!1)}},[value,billingAddress==null?void 0:billingAddress.errors,shippingAddress==null?void 0:shippingAddress.errors]);const mandatoryField=(billingAddress==null?void 0:billingAddress.isBusiness)?businessMandatoryField(p.name,billingAddress.isBusiness):businessMandatoryField(p.name,shippingAddress.isBusiness),reqField=required!==void 0?required:mandatoryField,errorClassName=(billingAddress==null?void 0:billingAddress.errorClassName)||(shippingAddress==null?void 0:shippingAddress.errorClassName),classNameComputed=`${className} ${hasError?errorClassName:""}`;return p.name==="billing_address_billing_info"&&!billingAddress.requiresBillingInfo?null:_jsx(BaseInput,Object.assign({ref:(billingAddress==null?void 0:billingAddress.validation)||(shippingAddress==null?void 0:shippingAddress.validation),className:classNameComputed,required:reqField,placeholder,defaultValue:value},p),void 0)};AddressInput.propTypes=propTypes,AddressInput.displayName=displayName;export default AddressInput;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { AddressStateSelectName, BaseSelectComponentProps } from
|
|
3
|
-
declare type AddressStateSelectorProps = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
|
|
4
|
-
name: AddressStateSelectName;
|
|
5
|
-
required?: boolean;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
inputClassName?: string;
|
|
8
|
-
selectClassName?: string;
|
|
9
|
-
} & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
|
|
10
|
-
declare const AddressStateSelector: FunctionComponent<AddressStateSelectorProps>;
|
|
11
|
-
export default AddressStateSelector;
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { AddressStateSelectName, BaseSelectComponentProps } from '../typings/index';
|
|
3
|
+
declare type AddressStateSelectorProps = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
|
|
4
|
+
name: AddressStateSelectName;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
inputClassName?: string;
|
|
8
|
+
selectClassName?: string;
|
|
9
|
+
} & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
|
|
10
|
+
declare const AddressStateSelector: FunctionComponent<AddressStateSelectorProps>;
|
|
11
|
+
export default AddressStateSelector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"./utils/BaseSelect";import components from"../config/components";import BillingAddressFormContext from"../context/BillingAddressFormContext";import ShippingAddressFormContext from"../context/ShippingAddressFormContext";import isEmpty from"lodash/isEmpty";import{getStateOfCountry,isValidState}from"../utils/countryStateCity";import isEmptyStates from"../utils/isEmptyStates";import AddressesContext from"../context/AddressContext";import BaseInput from"./utils/BaseInput";const propTypes=components.AddressStateSelector.propTypes,defaultProps=components.AddressStateSelector.defaultProps,displayName=components.AddressStateSelector.displayName,AddressStateSelector=props=>{var _a;const{required=!0,value,name,className,inputClassName,selectClassName}=props,p=__rest(props,["required","value","name","className","inputClassName","selectClassName"]),billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),{errors:addressErrors}=useContext(AddressesContext),[hasError,setHasError]=useState(!1),[countryCode,setCountryCode]=useState(""),[val,setVal]=useState(value||"");useEffect(()=>{var _a2,_b,_c,_d,_e,_f,_g,_h,_j;const billingCountryCode=((_b=(_a2=billingAddress==null?void 0:billingAddress.values)===null||_a2===void 0?void 0:_a2.billing_address_country_code)===null||_b===void 0?void 0:_b.value)||((_c=billingAddress==null?void 0:billingAddress.values)===null||_c===void 0?void 0:_c.country_code);!isEmpty(billingCountryCode)&&billingCountryCode!==countryCode&&setCountryCode(billingCountryCode);const shippingCountryCode=(_e=(_d=shippingAddress==null?void 0:shippingAddress.values)===null||_d===void 0?void 0:_d.shipping_address_country_code)===null||_e===void 0?void 0:_e.value;if(!isEmpty(shippingCountryCode)&&shippingCountryCode!==countryCode&&setCountryCode(shippingCountryCode),[!isEmpty(billingAddress),billingCountryCode,countryCode!==billingCountryCode].every(Boolean)&&!isValidState(val,billingCountryCode)&&(billingAddress.resetField&&billingAddress.resetField(name),setVal("")),[!isEmpty(shippingAddress),shippingCountryCode,countryCode!==shippingCountryCode].every(Boolean)&&!isValidState(val,shippingCountryCode)&&(shippingAddress.resetField&&shippingAddress.resetField(name),setVal("")),!isEmpty(billingAddress)){const fieldError=(_g=(_f=billingAddress==null?void 0:billingAddress.errors)===null||_f===void 0?void 0:_f[name])===null||_g===void 0?void 0:_g.error;setHasError(!!fieldError)}if(!isEmpty(shippingAddress)){const fieldError=(_j=(_h=shippingAddress==null?void 0:shippingAddress.errors)===null||_h===void 0?void 0:_h[name])===null||_j===void 0?void 0:_j.error;setHasError(!!fieldError)}return()=>{setHasError(!1)}},[value,billingAddress,shippingAddress,addressErrors]);const errorClassName=(billingAddress==null?void 0:billingAddress.errorClassName)||(shippingAddress==null?void 0:shippingAddress.errorClassName),classNameComputed=isEmptyStates(countryCode)?`${className} ${inputClassName} ${hasError?errorClassName:""}`:`${className} ${selectClassName} ${hasError?errorClassName:""}`;return isEmptyStates(countryCode)?_jsx(BaseInput,Object.assign({},p,{name,ref:(billingAddress==null?void 0:billingAddress.validation)||(shippingAddress==null?void 0:shippingAddress.validation),className:classNameComputed,required,placeholder:((_a=p.placeholder)===null||_a===void 0?void 0:_a.label)||"",defaultValue:val,type:"text"}),void 0):_jsx(BaseSelect,Object.assign({},p,{className:classNameComputed,ref:(billingAddress==null?void 0:billingAddress.validation)||(shippingAddress==null?void 0:shippingAddress.validation),required,options:getStateOfCountry(countryCode),name,value:val}),void 0)};AddressStateSelector.propTypes=propTypes,AddressStateSelector.defaultProps=defaultProps,AddressStateSelector.displayName=displayName;export default AddressStateSelector;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
export declare type AddressesContainerProps = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
shipToDifferentAddress?: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
export declare type AddressesContainerProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
shipToDifferentAddress?: boolean;
|
|
5
|
+
isBusiness?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const AddressesContainer: FunctionComponent<AddressesContainerProps>;
|
|
8
|
+
export default AddressesContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext,{defaultAddressContext}from"../context/AddressContext";import{useContext,useEffect,useReducer}from"react";import addressReducer,{addressInitialState,setAddressErrors,setCloneAddress}from"../reducers/AddressReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import{saveAddresses}from"../reducers/AddressReducer";import components from"../config/components";const propTypes=components.AddressesContainer.propTypes,displayName=components.AddressesContainer.displayName,AddressesContainer=props=>{const{children,shipToDifferentAddress=!1,isBusiness}=props,[state,dispatch]=useReducer(addressReducer,addressInitialState),{order,orderId,updateOrder}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>(dispatch({type:"setShipToDifferentAddress",payload:{shipToDifferentAddress,isBusiness}}),()=>{dispatch({type:"cleanup",payload:{}})}),[shipToDifferentAddress,isBusiness]);const contextValue=Object.assign(Object.assign({},state),{setAddressErrors:(errors,resource)=>setAddressErrors({errors,resource,dispatch,currentErrors:state.errors}),setAddress:params=>defaultAddressContext.setAddress(Object.assign(Object.assign({},params),{dispatch})),saveAddresses:async()=>await saveAddresses({config,dispatch,updateOrder,order,orderId,state}),setCloneAddress:(id,resource)=>setCloneAddress(id,resource,dispatch)});return _jsx(AddressesContext.Provider,Object.assign({value:contextValue},{children}),void 0)};AddressesContainer.propTypes=propTypes,AddressesContainer.displayName=displayName;export default AddressesContainer;
|
|
@@ -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,AdjustmentAmount=props=>_jsx(BaseOrderPrice,Object.assign({base:"amount",type:"adjustment"},props),void 0);AdjustmentAmount.propTypes=propTypes,AdjustmentAmount.defaultProps=defaultProps,AdjustmentAmount.displayName=displayName;export default AdjustmentAmount;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CSSProperties, FunctionComponent } from 'react';
|
|
2
|
+
import { PaymentSourceProps } from './PaymentSource';
|
|
3
|
+
declare type Styles = Partial<{
|
|
4
|
+
base: CSSProperties;
|
|
5
|
+
error: CSSProperties;
|
|
6
|
+
placeholder: CSSProperties;
|
|
7
|
+
validated: CSSProperties;
|
|
8
|
+
}>;
|
|
9
|
+
export declare type AdyenPaymentConfig = {
|
|
10
|
+
cardContainerClassName?: string;
|
|
11
|
+
threeDSecureContainerClassName?: string;
|
|
12
|
+
placeOrderCallback?: (response: {
|
|
13
|
+
placed: boolean;
|
|
14
|
+
}) => void;
|
|
15
|
+
styles?: Styles;
|
|
16
|
+
};
|
|
17
|
+
declare type AdyenPaymentProps = {
|
|
18
|
+
clientKey?: string;
|
|
19
|
+
config?: AdyenPaymentConfig;
|
|
20
|
+
templateCustomerSaveToWallet?: PaymentSourceProps['templateCustomerSaveToWallet'];
|
|
21
|
+
locale?: string;
|
|
22
|
+
environment?: string;
|
|
23
|
+
};
|
|
24
|
+
declare const AdyenPayment: FunctionComponent<AdyenPaymentProps>;
|
|
25
|
+
export default AdyenPayment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import isEmpty from"lodash/isEmpty";import{setCustomerOrderParam}from"../utils/localStorage";import Parent from"./utils/Parent";import getBrowserInfo from"../utils/browserInfo";import PlaceOrderContext from"../context/PlaceOrderContext";const threeDSConfiguration={challengeWindowSize:"05"},defaultConfig={},AdyenPayment=({clientKey,config,templateCustomerSaveToWallet,environment="test",locale="en_US"})=>{const{cardContainerClassName,threeDSecureContainerClassName,placeOrderCallback,styles}=Object.assign(Object.assign({},defaultConfig),config),[loadAdyen,setLoadAdyen]=useState(!1),[checkout,setCheckout]=useState({}),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext),{setPlaceOrder}=useContext(PlaceOrderContext),ref=useRef(null),handleSubmit=async(e,checkout2)=>{var _a,_b,_c,_d,_e,_f,_g;const savePaymentSourceToCustomerWallet=(_b=(_a=e==null?void 0:e.elements)===null||_a===void 0?void 0:_a.save_payment_source_to_customer_wallet)===null||_b===void 0?void 0:_b.checked;savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet);const attributes={_authorize:1};try{const pSource=paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes}),adyenAction=(_c=pSource==null?void 0:pSource.payment_response)===null||_c===void 0?void 0:_c.action,resultCode=(_d=pSource==null?void 0:pSource.payment_response)===null||_d===void 0?void 0:_d.resultCode;if(adyenAction&&["IdentifyShopper","RedirectShopper"].includes(resultCode))checkout2.createFromAction(adyenAction,threeDSConfiguration).mount("#adyen-action");else if(["Authorised","Pending","Received"].includes(resultCode)){const brand=(_f=(_e=pSource==null?void 0:pSource.payment_request_data)===null||_e===void 0?void 0:_e.payment_method)===null||_f===void 0?void 0:_f.brand;if(brand){const attributes2={metadata:{card:{brand}}};await setPaymentSource({paymentSourceId:pSource==null?void 0:pSource.id,paymentResource:"adyen_payments",attributes:attributes2})}return!0}const message=(_g=pSource==null?void 0:pSource.payment_response)===null||_g===void 0?void 0:_g.refusalReason;return setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}]),!1}catch(error){return setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}},handleChange=async(state,_component,config2,paySource)=>{if(state.isValid){if(ref.current){const adyenCheckout=await require("@adyen/adyen-web")(config2);ref.current.onsubmit=()=>handleSubmit(ref.current,adyenCheckout),setPaymentRef({ref})}const browserInfo=getBrowserInfo(),attributes={payment_request_data:{payment_method:state.data.paymentMethod,shopperInteraction:"Ecommerce",recurringProcessingModel:"CardOnFile",origin:window.location.origin,return_url:window.location.href,redirect_from_issuer_method:"GET",browser_info:Object.assign({acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"},browserInfo)}};paySource&&await setPaymentSource({paymentSourceId:paySource.id,paymentResource:"adyen_payments",attributes})}},handleOnAdditionalDetails=async(state,_component,config2)=>{var _a,_b;const attributes={payment_request_details:state.data,_details:1};try{const pSource=paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes}),adyenAction=(_a=pSource==null?void 0:pSource.payment_response)===null||_a===void 0?void 0:_a.action,resultCode=(_b=pSource==null?void 0:pSource.payment_response)===null||_b===void 0?void 0:_b.resultCode,AdyenCheckout=require("@adyen/adyen-web");if(adyenAction&&(await AdyenCheckout(config2)).createFromAction(adyenAction,threeDSConfiguration).mount("#adyen-action"),["Authorised","Pending","Received"].includes(resultCode)){const{placed}=setPlaceOrder&&await setPlaceOrder({paymentSource:pSource})||{placed:!1};placed&&placeOrderCallback&&placeOrderCallback({placed})}}catch(error){console.error("Adyen additional details error:",error)}};return useEffect(()=>{const paymentMethodsResponse=isEmpty(paymentSource==null?void 0:paymentSource.payment_methods)?{}:paymentSource==null?void 0:paymentSource.payment_methods;isEmpty(paymentMethodsResponse)&&console.error("Payment methods are not available. Please, check your Adyen configuration.");const options={locale,environment,clientKey,paymentMethodsResponse};return options.onChange=(s,c)=>handleChange(s,c,options,paymentSource),options.onAdditionalDetails=(s,c)=>handleOnAdditionalDetails(s,c,options),!ref&&clientKey&&setCustomerOrderParam("_save_payment_source_to_customer_wallet","false"),clientKey&&!loadAdyen&&!isEmpty(window)&&require("@adyen/adyen-web")(options).then(adyenCheckout=>{adyenCheckout.create("card",{styles}).mount("#adyen-card")&&(setCheckout(adyenCheckout),setLoadAdyen(!0))}),()=>{setPaymentRef({ref:{current:null}}),setLoadAdyen(!1)}},[clientKey,ref]),!clientKey&&!loadAdyen&&!checkout?null:_jsxs("form",Object.assign({ref,onSubmit:e=>handleSubmit(e,checkout)},{children:[_jsx("div",{className:cardContainerClassName,id:"adyen-card"},void 0),templateCustomerSaveToWallet&&_jsx(Parent,Object.assign({},{name:"save_payment_source_to_customer_wallet"},{children:templateCustomerSaveToWallet}),void 0),_jsx("div",{className:threeDSecureContainerClassName,id:"adyen-action"},void 0)]}),void 0)};export default AdyenPayment;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
declare type AvailabilityContainerProps = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
skuCode?: string;
|
|
5
|
-
};
|
|
6
|
-
declare const AvailabilityContainer: FunctionComponent<AvailabilityContainerProps>;
|
|
7
|
-
export default AvailabilityContainer;
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
declare type AvailabilityContainerProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
skuCode?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const AvailabilityContainer: FunctionComponent<AvailabilityContainerProps>;
|
|
7
|
+
export default AvailabilityContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useReducer,useEffect}from"react";import availabilityReducer,{availabilityInitialState,getAvailability}from"../reducers/AvailabilityReducer";import AvailabilityContext from"../context/AvailabilityContext";import{isEmpty}from"lodash";import ItemContext from"../context/ItemContext";import getCurrentItemKey from"../utils/getCurrentItemKey";import components from"../config/components";import CommerceLayerContext from"../context/CommerceLayerContext";import LineItemChildrenContext from"../context/LineItemChildrenContext";const propTypes=components.AvailabilityContainer.propTypes,displayName=components.AvailabilityContainer.displayName,AvailabilityContainer=props=>{const{children,skuCode}=props,{item,skuCode:itemSkuCode,setItem}=useContext(ItemContext),{lineItem}=useContext(LineItemChildrenContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(availabilityReducer,availabilityInitialState),sCode=skuCode||getCurrentItemKey(item)||itemSkuCode||(lineItem==null?void 0:lineItem.sku_code);return useEffect(()=>{var _a,_b,_c,_d,_e,_f,_g;if(sCode){const available=(_b=(_a=item[sCode])===null||_a===void 0?void 0:_a.inventory)===null||_b===void 0?void 0:_b.available,quantity=(_d=(_c=item[sCode])===null||_c===void 0?void 0:_c.inventory)===null||_d===void 0?void 0:_d.quantity,[level]=((_f=(_e=item[sCode])===null||_e===void 0?void 0:_e.inventory)===null||_f===void 0?void 0:_f.levels)||[{quantity:null,delivery_lead_times:[]}];if(!isEmpty(level)&&((_g=level==null?void 0:level.delivery_lead_times)===null||_g===void 0?void 0:_g.length)>0){const[delivery]=level==null?void 0:level.delivery_lead_times;dispatch({type:"setAvailability",payload:Object.assign(Object.assign({},delivery),{quantity:level==null?void 0:level.quantity})})}else config.accessToken&&!(item==null?void 0:item[sCode])?getAvailability({skuCode:sCode,config,dispatch,setItem}):available||dispatch({type:"setAvailability",payload:{quantity}})}return()=>{dispatch({type:"setAvailability",payload:{}})}},[config.accessToken,item,sCode]),_jsx(AvailabilityContext.Provider,Object.assign({value:Object.assign({},state)},{children}),void 0)};AvailabilityContainer.propTypes=propTypes,AvailabilityContainer.displayName=displayName;export default AvailabilityContainer;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { TimeFormat, FunctionChildren } from
|
|
3
|
-
import {
|
|
4
|
-
declare type AvailabilityTemplateChildrenProps = FunctionChildren<Omit<AvailabilityTemplateProps, 'children'> & {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export default AvailabilityTemplate;
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { TimeFormat, FunctionChildren } from '../typings/index';
|
|
3
|
+
import { DeliveryLeadTime } from '../reducers/AvailabilityReducer';
|
|
4
|
+
declare type AvailabilityTemplateChildrenProps = FunctionChildren<Omit<AvailabilityTemplateProps, 'children'> & DeliveryLeadTime & {
|
|
5
|
+
text: string;
|
|
6
|
+
quantity: number;
|
|
7
|
+
}>;
|
|
8
|
+
declare type AvailabilityTemplateProps = {
|
|
9
|
+
children?: AvailabilityTemplateChildrenProps;
|
|
10
|
+
timeFormat?: TimeFormat;
|
|
11
|
+
showShippingMethodName?: boolean;
|
|
12
|
+
showShippingMethodPrice?: boolean;
|
|
13
|
+
} & JSX.IntrinsicElements['p'];
|
|
14
|
+
declare const AvailabilityTemplate: FunctionComponent<AvailabilityTemplateProps>;
|
|
15
|
+
export default AvailabilityTemplate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import AvailabilityContext from"../context/AvailabilityContext";import Parent from"./utils/Parent";import{isEmpty}from"lodash";import components from"../config/components";const propTypes=components.AvailabilityTemplate.propTypes,defaultProps=components.AvailabilityTemplate.defaultProps,displayName=components.AvailabilityTemplate.displayName,AvailabilityTemplate=props=>{const{timeFormat,showShippingMethodName,showShippingMethodPrice,children}=props,p=__rest(props,["timeFormat","showShippingMethodName","showShippingMethodPrice","children"]),{min,max,shipping_method,quantity}=useContext(AvailabilityContext),mn=!isEmpty(min)&&timeFormat?min==null?void 0:min[timeFormat]:"",mx=!isEmpty(max)&&timeFormat?max==null?void 0:max[timeFormat]:"",text=[],shippingMethodPrice=showShippingMethodPrice&&(shipping_method==null?void 0:shipping_method.formatted_price_amount)?`(${shipping_method==null?void 0:shipping_method.formatted_price_amount})`:"",name=showShippingMethodName&&shipping_method?`with ${shipping_method.name}`:"";quantity&&quantity>0?(text.push("Available"),mn&&mx&&text.push(`in ${mn} - ${mx} ${timeFormat} ${name} ${shippingMethodPrice}`)):quantity===0&&text.push("Out of stock");const parentProps=Object.assign({min,max,shipping_method,quantity,text:text.join(" ")},props);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):_jsx("p",Object.assign({},p,{children:text.join(" ")}),void 0)};AvailabilityTemplate.propTypes=propTypes,AvailabilityTemplate.defaultProps=defaultProps,AvailabilityTemplate.displayName=displayName;export default AvailabilityTemplate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
declare type Props = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
};
|
|
5
|
-
declare const BillingAddressContainer: FunctionComponent<Props>;
|
|
6
|
-
export default BillingAddressContainer;
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
};
|
|
5
|
+
declare const BillingAddressContainer: FunctionComponent<Props>;
|
|
6
|
+
export default BillingAddressContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BillingAddressContext from"../context/BillingAddressContext";import{useContext,useEffect,useReducer}from"react";import billingAddressReducer,{billingAddressInitialState,setBillingAddress,setBillingCustomerAddressId}from"../reducers/BillingAddressReducer";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import OrderContext from"../context/OrderContext";import AddressContext from"../context/AddressContext";const propTypes=components.BillingAddressContainer.propTypes,BillingAddressContainer=props=>{const{children}=props,[state,dispatch]=useReducer(billingAddressReducer,billingAddressInitialState),config=useContext(CommerceLayerContext),{order,include,addResourceToInclude}=useContext(OrderContext),{shipToDifferentAddress,setCloneAddress}=useContext(AddressContext);useEffect(()=>((include==null?void 0:include.includes("billing_address"))||addResourceToInclude({newResource:"billing_address",resourcesIncluded:include}),order&&config&&setBillingCustomerAddressId({dispatch,order,setCloneAddress}),()=>{dispatch({type:"cleanup",payload:{}})}),[order,include]);const contextValue=Object.assign(Object.assign({},state),{setBillingAddress:async(id,options)=>{await setBillingAddress(id,{config,dispatch,order,shipToDifferentAddress,customerAddressId:options==null?void 0:options.customerAddressId}),setCloneAddress(id,"billing_address")}});return _jsx(BillingAddressContext.Provider,Object.assign({value:contextValue},{children}),void 0)};BillingAddressContainer.propTypes=propTypes;export default BillingAddressContainer;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
declare type BillingAddressFormProps = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
reset?: boolean;
|
|
5
|
-
errorClassName?: string;
|
|
6
|
-
} & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
|
|
7
|
-
declare const BillingAddressForm: FunctionComponent<BillingAddressFormProps>;
|
|
8
|
-
export default BillingAddressForm;
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
declare type BillingAddressFormProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
reset?: boolean;
|
|
5
|
+
errorClassName?: string;
|
|
6
|
+
} & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
|
|
7
|
+
declare const BillingAddressForm: FunctionComponent<BillingAddressFormProps>;
|
|
8
|
+
export default BillingAddressForm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../context/AddressContext";import useRapidForm from"rapid-form";import{useContext,useEffect,useRef}from"react";import BillingAddressFormContext from"../context/BillingAddressFormContext";import{isEmpty}from"lodash";import components from"../config/components";import OrderContext from"../context/OrderContext";import{getSaveBillingAddressToAddressBook}from"../utils/localStorage";import{businessMandatoryField}from"../utils/validateFormFields";const propTypes=components.BillingAddressForm.propTypes,BillingAddressForm=props=>{const{children,errorClassName,autoComplete="on",reset=!1}=props,p=__rest(props,["children","errorClassName","autoComplete","reset"]),{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,order,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{var _a,_b,_c;if((include==null?void 0:include.includes("billing_address"))?(includeLoaded==null?void 0:includeLoaded.billing_address)||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),isEmpty(errors)){if(!isEmpty(values)){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field==null?void 0:field.value)&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),(field==null?void 0:field.type)==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"billing_address",value:field.checked}))}console.log("values",values),setAddress({values:Object.assign(Object.assign({},values),isBusiness&&{business:isBusiness}),resource:"billing_address"})}}else{const formErrors=[];for(const fieldName in errors){const{code,message}=errors[fieldName];["billing_address_state_code"].includes(fieldName)?isEmpty(values.state_code)?delete errors[fieldName]:formErrors.push({code,message,resource:"billing_address",field:fieldName}):formErrors.push({code,message,resource:"billing_address",field:fieldName})}setAddressErrors(formErrors,"billing_address")}const checkboxChecked=((_b=(_a=ref.current)===null||_a===void 0?void 0:_a.querySelector('[name="billing_address_save_to_customer_book"]'))===null||_b===void 0?void 0:_b.checked)||getSaveBillingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"billing_address",value:!1}),ref&&((_c=ref.current)===null||_c===void 0||_c.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"})))},[errors,values,reset,include,includeLoaded,isBusiness]);const providerValues={isBusiness,values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:Object.assign(Object.assign(Object.assign({},values),field),isBusiness&&{business:isBusiness}),resource:"billing_address"})},errorClassName,requiresBillingInfo:(order==null?void 0:order.requires_billing_info)||!1,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(BillingAddressFormContext.Provider,Object.assign({value:providerValues},{children:_jsx("form",Object.assign({ref,autoComplete},p,{children}),void 0)}),void 0)};BillingAddressForm.propTypes=propTypes;export default BillingAddressForm;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { HostedFieldFieldOptions } from 'braintree-web/modules/hosted-fields';
|
|
3
|
-
import { PaymentSourceProps } from './PaymentSource';
|
|
4
|
-
declare type BraintreeHostedFields<Type> = {
|
|
5
|
-
[Property in keyof Type]: {
|
|
6
|
-
label?: string;
|
|
7
|
-
} & Type[Property];
|
|
8
|
-
};
|
|
9
|
-
export declare type BraintreeConfig = {
|
|
10
|
-
containerClassName?: string;
|
|
11
|
-
cardContainerClassName?: string;
|
|
12
|
-
expDateContainerClassName?: string;
|
|
13
|
-
fieldsContainerClassName?: string;
|
|
14
|
-
cvvContainerClassName?: string;
|
|
15
|
-
cardDetailsContainerClassName?: string;
|
|
16
|
-
fieldLabelClassName?: string;
|
|
17
|
-
inputWrapperClassName?: string;
|
|
18
|
-
fields?: BraintreeHostedFields<HostedFieldFieldOptions>;
|
|
19
|
-
styles?: {
|
|
20
|
-
[key: string]: Record<string, string>;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
declare type BraintreePaymentProps = {
|
|
24
|
-
authorization: string;
|
|
25
|
-
config?: BraintreeConfig;
|
|
26
|
-
templateCustomerSaveToWallet?: PaymentSourceProps['templateCustomerSaveToWallet'];
|
|
27
|
-
locale?: string;
|
|
28
|
-
};
|
|
29
|
-
declare const BraintreePayment: FunctionComponent<BraintreePaymentProps>;
|
|
30
|
-
export default BraintreePayment;
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { HostedFieldFieldOptions } from 'braintree-web/modules/hosted-fields';
|
|
3
|
+
import { PaymentSourceProps } from './PaymentSource';
|
|
4
|
+
declare type BraintreeHostedFields<Type> = {
|
|
5
|
+
[Property in keyof Type]: {
|
|
6
|
+
label?: string;
|
|
7
|
+
} & Type[Property];
|
|
8
|
+
};
|
|
9
|
+
export declare type BraintreeConfig = {
|
|
10
|
+
containerClassName?: string;
|
|
11
|
+
cardContainerClassName?: string;
|
|
12
|
+
expDateContainerClassName?: string;
|
|
13
|
+
fieldsContainerClassName?: string;
|
|
14
|
+
cvvContainerClassName?: string;
|
|
15
|
+
cardDetailsContainerClassName?: string;
|
|
16
|
+
fieldLabelClassName?: string;
|
|
17
|
+
inputWrapperClassName?: string;
|
|
18
|
+
fields?: BraintreeHostedFields<HostedFieldFieldOptions>;
|
|
19
|
+
styles?: {
|
|
20
|
+
[key: string]: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
declare type BraintreePaymentProps = {
|
|
24
|
+
authorization: string;
|
|
25
|
+
config?: BraintreeConfig;
|
|
26
|
+
templateCustomerSaveToWallet?: PaymentSourceProps['templateCustomerSaveToWallet'];
|
|
27
|
+
locale?: string;
|
|
28
|
+
};
|
|
29
|
+
declare const BraintreePayment: FunctionComponent<BraintreePaymentProps>;
|
|
30
|
+
export default BraintreePayment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import isEmpty from"lodash/isEmpty";import OrderContext from"../context/OrderContext";import Parent from"./utils/Parent";import{setCustomerOrderParam}from"../utils/localStorage";import promisify from"../utils/promisify";const defaultConfig={styles:{input:{"font-size":"16px",color:"#3A3A3A"},".number":{"font-family":"monospace"},":focus":{color:"blue"},".valid":{color:"green"},".invalid":{color:"red"},"@media screen and (max-width: 700px)":{input:{"font-size":"14px"}}},fields:{number:{label:"Card Number",selector:"#card-number",placeholder:"4111 1111 1111 1111"},cvv:{label:"CVV",selector:"#cvv",placeholder:"123"},expirationDate:{label:"Expiration Date",selector:"#expiration-date",placeholder:"10/2022"}},submitLabel:"Set payment method"},BraintreePayment=({authorization,config,templateCustomerSaveToWallet})=>{var _a,_b,_c;const{fields,styles,containerClassName,cardContainerClassName,fieldsContainerClassName,expDateContainerClassName,fieldLabelClassName,cvvContainerClassName,inputWrapperClassName,cardDetailsContainerClassName}=Object.assign(Object.assign({},defaultConfig),config),[loadBraintree,setLoadBraintree]=useState(!1),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),ref=useRef(null),handleSubmitForm=async(event,hostedFieldsInstance,threeDSInstance)=>{var _a2,_b2;const savePaymentSourceToCustomerWallet=(_b2=(_a2=event==null?void 0:event.elements)===null||_a2===void 0?void 0:_a2.save_payment_source_to_customer_wallet)===null||_b2===void 0?void 0:_b2.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),hostedFieldsInstance)try{const payload=await promisify(hostedFieldsInstance).then(payload2=>payload2),billingAddress=order==null?void 0:order.billing_address,verifyCardOptions={nonce:payload.nonce,bin:payload.details.bin,amount:order==null?void 0:order.total_amount_with_taxes_float,email:order==null?void 0:order.customer_email,billingAddress:{givenName:billingAddress==null?void 0:billingAddress.first_name,surname:billingAddress==null?void 0:billingAddress.last_name,phoneNumber:billingAddress==null?void 0:billingAddress.phone,streetAddress:billingAddress==null?void 0:billingAddress.line_1,countryCodeAlpha2:billingAddress==null?void 0:billingAddress.country_code,postalCode:billingAddress==null?void 0:billingAddress.zip_code,region:billingAddress==null?void 0:billingAddress.state_code,locality:billingAddress==null?void 0:billingAddress.city},onLookupComplete:(_data,next)=>{next()}},response=await threeDSInstance.verifyCard(verifyCardOptions);return response.rawCardinalSDKVerificationData.Validated&&paymentSource?(paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"braintree_payments",attributes:{payment_method_nonce:response.nonce,options:{id:response.nonce,card:{last4:response.details.lastFour,exp_year:response.details.expirationYear,exp_month:response.details.expirationMonth,brand:response.details.cardType.toLowerCase()}}}}),!0):!1}catch(error){return console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}return!1};return useEffect(()=>{if(!ref&&authorization&&setCustomerOrderParam("_save_payment_source_to_customer_wallet","false"),authorization&&!loadBraintree&&!isEmpty(window)){const braintreeClient=require("braintree-web/client"),hostedFields=require("braintree-web/hosted-fields"),threeDSecure=require("braintree-web/three-d-secure");braintreeClient.create({authorization},(clientErr,clientInstance)=>{if(clientErr){console.error(clientErr);return}hostedFields.create({client:clientInstance,fields,styles},(hostedFieldsErr,hostedFieldsInstance)=>{if(hostedFieldsErr){console.error(hostedFieldsErr);return}setLoadBraintree(!0),threeDSecure.create({authorization,version:2},(threeDSecureErr,threeDSecureInstance)=>{threeDSecureErr&&(console.error("3DSecure error",threeDSecureErr),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:threeDSecureErr.message}])),ref.current&&(ref.current.onsubmit=()=>handleSubmitForm(ref.current,hostedFieldsInstance,threeDSecureInstance),setPaymentRef({ref}))})})})}return()=>{setPaymentRef({ref:{current:null}}),setLoadBraintree(!1)}},[authorization,ref]),!authorization&&!loadBraintree?null:_jsx("div",Object.assign({className:containerClassName},{children:_jsxs("form",Object.assign({ref,id:"braintree-form",onSubmit:handleSubmitForm,className:containerClassName},{children:[_jsxs("div",Object.assign({className:fieldsContainerClassName},{children:[_jsxs("div",Object.assign({className:cardContainerClassName},{children:[_jsx("label",Object.assign({className:fieldLabelClassName,htmlFor:"card-number"},{children:(_a=fields==null?void 0:fields.number)===null||_a===void 0?void 0:_a.label}),void 0),_jsx("div",{className:inputWrapperClassName,id:"card-number"},void 0)]}),void 0),_jsxs("div",Object.assign({className:cardDetailsContainerClassName},{children:[_jsxs("div",Object.assign({className:expDateContainerClassName},{children:[_jsx("label",Object.assign({className:fieldLabelClassName,htmlFor:"expiration-date"},{children:(_b=fields==null?void 0:fields.expirationDate)===null||_b===void 0?void 0:_b.label}),void 0),_jsx("div",{className:inputWrapperClassName,id:"expiration-date"},void 0)]}),void 0),_jsxs("div",Object.assign({className:cvvContainerClassName},{children:[_jsx("label",Object.assign({className:fieldLabelClassName,htmlFor:"cvv"},{children:(_c=fields==null?void 0:fields.cvv)===null||_c===void 0?void 0:_c.label}),void 0),_jsx("div",{className:inputWrapperClassName,id:"cvv"},void 0)]}),void 0)]}),void 0)]}),void 0),_jsx("div",Object.assign({className:fieldsContainerClassName},{children:templateCustomerSaveToWallet&&_jsx(Parent,Object.assign({},{name:"save_payment_source_to_customer_wallet"},{children:templateCustomerSaveToWallet}),void 0)}),void 0)]}),void 0)}),void 0)};export default BraintreePayment;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { FunctionChildren } from
|
|
3
|
-
declare type CheckoutLinkChildrenProps = FunctionChildren<Omit<CheckoutLinkProps, 'children'> & {
|
|
4
|
-
checkoutUrl: string;
|
|
5
|
-
}>;
|
|
6
|
-
declare type CheckoutLinkProps = {
|
|
7
|
-
children?: CheckoutLinkChildrenProps;
|
|
8
|
-
label?: string;
|
|
9
|
-
} & JSX.IntrinsicElements['a'];
|
|
10
|
-
declare const CheckoutLink: FunctionComponent<CheckoutLinkProps>;
|
|
11
|
-
export default CheckoutLink;
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { FunctionChildren } from '../typings/index';
|
|
3
|
+
declare type CheckoutLinkChildrenProps = FunctionChildren<Omit<CheckoutLinkProps, 'children'> & {
|
|
4
|
+
checkoutUrl: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare type CheckoutLinkProps = {
|
|
7
|
+
children?: CheckoutLinkChildrenProps;
|
|
8
|
+
label?: string;
|
|
9
|
+
} & JSX.IntrinsicElements['a'];
|
|
10
|
+
declare const CheckoutLink: FunctionComponent<CheckoutLinkProps>;
|
|
11
|
+
export default CheckoutLink;
|
|
@@ -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 components from"../config/components";import Parent from"./utils/Parent";const propTypes=components.CheckoutLink.propTypes,defaultProps=components.CheckoutLink.defaultProps,displayName=components.CheckoutLink.displayName,CheckoutLink=props=>{const{label,children}=props,p=__rest(props,["label","children"]),{order}=useContext(OrderContext),parentProps=Object.assign({checkoutUrl:order==null?void 0:order.checkout_url,label},p);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):_jsx("a",Object.assign({href:order==null?void 0:order.checkout_url},p,{children:label}),void 0)};CheckoutLink.propTypes=propTypes,CheckoutLink.defaultProps=defaultProps,CheckoutLink.displayName=displayName;export default CheckoutLink;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
declare type CommerceLayerProps = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
accessToken: string;
|
|
5
|
-
endpoint: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default CommerceLayer;
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
declare type CommerceLayerProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
accessToken: string;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
};
|
|
7
|
+
declare const CommerceLayer: FunctionComponent<CommerceLayerProps>;
|
|
8
|
+
export default CommerceLayer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";const propTypes=components.CommerceLayer.propTypes,CommerceLayer=props=>{const{children}=props,p=__rest(props,["children"]);return _jsx(CommerceLayerContext.Provider,Object.assign({value:Object.assign({},p)},{children}),void 0)};CommerceLayer.propTypes=propTypes;export default CommerceLayer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
export declare type CustomerContainer = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
isGuest?: boolean;
|
|
5
|
-
};
|
|
6
|
-
declare const CustomerContainer: FunctionComponent<CustomerContainer>;
|
|
7
|
-
export default CustomerContainer;
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
export declare type CustomerContainer = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
isGuest?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const CustomerContainer: FunctionComponent<CustomerContainer>;
|
|
7
|
+
export default CustomerContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useReducer}from"react";import customerReducer,{customerInitialState,getCustomerAddresses,getCustomerPaymentSources}from"../reducers/CustomerReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{saveCustomerUser}from"../reducers/CustomerReducer";import CustomerContext from"../context/CustomerContext";import{defaultCustomerContext}from"../context/CustomerContext";import{isEmpty}from"lodash";const propTypes=components.CustomerContainer.propTypes,displayName=components.CustomerContainer.displayName,CustomerContainer=props=>{const{children,isGuest=!1}=props,[state,dispatch]=useReducer(customerReducer,customerInitialState),{order,addResourceToInclude,include,updateOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>(!(include==null?void 0:include.includes("available_customer_payment_sources.payment_source"))&&!isGuest?addResourceToInclude({newResource:"available_customer_payment_sources.payment_source"}):!(includeLoaded==null?void 0:includeLoaded["available_customer_payment_sources.payment_source"])&&!isGuest&&addResourceToInclude({newResourceLoaded:{"available_customer_payment_sources.payment_source":!0}}),config.accessToken&&isEmpty(state.addresses)&&!isGuest&&getCustomerAddresses({config,dispatch}),(order==null?void 0:order.available_customer_payment_sources)&&!isGuest&&getCustomerPaymentSources({dispatch,order}),()=>{dispatch({type:"setCustomerEmail",payload:{}})}),[config.accessToken,order,isGuest,include,includeLoaded]);const contextValue=Object.assign(Object.assign({isGuest},state),{saveCustomerUser:async customerEmail=>{await saveCustomerUser({config,customerEmail,dispatch,updateOrder,order})},setCustomerErrors:errors=>defaultCustomerContext.setCustomerErrors(errors,dispatch),setCustomerEmail:customerEmail=>defaultCustomerContext.setCustomerEmail(customerEmail,dispatch),getCustomerPaymentSources:()=>getCustomerPaymentSources({dispatch,order})});return _jsx(CustomerContext.Provider,Object.assign({value:contextValue},{children}),void 0)};CustomerContainer.propTypes=propTypes,CustomerContainer.displayName=displayName;export default CustomerContainer;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { BaseInputComponentProps } from
|
|
3
|
-
declare type CustomerInputProps = {
|
|
4
|
-
name?: 'customer_email' | string;
|
|
5
|
-
type?: 'email' | string;
|
|
6
|
-
saveOnBlur?: boolean;
|
|
7
|
-
onBlur?: () => void;
|
|
8
|
-
errorClassName?: string;
|
|
9
|
-
} & Omit<BaseInputComponentProps, 'name' | 'type' | 'onBlur'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
|
|
10
|
-
declare const CustomerInput: FunctionComponent<CustomerInputProps>;
|
|
11
|
-
export default CustomerInput;
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { BaseInputComponentProps } from '../typings/index';
|
|
3
|
+
declare type CustomerInputProps = {
|
|
4
|
+
name?: 'customer_email' | string;
|
|
5
|
+
type?: 'email' | string;
|
|
6
|
+
saveOnBlur?: boolean;
|
|
7
|
+
onBlur?: () => void;
|
|
8
|
+
errorClassName?: string;
|
|
9
|
+
} & Omit<BaseInputComponentProps, 'name' | 'type' | 'onBlur'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
|
|
10
|
+
declare const CustomerInput: FunctionComponent<CustomerInputProps>;
|
|
11
|
+
export default CustomerInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseInput from"./utils/BaseInput";import components from"../config/components";import useRapidForm from"rapid-form";import CustomerContext from"../context/CustomerContext";import isEmpty from"lodash/isEmpty";const propTypes=components.CustomerInput.propTypes,displayName=components.CustomerInput.displayName,CustomerInput=props=>{const{name="customer_email",placeholder="",required=!0,saveOnBlur=!1,type="email",value,onBlur,className,errorClassName}=props,p=__rest(props,["name","placeholder","required","saveOnBlur","type","value","onBlur","className","errorClassName"]),{validation,values,errors}=useRapidForm({fieldEvent:"blur"}),{saveCustomerUser,setCustomerErrors,setCustomerEmail}=useContext(CustomerContext),[hasError,setHasError]=useState(!1),handleOnBlur=async()=>{saveOnBlur&&isEmpty(errors)&&!isEmpty(values)&&(await saveCustomerUser(values[name].value),onBlur&&onBlur())};useEffect(()=>{if(isEmpty(errors))isEmpty(values)||(setCustomerErrors([]),setCustomerEmail(values[name].value),setHasError(!1));else{const formErrors=[];for(const fieldName in errors){const{code,message}=errors[fieldName];formErrors.push({code,message,resource:"orders",field:fieldName})}isEmpty(formErrors)||(setHasError(!0),setCustomerErrors(formErrors))}return()=>{setHasError(!1)}},[errors]);const classNameComputed=`${className} ${hasError?errorClassName:""}`;return _jsx(BaseInput,Object.assign({name,type,ref:validation,required,placeholder,defaultValue:value,onBlur:handleOnBlur,className:classNameComputed},p),void 0)};CustomerInput.propTypes=propTypes,CustomerInput.displayName=displayName;export default CustomerInput;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
export declare type DeliveryLeadTimeField = '
|
|
3
|
-
export declare type DeliveryLeadTimeComponentChildren = Omit<ShippingMethodPriceProps, 'children'>;
|
|
4
|
-
export interface ShippingMethodPriceProps extends Partial<JSX.IntrinsicElements['span']> {
|
|
5
|
-
children?: (props: DeliveryLeadTimeComponentChildren) => ReactNode;
|
|
6
|
-
type: DeliveryLeadTimeField;
|
|
7
|
-
text?: string;
|
|
8
|
-
}
|
|
9
|
-
declare const DeliveryLeadTime: FunctionComponent<ShippingMethodPriceProps>;
|
|
10
|
-
export default DeliveryLeadTime;
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
export declare type DeliveryLeadTimeField = 'min_hours' | 'max_hours' | 'min_days' | 'max_days';
|
|
3
|
+
export declare type DeliveryLeadTimeComponentChildren = Omit<ShippingMethodPriceProps, 'children'>;
|
|
4
|
+
export interface ShippingMethodPriceProps extends Partial<JSX.IntrinsicElements['span']> {
|
|
5
|
+
children?: (props: DeliveryLeadTimeComponentChildren) => ReactNode;
|
|
6
|
+
type: DeliveryLeadTimeField;
|
|
7
|
+
text?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const DeliveryLeadTime: FunctionComponent<ShippingMethodPriceProps>;
|
|
10
|
+
export default DeliveryLeadTime;
|