@commercelayer/react-components 4.5.0-beta.3 → 4.5.0-beta.5
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/lib/cjs/components/ExternalFunction.js +1 -0
- package/lib/cjs/components/MetadataInput.js +1 -0
- package/lib/cjs/components/SubmitButton.js +1 -0
- package/lib/cjs/components/addresses/Address.js +1 -0
- package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -0
- package/lib/cjs/components/addresses/AddressField.js +1 -0
- package/lib/cjs/components/addresses/AddressInput.js +1 -0
- package/lib/cjs/components/addresses/AddressStateSelector.js +1 -0
- package/lib/cjs/components/addresses/AddressesContainer.js +1 -0
- package/lib/cjs/components/addresses/AddressesEmpty.js +1 -0
- package/lib/cjs/components/addresses/BillingAddressContainer.js +1 -0
- package/lib/cjs/components/addresses/BillingAddressForm.js +1 -0
- package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -0
- package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -0
- package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -0
- package/lib/cjs/components/auth/CommerceLayer.js +1 -0
- package/lib/cjs/components/customers/CustomerAddressForm.js +1 -0
- package/lib/cjs/components/customers/CustomerContainer.js +1 -0
- package/lib/cjs/components/customers/CustomerField.js +1 -0
- package/lib/cjs/components/customers/CustomerInput.js +1 -0
- package/lib/cjs/components/customers/CustomerPaymentSource.js +1 -0
- package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.js +1 -0
- package/lib/cjs/components/customers/MyAccountLink.js +1 -0
- package/lib/cjs/components/customers/MyIdentityLink.d.ts +35 -0
- package/lib/cjs/components/customers/MyIdentityLink.js +2 -0
- package/lib/cjs/components/customers/SaveCustomerButton.js +1 -0
- package/lib/cjs/components/errors/Errors.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCard.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
- package/lib/cjs/components/gift_cards/GiftCardRecipientInput.js +1 -0
- package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -0
- package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.js +1 -0
- package/lib/cjs/components/line_items/LineItem.js +1 -0
- package/lib/cjs/components/line_items/LineItemAmount.js +1 -0
- package/lib/cjs/components/line_items/LineItemCode.js +1 -0
- package/lib/cjs/components/line_items/LineItemField.js +1 -0
- package/lib/cjs/components/line_items/LineItemImage.js +1 -0
- package/lib/cjs/components/line_items/LineItemName.js +1 -0
- package/lib/cjs/components/line_items/LineItemOption.js +1 -0
- package/lib/cjs/components/line_items/LineItemOptions.js +1 -0
- package/lib/cjs/components/line_items/LineItemQuantity.js +1 -0
- package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -0
- package/lib/cjs/components/line_items/LineItemsContainer.js +1 -0
- package/lib/cjs/components/line_items/LineItemsCount.js +1 -0
- package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -0
- package/lib/cjs/components/orders/AddToCartButton.js +1 -0
- package/lib/cjs/components/orders/AdjustmentAmount.js +1 -0
- package/lib/cjs/components/orders/CartLink.d.ts +8 -0
- package/lib/cjs/components/orders/CartLink.js +2 -1
- package/lib/cjs/components/orders/CheckoutLink.js +1 -0
- package/lib/cjs/components/orders/DiscountAmount.js +1 -0
- package/lib/cjs/components/orders/GiftCardAmount.js +1 -0
- package/lib/cjs/components/orders/HostedCart.js +1 -0
- package/lib/cjs/components/orders/OrderContainer.js +1 -0
- package/lib/cjs/components/orders/OrderList.js +1 -0
- package/lib/cjs/components/orders/OrderListEmpty.js +1 -0
- package/lib/cjs/components/orders/OrderListPaginationButtons.js +1 -0
- package/lib/cjs/components/orders/OrderListPaginationInfo.js +1 -0
- package/lib/cjs/components/orders/OrderListRow.js +1 -0
- package/lib/cjs/components/orders/OrderNumber.js +1 -0
- package/lib/cjs/components/orders/OrderStorage.js +1 -0
- package/lib/cjs/components/orders/PaymentMethodAmount.js +1 -0
- package/lib/cjs/components/orders/PlaceOrderButton.js +1 -0
- package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -0
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -0
- package/lib/cjs/components/orders/ShippingAmount.js +1 -0
- package/lib/cjs/components/orders/SubTotalAmount.js +1 -0
- package/lib/cjs/components/orders/TaxesAmount.js +1 -0
- package/lib/cjs/components/orders/TotalAmount.js +1 -0
- package/lib/cjs/components/parcels/ParcelField.js +1 -0
- package/lib/cjs/components/parcels/ParcelLineItem.js +1 -0
- package/lib/cjs/components/parcels/ParcelLineItemField.js +1 -0
- package/lib/cjs/components/parcels/ParcelLineItemsCount.js +1 -0
- package/lib/cjs/components/parcels/Parcels.js +1 -0
- package/lib/cjs/components/parcels/ParcelsCount.js +1 -0
- package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/CheckoutComGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/ExternalGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/KlarnaGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/PaypalGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/StripeGateway.js +1 -0
- package/lib/cjs/components/payment_gateways/WireTransferGateway.js +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -0
- package/lib/cjs/components/payment_source/AdyenPayment.js +1 -0
- package/lib/cjs/components/payment_source/BraintreePayment.js +1 -0
- package/lib/cjs/components/payment_source/CheckoutComPayment.js +1 -0
- package/lib/cjs/components/payment_source/ExternalPayment.js +1 -0
- package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -0
- package/lib/cjs/components/payment_source/PaymentSource.js +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -0
- package/lib/cjs/components/payment_source/PaypalPayment.js +1 -0
- package/lib/cjs/components/payment_source/StripeExpressPayment.js +1 -0
- package/lib/cjs/components/payment_source/StripePayment.js +1 -0
- package/lib/cjs/components/payment_source/WireTransferPayment.js +1 -0
- package/lib/cjs/components/prices/Price.js +1 -0
- package/lib/cjs/components/prices/PricesContainer.js +1 -0
- package/lib/cjs/components/shipments/Shipment.js +1 -0
- package/lib/cjs/components/shipments/ShipmentField.js +1 -0
- package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -0
- package/lib/cjs/components/shipments/ShipmentsCount.js +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethodName.js +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethodPrice.js +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -0
- package/lib/cjs/components/skus/AvailabilityContainer.js +1 -0
- package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -0
- package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -0
- package/lib/cjs/components/skus/SkuField.js +1 -0
- package/lib/cjs/components/skus/SkuList.js +1 -0
- package/lib/cjs/components/skus/SkuListsContainer.js +1 -0
- package/lib/cjs/components/skus/Skus.js +1 -0
- package/lib/cjs/components/skus/SkusContainer.js +1 -0
- package/lib/cjs/components/stock_transfers/StockTransfer.js +1 -0
- package/lib/cjs/components/stock_transfers/StockTransferField.js +1 -0
- package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -0
- package/lib/cjs/components/utils/BaseField.js +1 -0
- package/lib/cjs/components/utils/BaseInput.js +1 -0
- package/lib/cjs/components/utils/BaseOrderPrice.js +1 -0
- package/lib/cjs/components/utils/BaseSelect.js +1 -0
- package/lib/cjs/components/utils/ErrorBoundary.js +1 -0
- package/lib/cjs/components/utils/GenericFieldComponent.js +1 -0
- package/lib/cjs/components/utils/Parent.js +1 -0
- package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -0
- package/lib/cjs/components/utils/PriceTemplate.js +1 -0
- package/lib/cjs/components/utils/getAllErrors.js +1 -0
- package/lib/cjs/config/currency.js +1 -0
- package/lib/cjs/context/AddressChildrenContext.js +1 -0
- package/lib/cjs/context/AddressContext.js +1 -0
- package/lib/cjs/context/AvailabilityContext.js +1 -0
- package/lib/cjs/context/BillingAddressContext.js +1 -0
- package/lib/cjs/context/BillingAddressFormContext.js +1 -0
- package/lib/cjs/context/CommerceLayerContext.js +1 -0
- package/lib/cjs/context/CouponAndGiftCardFormContext.js +1 -0
- package/lib/cjs/context/CustomerAddressFormContext.js +1 -0
- package/lib/cjs/context/CustomerContext.js +1 -0
- package/lib/cjs/context/CustomerPaymentSourceContext.js +1 -0
- package/lib/cjs/context/ExternalFunctionContext.js +1 -0
- package/lib/cjs/context/GiftCardContext.js +1 -0
- package/lib/cjs/context/InStockSubscriptionContext.js +1 -0
- package/lib/cjs/context/LineItemChildrenContext.js +1 -0
- package/lib/cjs/context/LineItemContext.js +1 -0
- package/lib/cjs/context/LineItemOptionChildrenContext.js +1 -0
- package/lib/cjs/context/OrderContext.js +1 -0
- package/lib/cjs/context/OrderListChildrenContext.js +1 -0
- package/lib/cjs/context/OrderListPaginationContext.js +1 -0
- package/lib/cjs/context/OrderStorageContext.js +1 -0
- package/lib/cjs/context/ParcelChildrenContext.js +1 -0
- package/lib/cjs/context/ParcelLineItemChildrenContext.js +1 -0
- package/lib/cjs/context/PaymentMethodChildrenContext.js +1 -0
- package/lib/cjs/context/PaymentMethodContext.js +1 -0
- package/lib/cjs/context/PaymentSourceContext.js +1 -0
- package/lib/cjs/context/PlaceOrderContext.js +1 -0
- package/lib/cjs/context/PricesContext.js +1 -0
- package/lib/cjs/context/ShipmentChildrenContext.js +1 -0
- package/lib/cjs/context/ShipmentContext.js +1 -0
- package/lib/cjs/context/ShippingAddressContext.js +1 -0
- package/lib/cjs/context/ShippingAddressFormContext.js +1 -0
- package/lib/cjs/context/ShippingMethodChildrenContext.js +1 -0
- package/lib/cjs/context/SkuChildrenContext.js +1 -0
- package/lib/cjs/context/SkuContext.js +1 -0
- package/lib/cjs/context/SkuListsContext.js +1 -0
- package/lib/cjs/context/StockTransferChildrenContext.js +1 -0
- package/lib/cjs/hooks/useCommerceLayer.js +1 -0
- package/lib/cjs/hooks/useOrderContainer.js +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/reducers/AddressReducer.js +1 -0
- package/lib/cjs/reducers/AvailabilityReducer.js +1 -0
- package/lib/cjs/reducers/BillingAddressReducer.js +1 -0
- package/lib/cjs/reducers/CustomerReducer.js +1 -0
- package/lib/cjs/reducers/GiftCardReducer.js +1 -0
- package/lib/cjs/reducers/InStockSubscriptionReducer.js +1 -0
- package/lib/cjs/reducers/LineItemReducer.js +1 -0
- package/lib/cjs/reducers/OrderReducer.js +1 -0
- package/lib/cjs/reducers/PaymentMethodReducer.js +1 -0
- package/lib/cjs/reducers/PlaceOrderReducer.js +2 -1
- package/lib/cjs/reducers/PriceReducer.js +1 -0
- package/lib/cjs/reducers/ShipmentReducer.js +1 -0
- package/lib/cjs/reducers/ShippingAddressReducer.js +1 -0
- package/lib/cjs/reducers/SkuListsReducer.js +1 -0
- package/lib/cjs/reducers/SkuReducer.js +1 -0
- package/lib/cjs/typings/errors.js +1 -0
- package/lib/cjs/typings/globals.js +1 -0
- package/lib/cjs/typings/index.js +1 -0
- package/lib/cjs/utils/PropsType.js +1 -0
- package/lib/cjs/utils/addressesManager.js +1 -0
- package/lib/cjs/utils/baseReducer.js +1 -0
- package/lib/cjs/utils/browserInfo.js +1 -0
- package/lib/cjs/utils/checkIncludeResource.js +1 -0
- package/lib/cjs/utils/compareObjAttribute.js +1 -0
- package/lib/cjs/utils/countryStateCity.js +1 -0
- package/lib/cjs/utils/customMessages.js +1 -0
- package/lib/cjs/utils/customerOrderOptions.js +1 -0
- package/lib/cjs/utils/events.js +1 -0
- package/lib/cjs/utils/expressPaymentHelper.js +1 -0
- package/lib/cjs/utils/filterChildren.js +1 -0
- package/lib/cjs/utils/getAmount.js +1 -0
- package/lib/cjs/utils/getApplicationLink.d.ts +22 -7
- package/lib/cjs/utils/getApplicationLink.js +2 -1
- package/lib/cjs/utils/getCardDetails.js +1 -0
- package/lib/cjs/utils/getDomain.js +1 -0
- package/lib/cjs/utils/getErrors.js +1 -0
- package/lib/cjs/utils/getLineItemsCount.js +1 -0
- package/lib/cjs/utils/getLoaderComponent.js +1 -0
- package/lib/cjs/utils/getPaymentAttributes.js +1 -0
- package/lib/cjs/utils/getPrices.js +1 -0
- package/lib/cjs/utils/getSdk.js +1 -0
- package/lib/cjs/utils/getSkus.js +1 -0
- package/lib/cjs/utils/hasSubscriptions.js +1 -0
- package/lib/cjs/utils/hooks/useCustomContext.js +1 -0
- package/lib/cjs/utils/hooks/useExternalScript.js +1 -0
- package/lib/cjs/utils/icons.js +1 -0
- package/lib/cjs/utils/isDate.js +1 -0
- package/lib/cjs/utils/isEmpty.js +1 -0
- package/lib/cjs/utils/isEmptyStates.js +1 -0
- package/lib/cjs/utils/isJSON.js +1 -0
- package/lib/cjs/utils/jwt.js +1 -0
- package/lib/cjs/utils/localStorage.js +1 -0
- package/lib/cjs/utils/omit.js +1 -0
- package/lib/cjs/utils/organization.js +1 -0
- package/lib/cjs/utils/pick.js +1 -0
- package/lib/cjs/utils/placeholderImages.js +1 -0
- package/lib/cjs/utils/promisify.js +1 -0
- package/lib/cjs/utils/replace.js +1 -0
- package/lib/cjs/utils/scrollbarWidth.js +1 -0
- package/lib/cjs/utils/shipments.js +1 -0
- package/lib/cjs/utils/snakeToCamelCase.js +1 -0
- package/lib/cjs/utils/validateFormFields.js +1 -0
- package/lib/esm/components/ExternalFunction.js +1 -0
- package/lib/esm/components/MetadataInput.js +1 -0
- package/lib/esm/components/SubmitButton.js +1 -0
- package/lib/esm/components/addresses/Address.js +1 -0
- package/lib/esm/components/addresses/AddressCountrySelector.js +1 -0
- package/lib/esm/components/addresses/AddressField.js +1 -0
- package/lib/esm/components/addresses/AddressInput.js +1 -0
- package/lib/esm/components/addresses/AddressStateSelector.js +1 -0
- package/lib/esm/components/addresses/AddressesContainer.js +1 -0
- package/lib/esm/components/addresses/AddressesEmpty.js +1 -0
- package/lib/esm/components/addresses/BillingAddressContainer.js +1 -0
- package/lib/esm/components/addresses/BillingAddressForm.js +1 -0
- package/lib/esm/components/addresses/SaveAddressesButton.js +1 -0
- package/lib/esm/components/addresses/ShippingAddressContainer.js +1 -0
- package/lib/esm/components/addresses/ShippingAddressForm.js +1 -0
- package/lib/esm/components/auth/CommerceLayer.js +1 -0
- package/lib/esm/components/customers/CustomerAddressForm.js +1 -0
- package/lib/esm/components/customers/CustomerContainer.js +1 -0
- package/lib/esm/components/customers/CustomerField.js +1 -0
- package/lib/esm/components/customers/CustomerInput.js +1 -0
- package/lib/esm/components/customers/CustomerPaymentSource.js +1 -0
- package/lib/esm/components/customers/CustomerPaymentSourceEmpty.js +1 -0
- package/lib/esm/components/customers/MyAccountLink.js +1 -0
- package/lib/esm/components/customers/MyIdentityLink.d.ts +35 -0
- package/lib/esm/components/customers/MyIdentityLink.js +2 -0
- package/lib/esm/components/customers/SaveCustomerButton.js +1 -0
- package/lib/esm/components/errors/Errors.js +1 -0
- package/lib/esm/components/gift_cards/GiftCard.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardContainer.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardCurrencySelector.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardInput.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponCode.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponForm.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponInput.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
- package/lib/esm/components/gift_cards/GiftCardRecipientInput.js +1 -0
- package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -0
- package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.js +1 -0
- package/lib/esm/components/line_items/LineItem.js +1 -0
- package/lib/esm/components/line_items/LineItemAmount.js +1 -0
- package/lib/esm/components/line_items/LineItemCode.js +1 -0
- package/lib/esm/components/line_items/LineItemField.js +1 -0
- package/lib/esm/components/line_items/LineItemImage.js +1 -0
- package/lib/esm/components/line_items/LineItemName.js +1 -0
- package/lib/esm/components/line_items/LineItemOption.js +1 -0
- package/lib/esm/components/line_items/LineItemOptions.js +1 -0
- package/lib/esm/components/line_items/LineItemQuantity.js +1 -0
- package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -0
- package/lib/esm/components/line_items/LineItemsContainer.js +1 -0
- package/lib/esm/components/line_items/LineItemsCount.js +1 -0
- package/lib/esm/components/line_items/LineItemsEmpty.js +1 -0
- package/lib/esm/components/orders/AddToCartButton.js +1 -0
- package/lib/esm/components/orders/AdjustmentAmount.js +1 -0
- package/lib/esm/components/orders/CartLink.d.ts +8 -0
- package/lib/esm/components/orders/CartLink.js +2 -1
- package/lib/esm/components/orders/CheckoutLink.js +1 -0
- package/lib/esm/components/orders/DiscountAmount.js +1 -0
- package/lib/esm/components/orders/GiftCardAmount.js +1 -0
- package/lib/esm/components/orders/HostedCart.js +1 -0
- package/lib/esm/components/orders/OrderContainer.js +1 -0
- package/lib/esm/components/orders/OrderList.js +1 -0
- package/lib/esm/components/orders/OrderListEmpty.js +1 -0
- package/lib/esm/components/orders/OrderListPaginationButtons.js +1 -0
- package/lib/esm/components/orders/OrderListPaginationInfo.js +1 -0
- package/lib/esm/components/orders/OrderListRow.js +1 -0
- package/lib/esm/components/orders/OrderNumber.js +1 -0
- package/lib/esm/components/orders/OrderStorage.js +1 -0
- package/lib/esm/components/orders/PaymentMethodAmount.js +1 -0
- package/lib/esm/components/orders/PlaceOrderButton.js +1 -0
- package/lib/esm/components/orders/PlaceOrderContainer.js +1 -0
- package/lib/esm/components/orders/PrivacyAndTermsCheckbox.js +1 -0
- package/lib/esm/components/orders/ShippingAmount.js +1 -0
- package/lib/esm/components/orders/SubTotalAmount.js +1 -0
- package/lib/esm/components/orders/TaxesAmount.js +1 -0
- package/lib/esm/components/orders/TotalAmount.js +1 -0
- package/lib/esm/components/parcels/ParcelField.js +1 -0
- package/lib/esm/components/parcels/ParcelLineItem.js +1 -0
- package/lib/esm/components/parcels/ParcelLineItemField.js +1 -0
- package/lib/esm/components/parcels/ParcelLineItemsCount.js +1 -0
- package/lib/esm/components/parcels/Parcels.js +1 -0
- package/lib/esm/components/parcels/ParcelsCount.js +1 -0
- package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -0
- package/lib/esm/components/payment_gateways/BraintreeGateway.js +1 -0
- package/lib/esm/components/payment_gateways/CheckoutComGateway.js +1 -0
- package/lib/esm/components/payment_gateways/ExternalGateway.js +1 -0
- package/lib/esm/components/payment_gateways/KlarnaGateway.js +1 -0
- package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -0
- package/lib/esm/components/payment_gateways/PaypalGateway.js +1 -0
- package/lib/esm/components/payment_gateways/StripeGateway.js +1 -0
- package/lib/esm/components/payment_gateways/WireTransferGateway.js +1 -0
- package/lib/esm/components/payment_methods/PaymentMethod.js +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodName.js +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodPrice.js +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodRadioButton.js +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -0
- package/lib/esm/components/payment_source/AdyenPayment.js +1 -0
- package/lib/esm/components/payment_source/BraintreePayment.js +1 -0
- package/lib/esm/components/payment_source/CheckoutComPayment.js +1 -0
- package/lib/esm/components/payment_source/ExternalPayment.js +1 -0
- package/lib/esm/components/payment_source/KlarnaPayment.js +1 -0
- package/lib/esm/components/payment_source/PaymentSource.js +1 -0
- package/lib/esm/components/payment_source/PaymentSourceBrandIcon.js +1 -0
- package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -0
- package/lib/esm/components/payment_source/PaymentSourceDetail.js +1 -0
- package/lib/esm/components/payment_source/PaymentSourceEditButton.js +1 -0
- package/lib/esm/components/payment_source/PaypalPayment.js +1 -0
- package/lib/esm/components/payment_source/StripeExpressPayment.js +1 -0
- package/lib/esm/components/payment_source/StripePayment.js +1 -0
- package/lib/esm/components/payment_source/WireTransferPayment.js +1 -0
- package/lib/esm/components/prices/Price.js +1 -0
- package/lib/esm/components/prices/PricesContainer.js +1 -0
- package/lib/esm/components/shipments/Shipment.js +1 -0
- package/lib/esm/components/shipments/ShipmentField.js +1 -0
- package/lib/esm/components/shipments/ShipmentsContainer.js +1 -0
- package/lib/esm/components/shipments/ShipmentsCount.js +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethod.js +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethodName.js +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethodPrice.js +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -0
- package/lib/esm/components/skus/AvailabilityContainer.js +1 -0
- package/lib/esm/components/skus/AvailabilityTemplate.js +1 -0
- package/lib/esm/components/skus/DeliveryLeadTime.js +1 -0
- package/lib/esm/components/skus/SkuField.js +1 -0
- package/lib/esm/components/skus/SkuList.js +1 -0
- package/lib/esm/components/skus/SkuListsContainer.js +1 -0
- package/lib/esm/components/skus/Skus.js +1 -0
- package/lib/esm/components/skus/SkusContainer.js +1 -0
- package/lib/esm/components/stock_transfers/StockTransfer.js +1 -0
- package/lib/esm/components/stock_transfers/StockTransferField.js +1 -0
- package/lib/esm/components/utils/AddressCardsTemplate.js +1 -0
- package/lib/esm/components/utils/BaseField.js +1 -0
- package/lib/esm/components/utils/BaseInput.js +1 -0
- package/lib/esm/components/utils/BaseOrderPrice.js +1 -0
- package/lib/esm/components/utils/BaseSelect.js +1 -0
- package/lib/esm/components/utils/ErrorBoundary.js +1 -0
- package/lib/esm/components/utils/GenericFieldComponent.js +1 -0
- package/lib/esm/components/utils/Parent.js +1 -0
- package/lib/esm/components/utils/PaymentCardsTemplate.js +1 -0
- package/lib/esm/components/utils/PriceTemplate.js +1 -0
- package/lib/esm/components/utils/getAllErrors.js +1 -0
- package/lib/esm/config/currency.js +1 -0
- package/lib/esm/context/AddressChildrenContext.js +1 -0
- package/lib/esm/context/AddressContext.js +1 -0
- package/lib/esm/context/AvailabilityContext.js +1 -0
- package/lib/esm/context/BillingAddressContext.js +1 -0
- package/lib/esm/context/BillingAddressFormContext.js +1 -0
- package/lib/esm/context/CommerceLayerContext.js +1 -0
- package/lib/esm/context/CouponAndGiftCardFormContext.js +1 -0
- package/lib/esm/context/CustomerAddressFormContext.js +1 -0
- package/lib/esm/context/CustomerContext.js +1 -0
- package/lib/esm/context/CustomerPaymentSourceContext.js +1 -0
- package/lib/esm/context/ExternalFunctionContext.js +1 -0
- package/lib/esm/context/GiftCardContext.js +1 -0
- package/lib/esm/context/InStockSubscriptionContext.js +1 -0
- package/lib/esm/context/LineItemChildrenContext.js +1 -0
- package/lib/esm/context/LineItemContext.js +1 -0
- package/lib/esm/context/LineItemOptionChildrenContext.js +1 -0
- package/lib/esm/context/OrderContext.js +1 -0
- package/lib/esm/context/OrderListChildrenContext.js +1 -0
- package/lib/esm/context/OrderListPaginationContext.js +1 -0
- package/lib/esm/context/OrderStorageContext.js +1 -0
- package/lib/esm/context/ParcelChildrenContext.js +1 -0
- package/lib/esm/context/ParcelLineItemChildrenContext.js +1 -0
- package/lib/esm/context/PaymentMethodChildrenContext.js +1 -0
- package/lib/esm/context/PaymentMethodContext.js +1 -0
- package/lib/esm/context/PaymentSourceContext.js +1 -0
- package/lib/esm/context/PlaceOrderContext.js +1 -0
- package/lib/esm/context/PricesContext.js +1 -0
- package/lib/esm/context/ShipmentChildrenContext.js +1 -0
- package/lib/esm/context/ShipmentContext.js +1 -0
- package/lib/esm/context/ShippingAddressContext.js +1 -0
- package/lib/esm/context/ShippingAddressFormContext.js +1 -0
- package/lib/esm/context/ShippingMethodChildrenContext.js +1 -0
- package/lib/esm/context/SkuChildrenContext.js +1 -0
- package/lib/esm/context/SkuContext.js +1 -0
- package/lib/esm/context/SkuListsContext.js +1 -0
- package/lib/esm/context/StockTransferChildrenContext.js +1 -0
- package/lib/esm/hooks/useCommerceLayer.js +1 -0
- package/lib/esm/hooks/useOrderContainer.js +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/reducers/AddressReducer.js +1 -0
- package/lib/esm/reducers/AvailabilityReducer.js +1 -0
- package/lib/esm/reducers/BillingAddressReducer.js +1 -0
- package/lib/esm/reducers/CustomerReducer.js +1 -0
- package/lib/esm/reducers/GiftCardReducer.js +1 -0
- package/lib/esm/reducers/InStockSubscriptionReducer.js +1 -0
- package/lib/esm/reducers/LineItemReducer.js +1 -0
- package/lib/esm/reducers/OrderReducer.js +1 -0
- package/lib/esm/reducers/PaymentMethodReducer.js +1 -0
- package/lib/esm/reducers/PlaceOrderReducer.js +2 -1
- package/lib/esm/reducers/PriceReducer.js +1 -0
- package/lib/esm/reducers/ShipmentReducer.js +1 -0
- package/lib/esm/reducers/ShippingAddressReducer.js +1 -0
- package/lib/esm/reducers/SkuListsReducer.js +1 -0
- package/lib/esm/reducers/SkuReducer.js +1 -0
- package/lib/esm/typings/errors.js +1 -0
- package/lib/esm/typings/globals.js +1 -0
- package/lib/esm/typings/index.js +1 -0
- package/lib/esm/utils/PropsType.js +1 -0
- package/lib/esm/utils/addressesManager.js +1 -0
- package/lib/esm/utils/baseReducer.js +1 -0
- package/lib/esm/utils/browserInfo.js +1 -0
- package/lib/esm/utils/checkIncludeResource.js +1 -0
- package/lib/esm/utils/compareObjAttribute.js +1 -0
- package/lib/esm/utils/countryStateCity.js +1 -0
- package/lib/esm/utils/customMessages.js +1 -0
- package/lib/esm/utils/customerOrderOptions.js +1 -0
- package/lib/esm/utils/events.js +1 -0
- package/lib/esm/utils/expressPaymentHelper.js +1 -0
- package/lib/esm/utils/filterChildren.js +1 -0
- package/lib/esm/utils/getAmount.js +1 -0
- package/lib/esm/utils/getApplicationLink.d.ts +22 -7
- package/lib/esm/utils/getApplicationLink.js +2 -1
- package/lib/esm/utils/getCardDetails.js +1 -0
- package/lib/esm/utils/getDomain.js +1 -0
- package/lib/esm/utils/getErrors.js +1 -0
- package/lib/esm/utils/getLineItemsCount.js +1 -0
- package/lib/esm/utils/getLoaderComponent.js +1 -0
- package/lib/esm/utils/getPaymentAttributes.js +1 -0
- package/lib/esm/utils/getPrices.js +1 -0
- package/lib/esm/utils/getSdk.js +1 -0
- package/lib/esm/utils/getSkus.js +1 -0
- package/lib/esm/utils/hasSubscriptions.js +1 -0
- package/lib/esm/utils/hooks/useCustomContext.js +1 -0
- package/lib/esm/utils/hooks/useExternalScript.js +1 -0
- package/lib/esm/utils/icons.js +1 -0
- package/lib/esm/utils/isDate.js +1 -0
- package/lib/esm/utils/isEmpty.js +1 -0
- package/lib/esm/utils/isEmptyStates.js +1 -0
- package/lib/esm/utils/isJSON.js +1 -0
- package/lib/esm/utils/jwt.js +1 -0
- package/lib/esm/utils/localStorage.js +1 -0
- package/lib/esm/utils/omit.js +1 -0
- package/lib/esm/utils/organization.js +1 -0
- package/lib/esm/utils/pick.js +1 -0
- package/lib/esm/utils/placeholderImages.js +1 -0
- package/lib/esm/utils/promisify.js +1 -0
- package/lib/esm/utils/replace.js +1 -0
- package/lib/esm/utils/scrollbarWidth.js +1 -0
- package/lib/esm/utils/shipments.js +1 -0
- package/lib/esm/utils/snakeToCamelCase.js +1 -0
- package/lib/esm/utils/validateFormFields.js +1 -0
- package/package.json +23 -23
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";import getOrganizationSlug from"../utils/organization";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export const createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=getSdk(config);try{const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Create order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""},getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=getSdk(config);try{const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=getSdk(config);try{const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await getApiOrder({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=getErrors({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}export async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption}=params;try{if(config){const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=await sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),await getApiOrder({id,...params})}else await getApiOrder({id,...params,state});if(!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=getOrganizationSlug(config.endpoint??""),params2=`${id}?accessToken=${config.accessToken??""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=getErrors({error,resource:"orders"});return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}}export const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};export async function setGiftCardOrCouponCode({code,codeType,dispatch,config,order,include,state}){try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,order:currentOrder,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success,order:currentOrder}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export async function removeGiftCardOrCouponCode({codeType,dispatch,config,order,include,state}){try{if(config&&order&&dispatch){const attributes={[codeType]:""},orderUpdated=await updateOrder({id:order.id,attributes,config,include,dispatch,state});return dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0,order:orderUpdated?.order}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export const orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import{snakeToCamelCase}from"../utils/snakeToCamelCase";import{replace}from"../utils/replace";import{pick}from"../utils/pick";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[],paymentMethods:void 0},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})};export async function setPaymentMethod({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource}){let response={success:!1};try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:getSdk(config).payment_methods.relationship(paymentMethodId)};updateOrder!=null&&(response=await updateOrder({id:order.id,attributes})),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}return response}catch(error){const errors=getErrors({error,resource:"orders",field:paymentResource});return console.error("Set payment method",errors),response}}export async function setPaymentSource({config,dispatch,getOrder,attributes,order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors}){try{if(config&&order){let paymentSource;const sdk=getSdk(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=attributes!=null?await sdk[paymentResource].update(attrs):await sdk[paymentResource].retrieve(paymentSourceId)}else{const attrs={...attributes,order:sdk.orders.relationship(order.id)};paymentSource=await sdk[paymentResource].create(attrs)}return getOrder&&await getOrder(order.id),dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),paymentSource}}}catch(error){const errors=getErrors({error,resource:"payment_methods",field:paymentResource});console.error("Set payment source:",errors),dispatch&&setErrors({currentErrors,newErrors:errors,dispatch})}}export const updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await getSdk(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}},destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};export function getPaymentConfig(paymentResource,config){const resourceKeys=replace(replace(paymentResource,"payments","payment"),"transfers","transfer"),resource=snakeToCamelCase(resourceKeys);return pick(config,[resource])}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>baseReducer(state,reducer,type);export default paymentMethodReducer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import{isDoNotShip,shipmentsFilled}from"../utils/shipments";import{saveBillingAddress,saveShippingAddress,saveToWallet}from"../utils/customerOrderOptions";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";import{hasSubscriptions}from"../utils/hasSubscriptions";export function setButtonRef(ref,dispatch){ref?.current!=null&&dispatch({type:"setButtonRef",payload:{placeOrderButtonRef:ref}})}export const placeOrderInitialState={errors:[],isPermitted:!1};export function setPlaceOrderErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}export function placeOrderPermitted({config,order,dispatch,options}){if(order&&config){let isPermitted=!0;order.privacy_url&&order.terms_url&&(isPermitted=localStorage.getItem("privacy-terms")==="true");const billingAddress=order.billing_address,shippingAddress=order.shipping_address,doNotShip=isDoNotShip(order.line_items),shipments=order.shipments,shipment=shipments&&shipmentsFilled(shipments),paymentMethod=order.payment_method,paymentSource=order.payment_source;order.total_amount_with_taxes_cents!==0&&isEmpty(paymentMethod?.id)&&(isPermitted=!1),isEmpty(billingAddress)&&(isPermitted=!1),isEmpty(shippingAddress)&&!doNotShip&&(isPermitted=!1),!isEmpty(shipments)&&!shipment&&(isPermitted=!1),paymentSource?.mismatched_amounts&&(isPermitted=!1),dispatch({type:"setPlaceOrderPermitted",payload:{isPermitted,paymentType:paymentMethod?.payment_source_type,paymentSecret:paymentSource?.client_secret,paymentId:paymentSource?.options?.id,paymentSource,options}})}}export async function setPlaceOrder({state,order,config,setOrderErrors,paymentSource,setOrder,include}){const response={placed:!1};if(state&&config&&order){const sdk=getSdk(config),{options,paymentType}=state;try{if(paymentType==="paypal_payments"&&paymentSource?.type==="paypal_payments"){if(!options?.paypalPayerId&&paymentSource?.approval_url)return window.location.href=paymentSource?.approval_url,response;await sdk[paymentType].update({id:paymentSource.id,paypal_payer_id:options?.paypalPayerId})}if(paymentType==="checkout_com_payments"&&paymentSource&&options?.checkoutCom?.session_id){const payment=await sdk[paymentType].update({id:paymentSource.id,_details:!0,session_id:options?.checkoutCom?.session_id});if(payment?.payment_response?.status!=="Authorized"){const[action]=payment?.payment_response?.actions||[""];throw{errors:[{code:"PAYMENT_NOT_APPROVED_FOR_EXECUTION",message:action?.response_summary,resource:"orders",field:"checkout_com_payments"}]}}}const updateAttributes={id:order.id,_place:!0};switch(saveBillingAddress()&&await sdk.orders.update({id:order.id,_save_billing_address_to_customer_address_book:!0}),saveShippingAddress()&&await sdk.orders.update({id:order.id,_save_shipping_address_to_customer_address_book:!0}),paymentType){case"braintree_payments":{saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0});const orderUpdated=await sdk.orders.update(updateAttributes,{include});return setOrder&&setOrder(orderUpdated),setOrderErrors&&setOrderErrors([]),{placed:!0,order:orderUpdated}}default:{const orderUpdated=await sdk.orders.update(updateAttributes,{include});return setOrder&&setOrder(orderUpdated),saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0}),setOrderErrors&&setOrderErrors([]),hasSubscriptions(orderUpdated)&&await sdk.orders.update({id:order.id,_create_subscriptions:!0}),{placed:!0,order:orderUpdated}}}}catch(error){const errors=getErrors({error,resource:"orders",field:paymentType});return setOrderErrors&&setOrderErrors(errors),{...response,errors}}}return response}const type=["setErrors","setPlaceOrderPermitted","setButtonRef"],placeOrderReducer=(state,reducer)=>baseReducer(state,reducer,type);export default placeOrderReducer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import getPrices from"../utils/getPrices";import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]};export function setSkuCodes({skuCodes,dispatch}){dispatch&&dispatch({type:"setSkuCodes",payload:{skuCodes}})}export function getSkusPrice(skuCodes,{config,dispatch,perPage,filters}){let allPrices={};const sdk=getSdk(config);sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage}).then(async response=>{const pricesObj=getPrices(response);allPrices={...allPrices,...pricesObj},dispatch({type:"setPrices",payload:{prices:allPrices}}),dispatch({type:"setLoading",payload:{loading:!1}});const meta=response.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const pageResponse=await sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage,pageNumber}),pricesObj2=getPrices(pageResponse);allPrices={...allPrices,...pricesObj2},dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=getErrors({error,resource:"prices"});dispatch({type:"setErrors",payload:{errors}})})}export const unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default priceReducer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments,deliveryLeadTimes=await sdk.delivery_lead_times.list({include:["shipping_method","stock_location"]});dispatch({type:"setShipments",payload:{shipments,deliveryLeadTimes}})}catch(error){console.error(error)}};export async function setShippingMethod({config,shipmentId,shippingMethodId,getOrder,order}){try{if(shippingMethodId){const sdk=getSdk(config);if(await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder!=null&&order!=null)return{success:!0,order:await getOrder(order.id)}}return{success:!1}}catch(error){return console.error(error),{success:!1}}}const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shipmentReducer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shippingAddressInitialState={_shipping_address_clone_id:""},setShippingAddress=async(id,options)=>{try{if(options?.order){if(options.customerAddressId){const sdk=getSdk(options.config),attributes={id,reference:options.customerAddressId};await sdk.addresses.update(attributes)}options.dispatch({type:"setShippingAddress",payload:{_shipping_address_clone_id:id}})}}catch(error){console.error(error)}};export function setShippingCustomerAddressId({dispatch,order,setCloneAddress}){const customerAddressId=order?.shipping_address?.reference;try{customerAddressId&&(dispatch({type:"setShippingCustomerAddressId",payload:{shippingCustomerAddressId:customerAddressId}}),setCloneAddress(customerAddressId,"shipping_address"))}catch(error){console.error("error",error)}}const type=["setShippingAddress","setShippingCustomerAddressId","cleanup"],shippingAddressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shippingAddressReducer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";const actionType=["getSkuList","setSkuList"];export const skuListsInitialState={listIds:[]},getSkuList=async({listIds,config,dispatch})=>{const skuLists={};try{const sdk=getSdk(config);listIds.forEach(async id=>{const skuCodes=(await sdk.sku_lists.retrieve(id,{include:["skus"],fields:{skus:["code"]}})).skus;skuLists[id]=skuCodes}),dispatch({payload:{skuLists},type:"getSkuList"})}catch(error){console.error(error)}};const skuListsReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default skuListsReducer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";const actionType=["getSkus"];export const skuInitialState={skus:[],loading:!0,skuCodes:[]};export async function getSku({config,skus,dispatch,queryParams}){if(!config.accessToken||skus.length===0)return;const sdk=getSdk(config);let allSkus=[];const get=await sdk.skus.list({...queryParams,filters:{...queryParams?.filters,code_in:skus.join(",")}});allSkus=[...get];const meta=get.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const getPage=await sdk.skus.list({...queryParams,filters:{...queryParams?.filters,code_in:skus.join(",")},pageNumber});allSkus=[...allSkus,...getPage]}dispatch({type:"getSkus",payload:{skus:allSkus,loading:!1,skuCodes:skus}})}export default function skuReducer(state,reducer){return baseReducer(state,reducer,actionType)}
|
package/lib/esm/typings/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},BMObject=PropTypes.objectOf(PropTypes.string),baseOrderPricePropTypes={base:PropTypes.string.isRequired,type:PropTypes.string.isRequired,children:PropTypes.func,format:PropTypes.oneOf(["formatted","cents","float"]),...BC},baseOrderComponentPricePropTypes={children:baseOrderPricePropTypes.children,format:baseOrderPricePropTypes.format,...BC};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import isEmpty from"lodash/isEmpty";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo=!1})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===billingAddressId||a?.reference===billingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}if(countryCodeLock&&!isEmpty(billing_address)&&!shipToDifferentAddress)return billing_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(shipping_address)&&shipToDifferentAddress)return shipping_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(addresses)&&shippingAddressId&&shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===shippingAddressId||a?.reference===shippingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}return!1};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export default function getBrowserInfo(){const screenWidth=window?.screen?window.screen.width:"",screenHeight=window?.screen?window.screen.height:"",colorDepth=window?.screen?window.screen.colorDepth:"",userAgent=window?.navigator?window.navigator.userAgent:"",javaEnabled=window?.navigator?navigator.javaEnabled():!1;let language="";window?.navigator&&(language=window.navigator.language);const timeZoneOffset=new Date().getTimezoneOffset();return{screenWidth,screenHeight,colorDepth,userAgent,timeZoneOffset,language,javaEnabled}}export function cleanUrlBy(symbol="&"){const currentLocation=window?.location.href,[splitLocation]=currentLocation.split(symbol);return splitLocation??currentLocation}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export default function checkIncludeResources({order,resourceInclude}){const checkKeys=[];return resourceInclude.forEach(v=>{if(v.includes(".")){const[first]=v.split(".");order?.[first]===void 0&&checkKeys.push(!1)}else order?.[v]===void 0&&checkKeys.push(!1)}),checkKeys.length===0}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
function sortObj(obj){return Object.keys(obj).sort().reduce((result,key)=>(result[key]=obj[key],result),{})}export default function compareObjAttribute({attributes,object}){const returnObj={};return Object.keys(object).forEach(v=>{const element=attributes[v],compare=object[v];if(typeof element=="object"&&element){const elementSorted=sortObj(element),compareSorted=sortObj(compare);JSON.stringify(elementSorted)!==JSON.stringify(compareSorted)&&(returnObj[v]=element)}typeof element!="object"&&element&&element!==compare&&(returnObj[v]=element)}),returnObj}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{Countries}from"@ac-dev/countries-service";import{States}from"@ac-dev/states-service";export function getCountries(){return Countries.getCountries({sort:{mode:"alphabetical",key:"name"}}).map(({name,iso2})=>({label:name,value:iso2}))}export function getStateOfCountry(country_code){const filters={country_code};return country_code==="IT"&&(filters.is_region=!1),States.getStates({filters,sort:{mode:"alphabetical",key:"name"}}).map(({name,state_code})=>({label:name.replace("Province of",""),value:state_code}))}export function isValidState(state_code,country_code){return States.getStates({filters:{state_code,country_code}}).length>0}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{getSaveBillingAddressToAddressBook,getSavePaymentSourceToCustomerWallet,getSaveShippingAddressToAddressBook}from"./localStorage";export function saveToWallet(){return getSavePaymentSourceToCustomerWallet()}export function saveBillingAddress(){return getSaveBillingAddressToAddressBook()}export function saveShippingAddress(){return getSaveShippingAddressToAddressBook()}
|
package/lib/esm/utils/events.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
function subscribe(eventName,listener){document.addEventListener(eventName,listener)}function unsubscribe(eventName,listener){document.removeEventListener(eventName,listener)}function publish(eventName,data){const event=new CustomEvent(eventName,{detail:data});document.dispatchEvent(event)}export{publish,subscribe,unsubscribe};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import getSdk from"./getSdk";import{getDomain}from"./getDomain";const availablePaymentMethods=["stripe_payments"];export function getAvailableExpressPayments(paymentMethods){return paymentMethods.filter(payment=>payment.payment_source_type?availablePaymentMethods.includes(payment.payment_source_type):!1)}export async function setExpressFakeAddress({orderId,config,address,email}){const params={include:["shipments.available_shipping_methods"]},sdk=getSdk(config),fakeAddress=await sdk.addresses.create(address),resource={id:orderId,billing_address:sdk.addresses.relationship(fakeAddress.id),_shipping_address_same_as_billing:!0};return email!=null&&(resource.customer_email=email),await sdk.orders.update(resource,params),await sdk.orders.retrieve(orderId,params)}export function getExpressShippingMethods(order){const isSingleShipment=order?.shipments?.length===1,shippingMethods=order?.shipments?.map(shipment=>shipment.available_shipping_methods);if(isSingleShipment)return shippingMethods==null?null:shippingMethods.flat().map(method=>({id:method?.id??"",label:method?.name??"",amount:method?.price_amount_for_shipment_cents??0,detail:""}));{if(shippingMethods==null)return null;const shippingOptionsAmount=[];return shippingMethods.forEach(methods=>{if(methods!=null){const[firstMethod]=methods;firstMethod!=null&&shippingOptionsAmount.push(firstMethod.price_amount_for_shipment_cents??0)}}),[{id:"shipping",label:"Shipping",amount:shippingOptionsAmount.reduce((a,b)=>a+b,0),detail:""}]}}export async function setExpressShippingMethod({config,orderId,selectFirst=!0,selectedShippingMethodId,params}){const sdk=getSdk(config),order=await sdk.orders.retrieve(orderId,params),shippingMethods=getExpressShippingMethods(order);if(order?.shipments==null)throw new Error("No shipments found");const isSingleShipment=order.shipments.length===1,[shipmentId]=order.shipments.map(shipment=>shipment.id);if(shipmentId==null)throw new Error("No shipment found");if(shippingMethods==null||shippingMethods?.length===0)throw new Error("No shipping methods found");if(isSingleShipment)if(selectFirst){const[firstShippingMethodId]=shippingMethods.map(method=>method.id);firstShippingMethodId!=null&&await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(firstShippingMethodId)})}else selectedShippingMethodId!=null&&await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(selectedShippingMethodId)});else for(const shipment of order?.shipments??[]){const[firstShippingMethodId]=shipment?.available_shipping_methods?.map(method=>method.id)??[];firstShippingMethodId!=null&&await sdk.shipments.update({id:shipment.id,shipping_method:sdk.shipping_methods.relationship(firstShippingMethodId)})}return await sdk.orders.retrieve(order.id,params)}export async function setExpressPlaceOrder({config,orderId,paymentResource,paymentSourceId,placeTheOrder=!1}){const sdk=getSdk(config);if(!placeTheOrder&&paymentResource!=null&&paymentSourceId!=null){const include=["shipments.shipping_method","payment_source","payment_method"];return await sdk.orders.retrieve(orderId,{include}),await sdk[paymentResource].update({id:paymentSourceId,order:sdk.orders.relationship(orderId)}),await sdk.orders.update({id:orderId,payment_source:sdk[paymentResource].relationship(paymentSourceId)}),await sdk[paymentResource].update({id:paymentSourceId,_update:!0}),await sdk.orders.retrieve(orderId,{include})}return await sdk.orders.update({id:orderId,_place:!0})}export function expressRedirectUrl({order,config:{accessToken,endpoint}}){if(accessToken==null)throw new Error("No access token found");if(endpoint==null)throw new Error("No endpoint found");const{slug}=getDomain(endpoint);if(slug==null)throw new Error("No slug found");const href=order?.checkout_url!=null?order?.checkout_url:`https://${slug}.commercelayer.app/checkout/${order.id}?accessToken=${accessToken}`;window.location.pathname.includes("/checkout")||window.location.pathname.includes(`/${order.id}`)?window.location.reload():window.location.href=href}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export default function filterChildren({children,filterBy,componentName}){if(Array.isArray(children)?children.filter(child=>typeof child.type=="string").length>0:typeof children?.type=="string")throw new Error(`Only library components are allowed into <${componentName}/>`);return Array.isArray(children)?children.filter(child=>filterBy.includes(child.type.displayName)):children}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import keys from"lodash/keys";export default function getAmount(args){const{format,type,obj,base}=args;let v;return keys(obj).forEach(k=>{const key=k.toLowerCase(),typeOne=`${format}_${type}_${base}`.toLowerCase(),typeTwo=`${type}_${base}_${format}`.toLowerCase(),typeThree=`${format}_${base}_${type}`.toLowerCase(),typeFourth=`${base}_${type}_${format}`.toLowerCase();key===typeOne&&(v=obj[k]),key===typeTwo&&(v=obj[k]),key===typeThree&&(v=obj[k]),key===typeFourth&&(v=obj[k])}),v}
|
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
type ApplicationType = 'checkout' | 'cart' | 'my-account';
|
|
2
|
-
type ApplicationTypeProps = {
|
|
3
|
-
applicationType:
|
|
1
|
+
type ApplicationType = 'checkout' | 'cart' | 'my-account' | 'identity';
|
|
2
|
+
type ApplicationTypeProps<T extends ApplicationType = ApplicationType> = T extends 'my-account' ? {
|
|
3
|
+
applicationType: T;
|
|
4
4
|
orderId?: string;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
modeType?: 'login' | 'signup';
|
|
6
|
+
clientId?: string;
|
|
7
|
+
scope?: string;
|
|
8
|
+
returnUrl?: string;
|
|
9
|
+
} : T extends 'identity' ? {
|
|
10
|
+
applicationType: T;
|
|
11
|
+
orderId?: string;
|
|
12
|
+
modeType: 'login' | 'signup';
|
|
13
|
+
clientId: string;
|
|
14
|
+
scope: string;
|
|
15
|
+
returnUrl: string;
|
|
16
|
+
} : {
|
|
17
|
+
applicationType: Omit<T, 'my-account' | 'identity'>;
|
|
7
18
|
orderId: string;
|
|
19
|
+
modeType?: 'login' | 'signup';
|
|
20
|
+
clientId?: string;
|
|
21
|
+
scope?: string;
|
|
22
|
+
returnUrl?: string;
|
|
8
23
|
};
|
|
9
24
|
interface TArgs {
|
|
10
25
|
accessToken: string;
|
|
11
26
|
slug: string;
|
|
12
27
|
domain: string;
|
|
13
28
|
}
|
|
14
|
-
type Props =
|
|
15
|
-
export declare function getApplicationLink({ orderId, accessToken, slug, domain, applicationType }: Props): string;
|
|
29
|
+
type Props = ApplicationTypeProps & TArgs;
|
|
30
|
+
export declare function getApplicationLink({ orderId, accessToken, slug, domain, applicationType, modeType, clientId, scope, returnUrl }: Props): string;
|
|
16
31
|
export {};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
export function getApplicationLink({orderId,accessToken,slug,domain,applicationType,modeType,clientId,scope,returnUrl}){const env=domain==="commercelayer.io"?"":"stg.",t=modeType==="login"?"":"signup",c=clientId?`&clientId=${clientId}`:"",s=scope?`&scope=${scope}`:"",r=returnUrl?`&returnUrl=${returnUrl}`:"",params=applicationType==="identity"?`${c}${s}${r}`:"";return`https://${slug}.${env}commercelayer.app/${applicationType.toString()}/${orderId??t??""}?accessToken=${accessToken}${params}`}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export default function getCardDetails({paymentType,customerPayment}){switch(paymentType){case"checkout_com_payments":{const source=customerPayment.payment_source?.payment_response?.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":{const ps=customerPayment.payment_source,source=ps?.options?.card??ps?.payment_method?.card;if(source)return{...source};break}case"braintree_payments":{const source=customerPayment.payment_source?.options?.card;if(source)return{...source};break}case"adyen_payments":{const ps=customerPayment.payment_source,source=ps?.payment_request_data?.payment_method,authorized=ps?.payment_response?.resultCode==="Authorised",last4=ps?.payment_response?.additionalData?.cardSummary??ps?.payment_instrument?.card_last_digits??"****";if(source&&authorized){const brand=source.type==="scheme"?source.brand??"credit-card":source.type.replace("_account","");return{...source,last4,brand}}break}default:{const source=customerPayment.payment_source?.metadata?.card;if(source)return{...source};break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****"}}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import differenceBy from"lodash/differenceBy";export default function getErrors({error,resource,field,attributes}){return error?.errors?.map(e=>({...e,resource,...field!=null&&field!==""&&{field},...attributes!=null&&attributes}))}export function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=differenceBy(currentErrors,newErrors,filterBy),mergeErrors=currentErrors?.length===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];return dispatch?.({type:"setErrors",payload:{errors}}),errors}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export default function getLineItemsCount({lineItems,quantity=0,typeAccepted=["skus","gift_cards","bundles","adjustments"]}){return lineItems.filter(l=>typeAccepted.includes(l.item_type)&&l?.total_amount_cents!=null&&l?.total_amount_cents>=0).forEach(l=>{l.quantity&&(quantity+=l.quantity)}),quantity}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{getPaymentConfig}from"../reducers/PaymentMethodReducer";import{pick}from"./pick";import{replace}from"./replace";import{snakeToCamelCase}from"./snakeToCamelCase";export function getPaymentAttributes(params){const{resource,config,keys}=params,attributes=getPaymentConfig(resource,config),keysCamelCase=keys.map(key=>{const k=replace(replace(key,"payments","payment"),"transfers","transfer");return snakeToCamelCase(k)}),currentResource=snakeToCamelCase(replace(replace(resource,"payments","payment"),"transfers","transfer"));return attributes!=null&¤tResource in attributes?pick(attributes,keysCamelCase):void 0}export function getPaypalAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["paypal_payments"]});return attributes?.paypalPayment!=null&&"paypalPayment"in attributes?pick(attributes?.paypalPayment,["return_url","cancel_url"]):void 0}export function getExternalPaymentAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["external_payments"]});return attributes?.externalPayment!=null&&"externalPayment"in attributes?pick(attributes?.externalPayment,["payment_source_token"]):void 0}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export function getPriceByCode(skuPrices,code=""){return code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices)}export function getPricesComponent(skuPrices,props){return isEmpty(skuPrices)?_jsx(PriceTemplate,{...props}):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return _createElement(PriceTemplate,{...props,key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount,skuCode:p.sku_code})})}export default function getPrices(prices){const obj={};return isArray(prices)&&prices.forEach(p=>{const sku=p.sku_code;has(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}
|
package/lib/esm/utils/getSdk.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import getOrganizationSlug from"./organization";import Sdk from"@commercelayer/sdk";export default function getSdk({endpoint,accessToken}){if(accessToken==null||endpoint==null)throw new Error("accessToken and endpoint are required parameters");const org=getOrganizationSlug(endpoint);return Sdk({accessToken,...org})}
|
package/lib/esm/utils/getSkus.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{useContext}from"react";export default function useCustomContext({context,key,currentComponentName,contextComponentName}){const currentContext=useContext(context),isProduction=process.env.NODE_ENV==="production",msg=`Cannot use <${currentComponentName}/> outside of <${contextComponentName}/>`;if(key!=null&&key in currentContext||key==null&¤tContext!=null)return currentContext;if(isProduction)console.error(msg);else throw new Error(msg);return currentContext}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{useEffect,useState}from"react";export default function useExternalScript(url){const[loaded,setLoaded]=useState(!1);return useEffect(()=>{const script=document.createElement("script");return script.src=url,script.async=!0,document.body.appendChild(script),script.onload=()=>{setLoaded(!0)},()=>{document.body.removeChild(script),setLoaded(!1)}},[url]),loaded}
|
package/lib/esm/utils/icons.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";export const sortDescIcon=_jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:_jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4"})}),sortAscIcon=_jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:_jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})});
|
package/lib/esm/utils/isDate.js
CHANGED
package/lib/esm/utils/isEmpty.js
CHANGED
package/lib/esm/utils/isJSON.js
CHANGED
package/lib/esm/utils/jwt.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export const getLocalOrder=key=>localStorage.getItem(key),setLocalOrder=(key,value)=>{localStorage.setItem(key,value)},deleteLocalOrder=key=>{localStorage.removeItem(key)},getSavePaymentSourceToCustomerWallet=()=>localStorage.getItem("_save_payment_source_to_customer_wallet")==="true",getSaveBillingAddressToAddressBook=()=>localStorage.getItem("_save_billing_address_to_customer_address_book")==="true",getSaveShippingAddressToAddressBook=()=>localStorage.getItem("_save_shipping_address_to_customer_address_book")==="true";export function setCustomerOrderParam(key,value){setLocalOrder(key,value)}
|
package/lib/esm/utils/omit.js
CHANGED
package/lib/esm/utils/pick.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import isFunction from"lodash/isFunction";export default async function promisify(cb,params){return await new Promise((resolve,reject)=>{params?cb(params,(err,res)=>{err&&reject(err),resolve(res)}):isFunction(cb?.tokenize)?cb?.tokenize((err,payload)=>{err&&reject(err),resolve(payload)}):cb((err,res)=>{err&&reject(err),resolve(res)})})}
|
package/lib/esm/utils/replace.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export default function scrollbarWidth(){if(typeof document>"u")return 0;const scrollDiv=document.createElement("div");scrollDiv.setAttribute("style","width: 100px; height: 100px; overflow: scroll; position:absolute; top:-9999px;"),document.body.appendChild(scrollDiv);const scrollbarWidth2=scrollDiv.offsetWidth-scrollDiv.clientWidth;return document.body.removeChild(scrollDiv),scrollbarWidth2}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}export function isDoNotShip(lineItems){const itemDoNotShip=[],items=lineItems?lineItems.filter(({item_type})=>item_type==="skus").map(lineItem=>(lineItem.item&&lineItem?.item?.do_not_ship&&itemDoNotShip.push(!0),lineItem)):[];return itemDoNotShip.length>0&&itemDoNotShip.length===items.length}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const val="checked"in v||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.includes(attrName)||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values={...values,[`${v.name}`]:val}}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?{...values,metadata:{...values.metadata,[`${v.name}`]:val}}:{...values,[`${v.name}`]:val})}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};const businessOptionalFields=["billing_address_first_name","billing_address_last_name","shipping_address_first_name","shipping_address_last_name","first_name","last_name"],customerOptionalFields=["billing_address_company","shipping_address_company","company"];export function businessMandatoryField(fieldName,isBusiness){return!(isBusiness&&businessOptionalFields.includes(fieldName)||!isBusiness&&customerOptionalFields.includes(fieldName))}export default validateFormFields;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/react-components",
|
|
3
|
-
"version": "4.5.0-beta.
|
|
3
|
+
"version": "4.5.0-beta.5",
|
|
4
4
|
"description": "The Official Commerce Layer React Components",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -167,14 +167,14 @@
|
|
|
167
167
|
"dependencies": {
|
|
168
168
|
"@ac-dev/countries-service": "^1.2.0",
|
|
169
169
|
"@ac-dev/states-service": "^1.1.1",
|
|
170
|
-
"@adyen/adyen-web": "^5.
|
|
171
|
-
"@commercelayer/sdk": "^5.
|
|
172
|
-
"@stripe/react-stripe-js": "^2.1.
|
|
173
|
-
"@stripe/stripe-js": "^
|
|
174
|
-
"@tanstack/react-table": "^8.9.
|
|
170
|
+
"@adyen/adyen-web": "^5.49.3",
|
|
171
|
+
"@commercelayer/sdk": "^5.10.0",
|
|
172
|
+
"@stripe/react-stripe-js": "^2.1.1",
|
|
173
|
+
"@stripe/stripe-js": "^2.0.0",
|
|
174
|
+
"@tanstack/react-table": "^8.9.3",
|
|
175
175
|
"@types/iframe-resizer": "^3.5.9",
|
|
176
176
|
"axios": "^1.4.0",
|
|
177
|
-
"braintree-web": "^3.
|
|
177
|
+
"braintree-web": "^3.96.1",
|
|
178
178
|
"frames-react": "^1.1.0",
|
|
179
179
|
"iframe-resizer": "^4.3.6",
|
|
180
180
|
"jwt-decode": "^3.1.2",
|
|
@@ -184,30 +184,30 @@
|
|
|
184
184
|
"devDependencies": {
|
|
185
185
|
"@commercelayer/js-auth": "^4.1.1",
|
|
186
186
|
"@faker-js/faker": "^8.0.2",
|
|
187
|
-
"@playwright/test": "^1.
|
|
188
|
-
"@testing-library/dom": "^9.3.
|
|
187
|
+
"@playwright/test": "^1.36.2",
|
|
188
|
+
"@testing-library/dom": "^9.3.1",
|
|
189
189
|
"@testing-library/react": "^14.0.0",
|
|
190
|
-
"@types/braintree-web": "^3.
|
|
191
|
-
"@types/lodash": "^4.14.
|
|
192
|
-
"@types/node": "^20.
|
|
190
|
+
"@types/braintree-web": "^3.94.0",
|
|
191
|
+
"@types/lodash": "^4.14.196",
|
|
192
|
+
"@types/node": "^20.4.8",
|
|
193
193
|
"@types/prop-types": "^15.7.5",
|
|
194
|
-
"@types/react": "^18.2.
|
|
194
|
+
"@types/react": "^18.2.19",
|
|
195
195
|
"@types/react-test-renderer": "^18.0.0",
|
|
196
196
|
"@types/react-window": "^1.8.5",
|
|
197
|
-
"@vitejs/plugin-react": "^4.0.
|
|
198
|
-
"@vitest/coverage-c8": "^0.
|
|
197
|
+
"@vitejs/plugin-react": "^4.0.4",
|
|
198
|
+
"@vitest/coverage-c8": "^0.33.0",
|
|
199
199
|
"jsdom": "^22.1.0",
|
|
200
|
-
"minimize-js": "^1.
|
|
201
|
-
"msw": "^1.2.
|
|
200
|
+
"minimize-js": "^1.4.0",
|
|
201
|
+
"msw": "^1.2.3",
|
|
202
202
|
"react": "^18.2.0",
|
|
203
203
|
"react-dom": "^18.2.0",
|
|
204
204
|
"react-test-renderer": "^18.2.0",
|
|
205
|
-
"tsc-alias": "^1.8.
|
|
206
|
-
"tslib": "^2.
|
|
207
|
-
"typescript": "^5.1.
|
|
208
|
-
"vite": "^4.
|
|
205
|
+
"tsc-alias": "^1.8.7",
|
|
206
|
+
"tslib": "^2.6.1",
|
|
207
|
+
"typescript": "^5.1.6",
|
|
208
|
+
"vite": "^4.4.9",
|
|
209
209
|
"vite-tsconfig-paths": "^4.2.0",
|
|
210
|
-
"vitest": "^0.
|
|
210
|
+
"vitest": "^0.34.1"
|
|
211
211
|
},
|
|
212
212
|
"peerDependencies": {
|
|
213
213
|
"react": "^18.0.0"
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
"coverage:report": "nyc report --reporter=html",
|
|
223
223
|
"build": "tsc -b tsconfig.prod.json tsconfig.prod.esm.json --verbose && pnpm postbuild",
|
|
224
224
|
"build:dev": "tsc -b tsconfig.prod.json tsconfig.prod.esm.json --verbose && tsc-alias -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.esm.json",
|
|
225
|
-
"postbuild": "tsc-alias -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.esm.json && minimize-js lib -w -s",
|
|
225
|
+
"postbuild": "tsc-alias -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.esm.json && minimize-js lib -w -s -b '\"use client\";'",
|
|
226
226
|
"dev": "NODE_OPTIONS='--inspect' next dev"
|
|
227
227
|
}
|
|
228
228
|
}
|