@commercelayer/react-components 4.5.0-beta.2 → 4.5.0-beta.4
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.d.ts +23 -0
- package/lib/cjs/components/customers/MyAccountLink.js +2 -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 +2 -1
- package/lib/cjs/components/orders/AdjustmentAmount.js +1 -0
- package/lib/cjs/components/orders/CartLink.d.ts +23 -0
- package/lib/cjs/components/orders/CartLink.js +2 -1
- package/lib/cjs/components/orders/CheckoutLink.js +2 -1
- package/lib/cjs/components/orders/DiscountAmount.js +1 -0
- package/lib/cjs/components/orders/GiftCardAmount.js +1 -0
- package/lib/cjs/components/orders/HostedCart.d.ts +30 -0
- package/lib/cjs/components/orders/HostedCart.js +2 -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.d.ts +13 -0
- package/lib/cjs/components/orders/PlaceOrderButton.js +2 -1
- 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 +2 -1
- 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.d.ts +27 -2
- 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 +1 -0
- 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.d.ts +5 -0
- package/lib/cjs/utils/events.js +2 -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 +31 -0
- package/lib/cjs/utils/getApplicationLink.js +2 -0
- package/lib/cjs/utils/getCardDetails.js +2 -1
- 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.d.ts +23 -0
- package/lib/esm/components/customers/MyAccountLink.js +2 -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 +2 -1
- package/lib/esm/components/orders/AdjustmentAmount.js +1 -0
- package/lib/esm/components/orders/CartLink.d.ts +23 -0
- package/lib/esm/components/orders/CartLink.js +2 -1
- package/lib/esm/components/orders/CheckoutLink.js +2 -1
- package/lib/esm/components/orders/DiscountAmount.js +1 -0
- package/lib/esm/components/orders/GiftCardAmount.js +1 -0
- package/lib/esm/components/orders/HostedCart.d.ts +30 -0
- package/lib/esm/components/orders/HostedCart.js +2 -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.d.ts +13 -0
- package/lib/esm/components/orders/PlaceOrderButton.js +2 -1
- 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 +2 -1
- 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.d.ts +27 -2
- 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 +1 -0
- 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.d.ts +5 -0
- package/lib/esm/utils/events.js +2 -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 +31 -0
- package/lib/esm/utils/getApplicationLink.js +2 -0
- package/lib/esm/utils/getCardDetails.js +2 -1
- 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 +25 -23
- package/lib/cjs/utils/getCartLink.d.ts +0 -8
- package/lib/cjs/utils/getCartLink.js +0 -1
- package/lib/esm/utils/getCartLink.d.ts +0 -8
- package/lib/esm/utils/getCartLink.js +0 -1
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
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 ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import isEmpty from"lodash/isEmpty";import OrderContext from"../../context/OrderContext";import{getSaveShippingAddressToAddressBook}from"../../utils/localStorage";import{businessMandatoryField}from"../../utils/validateFormFields";export function ShippingAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,shipToDifferentAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address"}),isEmpty(errors)){if(!isEmpty(values)&&shipToDifferentAddress){setAddressErrors([],"shipping_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field?.value||field?.required===!1&&field?.type!=="checkbox")&&(values[name.replace("shipping_address_","")]=field.value,delete values[name]),field?.type==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"shipping_address",value:field.checked}))}setAddress({values:{...values,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})}}else{const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;["shipping_address_state_code"].includes(fieldName)?isEmpty(values.state_code)?delete errors[fieldName]:formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName}):formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName})}shipToDifferentAddress&&setAddressErrors(formErrors,"shipping_address")}const checkboxChecked=ref.current?.querySelector('[name="shipping_address_save_to_customer_book"]')?.checked||getSaveShippingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"shipping_address",value:!1}),ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"shipping_address"),setAddress({values:{},resource:"shipping_address"})))},[values,errors,shipToDifferentAddress,reset,include,includeLoaded,isBusiness]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("shipping_address_","")]:value};setAddress({values:{...values,...field,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})},errorClassName,errors,resetField:name=>{resetForm({currentTarget:ref.current},name)}};return _jsx(ShippingAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default ShippingAddressForm;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import ErrorBoundary from"../utils/ErrorBoundary";export function CommerceLayer(props){const{children,...p}=props;return _jsx(ErrorBoundary,{children:_jsx(CommerceLayerContext.Provider,{value:{...p},children})})}export default CommerceLayer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
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 CustomerAddressFormContext from"../../context/CustomerAddressFormContext";import OrderContext from"../../context/OrderContext";import isEmptyStates from"../../utils/isEmptyStates";export function CustomerAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress}=useContext(AddressesContext),{order}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(Object.keys(errors).length>0){const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message||"";fieldName==="billing_address_state_code"?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")}else if(Object.keys(values).length>0){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];if(field?.value&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),["billing_address_state_code"].includes(name)){const countryCode=values.billing_address_country_code?.value||values.country_code;!isEmptyStates(countryCode)&&!field.value&&delete values.billing_address_state_code}}setAddress({values,resource:"billing_address"})}reset&&(Object.keys(values).length>0||Object.keys(errors).length>0)&&ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"}))},[errors,values,reset]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:{...values,...field},resource:"billing_address"})},errorClassName,requiresBillingInfo:order?.requires_billing_info||!1,errors,resetField:name=>{resetForm({currentTarget:ref.current},name)}};return _jsx(CustomerAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default CustomerAddressForm;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useReducer,useMemo}from"react";import customerReducer,{customerInitialState,getCustomerAddresses,getCustomerOrders,getCustomerPaymentSources,setCustomerEmail,setCustomerErrors,deleteCustomerAddress,createCustomerAddress,saveCustomerUser,getCustomerPayments,getCustomerSubscriptions}from"../../reducers/CustomerReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import CustomerContext from"../../context/CustomerContext";export function CustomerContainer(props){const{children,isGuest=!1}=props,[state,dispatch]=useReducer(customerReducer,customerInitialState),{order,addResourceToInclude,include,updateOrder,includeLoaded,withoutIncludes}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{!include?.includes("available_customer_payment_sources.payment_source")&&!isGuest?addResourceToInclude({newResource:"available_customer_payment_sources.payment_source"}):!includeLoaded?.["available_customer_payment_sources.payment_source"]&&!isGuest&&addResourceToInclude({newResourceLoaded:{"available_customer_payment_sources.payment_source":!0}})},[include?.length,Object.keys(includeLoaded??{}).length]),useEffect(()=>{if(config.accessToken&&state.addresses==null&&!isGuest&&getCustomerAddresses({config,dispatch,isOrderAvailable:withoutIncludes!=null}),order?.available_customer_payment_sources&&!isGuest&&getCustomerPaymentSources({dispatch,order}),config.accessToken&&order==null&&include==null&&includeLoaded==null&&!isGuest){async function getCustomerData(){await getCustomerOrders({config,dispatch}),await getCustomerSubscriptions({config,dispatch}),await getCustomerPayments({config,dispatch})}getCustomerData()}},[config.accessToken,order,isGuest]);const contextValue=useMemo(()=>({isGuest,...state,saveCustomerUser:async customerEmail=>{await saveCustomerUser({config,customerEmail,dispatch,updateOrder,order})},setCustomerErrors:errors=>{setCustomerErrors(errors,dispatch)},setCustomerEmail:customerEmail=>{setCustomerEmail(customerEmail,dispatch)},getCustomerPaymentSources:()=>{getCustomerPaymentSources({dispatch,order})},deleteCustomerAddress:async({customerAddressId})=>{await deleteCustomerAddress({customerAddressId,dispatch,config,addresses:state.addresses})},createCustomerAddress:async address=>{await createCustomerAddress({address,config,dispatch,state})},getCustomerOrders:async({pageNumber,pageSize})=>{await getCustomerOrders({config,dispatch,pageNumber,pageSize})}}),[state,isGuest]);return _jsx(CustomerContext.Provider,{value:contextValue,children})}export default CustomerContainer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import CustomerContext from"../../context/CustomerContext";export function CustomerField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"customers",attribute,tagElement,context:CustomerContext,...p,children})}export default CustomerField;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseInput from"../utils/BaseInput";import{useRapidForm}from"rapid-form";import CustomerContext from"../../context/CustomerContext";export function CustomerInput(props){const{name="customer_email",placeholder="",required=!0,saveOnBlur=!1,type="email",value,onBlur,className,errorClassName,...p}=props,{validation,values,errors}=useRapidForm({fieldEvent:"blur"}),{saveCustomerUser,setCustomerErrors,setCustomerEmail}=useContext(CustomerContext),[hasError,setHasError]=useState(!1),handleOnBlur=async()=>{saveOnBlur&&Object.keys(errors).length===0&&Object.keys(values).length>0&&saveCustomerUser!=null&&(await saveCustomerUser(values[name].value),onBlur&&onBlur(values[name].value))};useEffect(()=>{if(Object.keys(errors).length>0){const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;formErrors.push({code,message:message||"",resource:"orders",field:fieldName})}formErrors.length>0&&(setHasError(!0),setCustomerErrors&&setCustomerErrors(formErrors))}else Object.keys(values).length>0&&(setCustomerErrors&&setCustomerErrors([]),setCustomerEmail&&setCustomerEmail(values[name].value),setHasError(!1));return()=>{setHasError(!1)}},[errors]);const classNameComputed=`${className??""} ${hasError&&errorClassName?errorClassName:""}`;return _jsx(BaseInput,{name,type,ref:validation,required,placeholder,defaultValue:value,onBlur:()=>{handleOnBlur()},className:classNameComputed,...p})}export default CustomerInput;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import CustomerContext from"../../context/CustomerContext";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";import getCardDetails from"../../utils/getCardDetails";import useCustomContext from"../../utils/hooks/useCustomContext";import{useEffect,useState}from"react";export function CustomerPaymentSource({children,loader="Loading..."}){const[loading,setLoading]=useState(!0),{payments}=useCustomContext({context:CustomerContext,contextComponentName:"CustomerContainer",currentComponentName:"CustomerPaymentSource",key:"payments"});useEffect(()=>(payments!=null&&setLoading(!1),()=>{setLoading(!0)}),[payments!=null]);const provider=payments?.filter(p=>p?.payment_source!=null).map(p=>{const paymentType=p.payment_source?.type,value={...getCardDetails({paymentType,customerPayment:p})};return _jsx(CustomerPaymentSourceContext.Provider,{value,children},p.id)});return loading?_jsx(_Fragment,{children:loader}):_jsx(_Fragment,{children:provider})}export default CustomerPaymentSource;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import CustomerContext from"../../context/CustomerContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function CustomerPaymentSourceEmpty({children,emptyText="No payments available",...p}){const{payments}=useCustomContext({context:CustomerContext,contextComponentName:"CustomerContainer",currentComponentName:"CustomerPaymentSourceEmpty",key:"payments"}),parentProps={emptyText,...p};return payments!=null&&payments.length>0||payments===null?null:children!==void 0?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:emptyText})}export default CustomerPaymentSourceEmpty;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ChildrenFunction } from '../../typings/index';
|
|
2
|
+
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
3
|
+
/**
|
|
4
|
+
* The link href
|
|
5
|
+
*/
|
|
6
|
+
href: string;
|
|
7
|
+
/**
|
|
8
|
+
* The link status
|
|
9
|
+
*/
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
|
|
13
|
+
/**
|
|
14
|
+
* A render function to render your own custom component
|
|
15
|
+
*/
|
|
16
|
+
children?: ChildrenFunction<ChildrenProps>;
|
|
17
|
+
/**
|
|
18
|
+
* The label of the link
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function MyAccountLink(props: Props): JSX.Element;
|
|
23
|
+
export default MyAccountLink;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import{getApplicationLink}from"../../utils/getApplicationLink";import{getDomain}from"../../utils/getDomain";import jwt from"../../utils/jwt";export function MyAccountLink(props){const{label="Go to my account",children,...p}=props,{accessToken,endpoint}=useContext(CommerceLayerContext);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyAccountLink` outside of `CommerceLayer`");const{domain,slug}=getDomain(endpoint),disabled=!("owner"in jwt(accessToken)),href=getApplicationLink({slug,accessToken,applicationType:"my-account",domain}),parentProps={disabled,label,href,...p};function handleClick(e){disabled&&e.preventDefault()}return children?_jsx(Parent,{...parentProps,children}):_jsx("a",{"aria-disabled":disabled,onClick:handleClick,href,...p,children:label})}export default MyAccountLink;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ChildrenFunction } from '../../typings/index';
|
|
2
|
+
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
3
|
+
/**
|
|
4
|
+
* The link href
|
|
5
|
+
*/
|
|
6
|
+
href: string;
|
|
7
|
+
}
|
|
8
|
+
interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
|
|
9
|
+
/**
|
|
10
|
+
* A render function to render your own custom component
|
|
11
|
+
*/
|
|
12
|
+
children?: ChildrenFunction<ChildrenProps>;
|
|
13
|
+
/**
|
|
14
|
+
* The label of the link
|
|
15
|
+
*/
|
|
16
|
+
label: string;
|
|
17
|
+
/**
|
|
18
|
+
* The type of the link
|
|
19
|
+
*/
|
|
20
|
+
type: 'login' | 'signup';
|
|
21
|
+
/**
|
|
22
|
+
* The client id of the Commerce Layer application
|
|
23
|
+
*/
|
|
24
|
+
clientId: string;
|
|
25
|
+
/**
|
|
26
|
+
* The scope of the Commerce Layer application
|
|
27
|
+
*/
|
|
28
|
+
scope: string;
|
|
29
|
+
/**
|
|
30
|
+
* The return url to redirect the user after the login/signup
|
|
31
|
+
*/
|
|
32
|
+
returnUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function MyIdentityLink(props: Props): JSX.Element;
|
|
35
|
+
export default MyIdentityLink;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import{getApplicationLink}from"../../utils/getApplicationLink";import{getDomain}from"../../utils/getDomain";export function MyIdentityLink(props){const{label,children,type,clientId,scope,returnUrl,...p}=props,{accessToken,endpoint}=useContext(CommerceLayerContext);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyIdentityLink` outside of `CommerceLayer`");const{domain,slug}=getDomain(endpoint),href=getApplicationLink({slug,accessToken,applicationType:"identity",domain,modeType:type,clientId,scope,returnUrl:returnUrl??window.location.href});console.log("href",href);const parentProps={label,href,clientId,scope,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,children:label})}export default MyIdentityLink;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import isEmpty from"lodash/isEmpty";import CustomerContext from"../../context/CustomerContext";export function SaveCustomerButton(props){const{children,label="Save",resource,disabled,onClick,...p}=props,{errors,saveCustomerUser,customerEmail}=useContext(CustomerContext),disable=disabled||!isEmpty(errors)||isEmpty(customerEmail),handleClick=async()=>{isEmpty(errors)&&!disable&&(saveCustomerUser&&await saveCustomerUser(customerEmail),onClick&&onClick())},parentProps={...p,label,resource,handleClick,disabled:disable};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{type:"button",disabled:disable,onClick:()=>{handleClick()},...p,children:label})}export default SaveCustomerButton;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useMemo}from"react";import Parent from"../utils/Parent";import GiftCardContext from"../../context/GiftCardContext";import OrderContext from"../../context/OrderContext";import AddressContext from"../../context/AddressContext";import getAllErrors from"../utils/getAllErrors";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import CustomerContext from"../../context/CustomerContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import ShipmentContext from"../../context/ShipmentContext";import InStockSubscriptionContext from"../../context/InStockSubscriptionContext";export function Errors(props){const{children,messages=[],resource,field,...p}=props,{payment}=useContext(PaymentMethodChildrenContext),{errors:orderErrors}=useContext(OrderContext),{errors:giftCardErrors}=useContext(GiftCardContext),{errors:lineItemErrors}=useContext(LineItemContext),{errors:addressErrors}=useContext(AddressContext),{errors:customerErrors}=useContext(CustomerContext),{errors:shipmentErrors}=useContext(ShipmentContext),{errors:inStockSubscriptionErrors}=useContext(InStockSubscriptionContext),{errors:paymentMethodErrors,currentPaymentMethodType,currentPaymentMethodId}=useContext(PaymentMethodContext),{lineItem}=useContext(LineItemChildrenContext),allErrors=useMemo(()=>[...giftCardErrors||[],...orderErrors||[],...lineItemErrors||[],...addressErrors||[],...customerErrors||[],...shipmentErrors||[],...inStockSubscriptionErrors||[],...paymentMethodErrors?.filter(v=>v.field===currentPaymentMethodType&&payment?.id===currentPaymentMethodId)||[]],[giftCardErrors,orderErrors,lineItemErrors,addressErrors,customerErrors,shipmentErrors,inStockSubscriptionErrors,paymentMethodErrors]).filter((v,k,a)=>v?.code!==a[k-1]?.code),msgErrors=getAllErrors({allErrors,field,messages,props:p,lineItem,resource,returnHtml:!children}),parentProps={messages,resource,field,errors:msgErrors,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx(_Fragment,{children:msgErrors})}export default Errors;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useRef,useContext}from"react";import validateFormFields from"../../utils/validateFormFields";import isEmpty from"lodash/isEmpty";import GiftCardContext from"../../context/GiftCardContext";export function GiftCard(props){const{children,onSubmit}=props,name="giftCardForm",ref=useRef(null),{addGiftCard,addGiftCardError}=useContext(GiftCardContext);return _jsx(_Fragment,{children:_jsx("form",{name,ref,onSubmit:e=>{e.preventDefault();const currentForm=ref.current,elements=currentForm?.elements,{errors,values}=validateFormFields(elements,["currencyCode","balanceCents"],"gift_cards");isEmpty(errors)?(addGiftCard(values),currentForm?.reset(),onSubmit&&onSubmit(values)):addGiftCardError(errors)},children},name)})}export default GiftCard;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useReducer,useContext}from"react";import GiftCardContext from"../../context/GiftCardContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import giftCardReducer,{giftCardInitialState,addGiftCardRecipient,addGiftCard,addGiftCardError,addGiftCardLoading}from"../../reducers/GiftCardReducer";import OrderContext from"../../context/OrderContext";export function GiftCardContainer(props){const{children}=props,[state,dispatch]=useReducer(giftCardReducer,giftCardInitialState),config=useContext(CommerceLayerContext),{getOrder,createOrder,order}=useContext(OrderContext),giftCardValue={...state,addGiftCardRecipient:async values=>{await addGiftCardRecipient(values,config,dispatch)},addGiftCard:async values=>{await addGiftCard({...values},{config,dispatch,getOrder,createOrder,order})},addGiftCardError:errors=>{addGiftCardError(errors,dispatch)},addGiftCardLoading:loading=>{addGiftCardLoading(loading,dispatch)}};return _jsx(GiftCardContext.Provider,{value:giftCardValue,children})}export default GiftCardContainer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import BaseSelect from"../utils/BaseSelect";import currencyOptions from"../../config/currency";export function GiftCardCurrencySelector(props){return _jsx(BaseSelect,{options:currencyOptions,name:"currencyCode",...props})}export default GiftCardCurrencySelector;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderContext from"../../context/OrderContext";import has from"lodash/has";import isEmpty from"lodash/isEmpty";export function GiftCardOrCouponCode({children,type,...props}){const{order}=useContext(OrderContext);let codeType=type&&`${type}_code`;!type&&order&&has(order,"coupon_code")&&!isEmpty(order.coupon_code)?codeType="coupon_code":type||(codeType="gift_card_code");const code=order&&codeType?order[codeType]:"",hide=!(order&&code),parentProps={...props,code,hide,discountAmountCents:order?.discount_amount_cents,discountAmountFloat:order?.discount_amount_float,formattedDiscountAmount:order?.formatted_discount_amount};return children?_jsx(Parent,{...parentProps,children}):hide?null:_jsx("span",{...props,children:code})}export default GiftCardOrCouponCode;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef,useState}from"react";import CouponAndGiftCardFormContext from"../../context/CouponAndGiftCardFormContext";import OrderContext from"../../context/OrderContext";import isEmpty from"lodash/isEmpty";import camelCase from"lodash/camelCase";import dropWhile from"lodash/dropWhile";import has from"lodash/has";import findIndex from"lodash/findIndex";export function GiftCardOrCouponForm(props){const{children,autoComplete="on",onSubmit,...p}=props,{validation,values,reset}=useRapidForm(),[codeType,setCodeType]=useState("gift_card_or_coupon_code"),{setGiftCardOrCouponCode,order,errors,setOrderErrors}=useContext(OrderContext),ref=useRef(null),inputName="gift_card_or_coupon_code";useEffect(()=>{if(values[inputName]?.value===""&&findIndex(errors,{field:camelCase(inputName)})!==-1){const err=dropWhile(errors,i=>i.field===camelCase(inputName));setOrderErrors(err),onSubmit&&onSubmit({value:values[inputName]?.value,success:!1})}values[inputName]?.value===""&&(setOrderErrors([]),onSubmit&&onSubmit({value:values[inputName]?.value,success:!1}))},[values]),useEffect(()=>{order?.gift_card_code&&!order?.coupon_code&&setCodeType("coupon_code"),!order?.gift_card_code&&order?.coupon_code&&setCodeType("gift_card_code"),!order?.gift_card_code&&!order?.coupon_code&&setCodeType("gift_card_or_coupon_code")},[order]);const handleSubmit=async e=>{e.preventDefault();const code=has(values,inputName)?values[inputName].value:void 0;if(code!=null&&setGiftCardOrCouponCode!=null){const{success,order:order2}=await setGiftCardOrCouponCode({code,codeType}),value=values[inputName]?.value;onSubmit&&onSubmit({success,value,order:order2}),success&&reset(e)}};return order?.gift_card_code&&order?.coupon_code||isEmpty(order)?null:_jsx(CouponAndGiftCardFormContext.Provider,{value:{validation,codeType},children:_jsx("form",{ref,autoComplete,onSubmit:e=>{handleSubmit(e)},...p,children})})}export default GiftCardOrCouponForm;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import BaseInput from"../utils/BaseInput";import CouponAndGiftCardFormContext from"../../context/CouponAndGiftCardFormContext";export function GiftCardOrCouponInput(props){const{placeholder="",required,value,placeholderTranslation,...p}=props,{validation,codeType}=useContext(CouponAndGiftCardFormContext);let placeholderLabel=placeholder;return placeholderTranslation&&codeType&&(placeholderLabel=placeholderTranslation(codeType)),_jsx(BaseInput,{type:"text",name:"gift_card_or_coupon_code",ref:validation,required:required!==void 0?required:!0,placeholder:placeholderLabel,defaultValue:value,...p})}export default GiftCardOrCouponInput;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderContext from"../../context/OrderContext";export function GiftCardOrCouponRemoveButton(props){const{children,label="Remove",onClick,type,...p}=props,{order,removeGiftCardOrCouponCode}=useContext(OrderContext);let codeType=type?`${type}_code`:void 0;!type&&order&&"coupon_code"in order&&order.coupon_code!=null?codeType="coupon_code":type||(codeType="gift_card_code");const code=order&&codeType?order[codeType]:"",hide=!(order&&code),handleClick=async()=>{if(codeType!=null&&removeGiftCardOrCouponCode!=null){const response=await removeGiftCardOrCouponCode({codeType});onClick!=null&&response!=null&&onClick(response)}},parentProps={...p,label,handleClick,codeType};return children?_jsx(Parent,{...parentProps,children}):hide?null:_jsx("button",{type:"button",onClick:()=>{handleClick()},...p,children:label})}export default GiftCardOrCouponRemoveButton;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";export function GiftCardOrCouponSubmit(props){const{children,label="Submit",...p}=props,parentProps={...p,label};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{type:"submit",...p,children:label})}export default GiftCardOrCouponSubmit;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import InStockSubscriptionContext from"../../context/InStockSubscriptionContext";import useCustomContext from"../../utils/hooks/useCustomContext";import jwt from"../../utils/jwt";import{useContext,useState}from"react";export function InStockSubscriptionButton({skuCode,customerEmail,children,onClick,show=!1,label="Subscribe",loadingLabel="Loading...",...props}){const{setInStockSubscription}=useCustomContext({context:InStockSubscriptionContext,contextComponentName:"InStockSubscriptionsContainer",currentComponentName:"InStockSubscriptionButton",key:"setInStockSubscription"}),{accessToken}=useContext(CommerceLayerContext),[loading,setLoading]=useState(!1),handleClick=async()=>{if(accessToken!=null&&customerEmail==null&&jwt(accessToken)?.owner==null){console.error("Missing customerEmail");return}if(setInStockSubscription==null){console.error("Missing <InStockSubscriptionsContainer>");return}setLoading(!0);const res=await setInStockSubscription({customerEmail,skuCode});onClick?.(res),setLoading(!1)};if(children!=null){const parentProps={skuCode,customerEmail,onClick,show,label,loadingLabel,...props};return _jsx(Parent,{...parentProps,children})}return show?_jsx("button",{onClick:()=>{handleClick()},disabled:loading,...props,children:loading?loadingLabel:label}):null}export default InStockSubscriptionButton;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import InStockSubscriptionContext from"../../context/InStockSubscriptionContext";import inStockSubscriptionReducer,{inStockSubscriptionInitialState,setInStockSubscription}from"../../reducers/InStockSubscriptionReducer";import useCustomContext from"../../utils/hooks/useCustomContext";import{useReducer}from"react";export function InStockSubscriptionsContainer({children}){const config=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"InStockSubscriptionsContainer",key:"accessToken"}),[state,dispatch]=useReducer(inStockSubscriptionReducer,inStockSubscriptionInitialState),value={...state,setInStockSubscription:async({customerEmail,skuCode})=>await setInStockSubscription({customerEmail,skuCode,config,dispatch})};return _jsx(InStockSubscriptionContext.Provider,{value,children})}export default InStockSubscriptionsContainer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function LineItem(props){const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),components=(shipmentLineItems&&shipmentLineItems?.length>0?shipmentLineItems:lineItems)?.filter(l=>l?.item_type===type).map((lineItem,k,check)=>{if(lineItem?.item_type==="bundles"&&k>0&&check[k-1]?.bundle_code===lineItem.bundle_code||lineItem?.item_type==="gift_cards"&&lineItem?.total_amount_cents&&lineItem?.total_amount_cents<=0)return null;const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,{value:lineProps,children},lineItem?.id)});return _jsx(_Fragment,{children:components})}export default LineItem;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemAmount(props){const{format="formatted",type="total",...p}=props,{lineItem}=useContext(LineItemChildrenContext),[price,setPrice]=useState("");useEffect(()=>{if(lineItem){const p2=getAmount({base:"amount",type,format,obj:lineItem});setPrice(p2)}return()=>{setPrice("")}},[lineItem]);const parentProps={price,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:price})}export default LineItemAmount;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemCode({type="sku_code",children,...p}){const{lineItem}=useContext(LineItemChildrenContext),labelName=lineItem?.[type],parentProps={lineItem,skuCode:labelName,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("p",{...p,children:labelName})}export default LineItemCode;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function LineItemField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"lineItem",attribute,tagElement,context:LineItemChildrenContext,...p,children})}export default LineItemField;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import{defaultGiftCardImgUrl,defaultImgUrl}from"../../utils/placeholderImages";import Parent from"../utils/Parent";export function LineItemImage(props){const{placeholder,children,...p}=props,{lineItem}=useContext(LineItemChildrenContext),itemType=lineItem?.item_type;let src=lineItem?.image_url;src||(placeholder?.[itemType]?src=placeholder?.[itemType]:src=itemType==="gift_cards"?defaultGiftCardImgUrl:defaultImgUrl);const parenProps={lineItem,src,placeholder,...p};return children?_jsx(Parent,{...parenProps,children}):src?_jsx("img",{"data-testid":`line-item-image-${lineItem?.sku_code??""}`,alt:lineItem?.name??"",src,...p}):null}export default LineItemImage;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemName(props){const{lineItem}=useContext(LineItemChildrenContext),label=lineItem?.name,parentProps={label,lineItem,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("p",{"data-testid":`line-item-name-${lineItem?.sku_code??""}`,...props,children:label})}export default LineItemName;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext}from"react";import LineItemOptionChildrenContext from"../../context/LineItemOptionChildrenContext";import map from"lodash/map";import Parent from"../utils/Parent";import isJSON from"../../utils/isJSON";export function LineItemOption(props){const{name,children,valueClassName,key,tagElement="li",tagContainer="ul",...p}=props,{lineItemOption,showAll}=useContext(LineItemOptionChildrenContext),parentProps={...props,lineItemOption},TagElement=tagElement,TagContainer=tagContainer,label=name!=null?lineItemOption?.options?.[name]:"",components=showAll&&isJSON(JSON.stringify(lineItemOption?.options))?map(lineItemOption?.options,(value,key2)=>_jsxs(TagElement,{...p,children:[`${key2}:`,_jsx("span",{className:valueClassName,children:`${value}`})]},key2)):name!=null&&lineItemOption?.options!=null&&name in lineItemOption.options?_jsxs(TagElement,{...p,children:[`${name}:`,_jsx("span",{className:valueClassName,...p,children:label??""})]},key):null;return children?_jsx(Parent,{...parentProps,children:props.children}):_jsx(TagContainer,{children:components})}export default LineItemOption;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemOptionChildrenContext from"../../context/LineItemOptionChildrenContext";export function LineItemOptions(props){const{skuOptionId,title,children,showName=!0,showAll,className,titleTagElement="h6",titleClassName,...p}=props,{lineItem}=useContext(LineItemChildrenContext),lineItemOptions=lineItem!=null?lineItem?.line_item_options||[]:[],TitleTagElement=titleTagElement,options=lineItemOptions.filter(o=>showAll?!0:o.skuOption().id===skuOptionId).map((o,k)=>{const showTitle=showName?_jsx(TitleTagElement,{className:titleClassName,children:title||o.name}):null,valueProps={lineItemOption:o,showAll};return _jsxs("div",{className,...p,children:[showTitle,_jsx(LineItemOptionChildrenContext.Provider,{value:valueProps,children})]},k)});return _jsx(_Fragment,{children:options})}export default LineItemOptions;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";export function LineItemQuantity(props){const{max=50,readonly=!1,...p}=props,{lineItem}=useContext(LineItemChildrenContext),{updateLineItem}=useContext(LineItemContext),options=[];for(let i=1;i<=max;i++)options.push(_jsx("option",{value:`${i}`,children:i},i));const handleChange=e=>{const quantity2=Number(e.target.value);updateLineItem&&lineItem&&updateLineItem(lineItem.id,quantity2)},quantity=lineItem?.quantity,parentProps={handleChange,quantity,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):readonly?_jsx("span",{...p,children:quantity}):_jsx("select",{"data-testid":lineItem?.sku_code,title:lineItem?.name??"",value:quantity,onChange:handleChange,...p,children:options})}export default LineItemQuantity;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function LineItemRemoveLink(props){const{label="Remove",onClick}=props,{lineItem}=useCustomContext({context:LineItemChildrenContext,contextComponentName:"LineItem",currentComponentName:"LineItemRemoveLink",key:"lineItem"}),{deleteLineItem}=useContext(LineItemContext),handleRemove=e=>{e.preventDefault(),deleteLineItem!=null&&lineItem!=null&&deleteLineItem(lineItem.id),onClick?.(e)},parentProps={handleRemove,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("a",{"data-testid":`line-item-remove-link-${lineItem?.sku_code??""}`,...props,href:"#",onClick:handleRemove,children:label})}export default LineItemRemoveLink;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../../reducers/LineItemReducer";import OrderContext from"../../context/OrderContext";import LineItemContext from"../../context/LineItemContext";import CommerceLayerContext from"../../context/CommerceLayerContext";export function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),useEffect(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue={...state,loader,updateLineItem:async(lineItemId,quantity=1)=>{await updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors})},deleteLineItem:async lineItemId=>{await deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})}};return _jsx(LineItemContext.Provider,{value:lineItemValue,children:state.loading?loader:children})}export default LineItemsContainer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"../utils/Parent";import getLineItemsCount from"../../utils/getLineItemsCount";import LineItemContext from"../../context/LineItemContext";export function LineItemsCount(props){const{children,typeAccepted,...p}=props,{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0);useEffect(()=>{if(lineItems&&lineItems.length>0){const qty=getLineItemsCount({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps={quantity,typeAccepted,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:quantity})}export default LineItemsCount;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"../utils/Parent";import getLineItemsCount from"../../utils/getLineItemsCount";import LineItemContext from"../../context/LineItemContext";export function LineItemsEmpty(props){const{children,text="Your shopping bag is empty",...p}=props,{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(),emptyText=quantity===0?_jsx("span",{...p,children:text}):null;useEffect(()=>{if(lineItems)if(lineItems.length>0){const qty=getLineItemsCount({lineItems:lineItems||[]});setQuantity(qty)}else setQuantity(0);return()=>{setQuantity(void 0)}},[lineItems]);const parentProps={quantity,text,...p};return children?_jsx(Parent,{...parentProps,children}):emptyText}export default LineItemsEmpty;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderContext from"../../context/OrderContext";import SkuListsContext from"../../context/SkuListsContext";import ExternalFunctionContext from"../../context/ExternalFunctionContext";import SkuChildrenContext from"../../context/SkuChildrenContext";import{getApplicationLink}from"../../utils/getApplicationLink";import CommerceLayerContext from"../../context/CommerceLayerContext";import useCustomContext from"../../utils/hooks/useCustomContext";import{getDomain}from"../../utils/getDomain";import{publish}from"../../utils/events";export function AddToCartButton(props){const{label="Add to cart",children,skuCode,bundleCode,skuListId,lineItem,buyNowMode=!1,checkoutUrl,redirectToHostedCart,hostedCartUrl,quantity,lineItemOption,...p}=props,{accessToken,endpoint}=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"AddToCartButton",key:"accessToken"}),{addToCart,orderId,getOrder,setOrderErrors}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"AddToCartButton",key:"addToCart"}),{url,callExternalFunction}=useContext(ExternalFunctionContext),{skuLists}=useContext(SkuListsContext),{sku}=useContext(SkuChildrenContext),sCode=sku?.code??skuCode,handleClick=async()=>{const qty=quantity!=null?parseInt(quantity):1;if(skuLists!=null&&skuListId&&url&&skuListId in skuLists){const lineItems=skuLists?.[skuListId]?.map(skuCode2=>({skuCode:skuCode2,quantity:qty,_update_quantity:1}));return await callExternalFunction({url,data:{resourceType:"orders",inputs:[{id:orderId,lineItems}]}}).then(async res=>(getOrder&&orderId&&await getOrder(orderId),publish("open-cart"),res)).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))}if(!url&&addToCart!=null){const res=await addToCart({bundleCode,skuCode:sCode,quantity:qty,lineItemOption,lineItem,buyNowMode,checkoutUrl});if(redirectToHostedCart&&accessToken!=null&&endpoint!=null){const{slug,domain}=getDomain(endpoint),orderId2=res?.orderId;hostedCartUrl&&orderId2?location.href=`https://${hostedCartUrl}/${orderId2}?accessToken=${accessToken}`:orderId2&&slug&&(location.href=getApplicationLink({orderId:orderId2,slug,accessToken,domain,applicationType:"cart"}))}return publish("open-cart"),res}else if(url)return await callExternalFunction({url,data:{bundleCode,skuCode:sCode,quantity:qty,lineItemOption,lineItem,buyNowMode,checkoutUrl}}).then(async res=>(getOrder&&orderId&&await getOrder(orderId),publish("open-cart"),res)).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))},parentProps={handleClick,label,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{...p,onClick:()=>{handleClick()},children:label})}export default AddToCartButton;
|
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { type MouseEvent, type ReactNode } from 'react';
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
3
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* The url of the cart
|
|
6
|
+
*/
|
|
4
7
|
href: string;
|
|
8
|
+
/**
|
|
9
|
+
* Callback to dispatch the click event
|
|
10
|
+
* @param e: MouseEvent<HTMLAnchorElement>
|
|
11
|
+
* @returns Promise<void>
|
|
12
|
+
*/
|
|
5
13
|
handleClick?: (e: MouseEvent<HTMLAnchorElement>) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* The order id
|
|
16
|
+
*/
|
|
17
|
+
orderId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The access token
|
|
20
|
+
*/
|
|
21
|
+
accessToken?: string;
|
|
6
22
|
}
|
|
7
23
|
interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
|
|
8
24
|
children?: ChildrenFunction<ChildrenProps>;
|
|
25
|
+
/**
|
|
26
|
+
* Label to display
|
|
27
|
+
*/
|
|
9
28
|
label?: string | ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* The type of the cart. Defaults to undefined. If set to 'mini', the cart will open in a modal.
|
|
31
|
+
*/
|
|
32
|
+
type?: 'mini';
|
|
10
33
|
}
|
|
11
34
|
export declare function CartLink(props: Props): JSX.Element | null;
|
|
12
35
|
export default CartLink;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import{getApplicationLink}from"../../utils/getApplicationLink";import{getDomain}from"../../utils/getDomain";import{publish}from"../../utils/events";export function CartLink(props){const{label,children,type,...p}=props,{order,createOrder}=useContext(OrderContext),{accessToken,endpoint}=useContext(CommerceLayerContext);if(accessToken==null)throw new Error("Cannot use `CartLink` outside of `CommerceLayer`");if(endpoint==null)throw new Error("Cannot use `CartLink` outside of `CommerceLayer`");const{domain,slug}=getDomain(endpoint),href=slug&&order?.id?getApplicationLink({slug,orderId:order?.id,accessToken,domain,applicationType:"cart"}):"",handleClick=async event=>{if(event.preventDefault(),type!=="mini")if(order?.id)location.href=href;else{const orderId=await createOrder();slug&&(location.href=getApplicationLink({slug,orderId,accessToken,domain,applicationType:"cart"}))}else publish("open-cart")},parentProps={handleClick,label,href,orderId:order?.id,accessToken,...p};return accessToken?children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,onClick:e=>{handleClick(e)},children:label}):null}export default CartLink;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import{getApplicationLink}from"../../utils/getApplicationLink";import{getDomain}from"../../utils/getDomain";export function CheckoutLink(props){const{label,hostedCheckout=!0,children,...p}=props,{order}=useContext(OrderContext),{accessToken,endpoint}=useContext(CommerceLayerContext);if(accessToken==null||endpoint==null)throw new Error("Cannot use `CheckoutLink` outside of `CommerceLayer`");const{domain,slug}=getDomain(endpoint),href=hostedCheckout&&order?.id?getApplicationLink({slug,orderId:order?.id,accessToken,applicationType:"checkout",domain}):order?.checkout_url??"",parentProps={checkoutUrl:order?.checkout_url,hostedCheckout,label,href,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("a",{href,...p,children:label})}export default CheckoutLink;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
interface Styles {
|
|
3
|
+
cart?: CSSProperties;
|
|
4
|
+
container?: CSSProperties;
|
|
5
|
+
background?: CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
interface Props extends Omit<JSX.IntrinsicElements['div'], 'children' | 'style'> {
|
|
8
|
+
/**
|
|
9
|
+
* The type of the cart. Defaults to undefined.
|
|
10
|
+
*/
|
|
11
|
+
type?: 'mini';
|
|
12
|
+
/**
|
|
13
|
+
* If true, the cart will open when a line item is added to the order clicking the add to cart button. Defaults to false.
|
|
14
|
+
*/
|
|
15
|
+
openAdd?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The style of the cart.
|
|
18
|
+
*/
|
|
19
|
+
style?: Styles;
|
|
20
|
+
/**
|
|
21
|
+
* If true, the cart will be open. Defaults to false.
|
|
22
|
+
*/
|
|
23
|
+
open?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* A function that will be called when the cart is open and the background is clicked.
|
|
26
|
+
*/
|
|
27
|
+
handleOpen?: () => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function HostedCart({ type, openAdd, style, open, handleOpen, ...props }: Props): JSX.Element | null;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import OrderStorageContext from"../../context/OrderStorageContext";import{getApplicationLink}from"../../utils/getApplicationLink";import{getDomain}from"../../utils/getDomain";import useCustomContext from"../../utils/hooks/useCustomContext";import{useContext,useEffect,useState,useRef}from"react";import{iframeResizer}from"iframe-resizer";import{subscribe,unsubscribe}from"../../utils/events";const defaultIframeStyle={width:"1px",minWidth:"100%",minHeight:"100%",border:"none"},defaultContainerStyle={position:"fixed",top:"0",right:"-25rem",height:"100%",width:"23rem",transition:"right 0.5s ease-in-out",zIndex:"0"},defaultBackgroundStyle={opacity:"0",position:"fixed",top:"0",left:"0",height:"100%",width:"100vw",transition:"opacity 0.5s ease-in-out",zIndex:"-10",backgroundColor:"black"},defaultStyle={cart:defaultIframeStyle,container:defaultContainerStyle,background:defaultBackgroundStyle};export function HostedCart({type,openAdd=!1,style=defaultStyle,open=!1,handleOpen,...props}){const[isOpen,setOpen]=useState(!1),ref=useRef(null),{accessToken,endpoint}=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"HostedCart",key:"accessToken"}),[src,setSrc]=useState();if(accessToken==null||endpoint==null)return null;const{order,createOrder}=useContext(OrderContext),{persistKey}=useContext(OrderStorageContext),{domain,slug}=getDomain(endpoint);async function setOrder(openCart){const orderId=localStorage.getItem(persistKey)??await createOrder();orderId!=null&&accessToken!=null&&(setSrc(getApplicationLink({slug,orderId,accessToken,domain,applicationType:"cart"})),openCart&&setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300))}function onMessage(data){switch(data.message.type){case"update":break;case"close":type==="mini"&&(handleOpen!=null?handleOpen():setOpen(!1));break;case"blur":type==="mini"&&isOpen&&ref.current?.focus();break}}return useEffect(()=>{const orderId=localStorage.getItem(persistKey);let ignore=!1;return open!=null&&open!==isOpen&&setOpen(open),openAdd&&type==="mini"&&subscribe("open-cart",()=>{console.log("open-cart by event",src,order?.id,orderId),src==null&&order?.id==null&&orderId==null?setOrder(!0):(src!=null&&ref.current!=null&&(ref.current.src=src),setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300))}),src==null&&order?.id==null&&orderId==null&&accessToken!=null&&!ignore&&isOpen?setOrder():src==null&&(order?.id!=null||orderId!=null)&&setSrc(getApplicationLink({slug,orderId:order?.id??orderId,accessToken,domain,applicationType:"cart"})),src!=null&&ref.current!=null&&(ref.current.src=src),()=>{ignore=!0,openAdd&&type==="mini"&&unsubscribe("open-cart",()=>{})}},[src,open,order?.id]),useEffect(()=>{ref.current!=null&&iframeResizer({checkOrigin:!1,bodyPadding:"20px",onMessage},ref.current)},[ref.current!=null]),src==null?null:type==="mini"?_jsxs(_Fragment,{children:[_jsx("div",{style:{...style.background,opacity:isOpen?"0.5":style.background?.opacity,zIndex:isOpen?"1":style.background?.zIndex},onClick:()=>{handleOpen!=null?handleOpen():setOpen(!1)}}),_jsx("div",{style:{...style.container,right:isOpen?"0":style.container?.right,zIndex:isOpen?"10":style.container?.zIndex},...props,children:_jsx("iframe",{title:"Cart",ref,style:style.cart,src,width:"100%",height:"100%"})})]}):_jsx("iframe",{title:"Cart",ref,style:style.cart,src,width:"100%",height:"100%"})}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext,useMemo,useState}from"react";import orderReducer,{createOrder,getApiOrder,setOrderErrors,setOrder,orderInitialState,updateOrder,addToCart}from"../../reducers/OrderReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext,{defaultOrderContext}from"../../context/OrderContext";import OrderStorageContext from"../../context/OrderStorageContext";import compareObjAttribute from"../../utils/compareObjAttribute";import useCustomContext from"../../utils/hooks/useCustomContext";export function OrderContainer(props){const{orderId,children,metadata,attributes,fetchOrder}=props,[state,dispatch]=useReducer(orderReducer,orderInitialState),[lock,setLock]=useState(!1),[lockOrder,setLockOrder]=useState(!0),config=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"OrderContainer",key:"accessToken"}),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=useContext(OrderStorageContext),localOrder=persistKey?getLocalOrder(persistKey):orderId,getOrder=async()=>{localOrder&&await getApiOrder({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:!!(persistKey&&clearWhenPlaced),deleteLocalOrder,state})};useEffect(()=>{state?.orderId&&(localOrder!=null&&state.orderId!==localOrder?getOrder():dispatch({type:"setOrderId",payload:{orderId:void 0,order:void 0}}))},[persistKey]),useEffect(()=>{state.withoutIncludes||dispatch({type:"setLoading",payload:{loading:!0}})},[state.withoutIncludes]),useEffect(()=>{if(attributes&&state?.order&&!lock){const updateAttributes=compareObjAttribute({attributes,object:state.order});Object.keys(updateAttributes).length>0&&(updateOrder({id:state.order.id,attributes:updateAttributes,dispatch,config,include:state.include,state}),setLock(!0))}return()=>{if(attributes&&state?.order){const updateAttributes=compareObjAttribute({attributes,object:state.order});state.order&&Object.keys(updateAttributes).length===0&&setLock(!1)}}},[attributes,state?.order,lock]),useEffect(()=>{const startRequest=Object.keys(state?.includeLoaded||{}).filter(key=>state?.includeLoaded?.[key]===!0);return config.accessToken&&state.loading===!1&&state?.order==null?(localOrder&&!state.order&&state.include?.length===startRequest.length&&!state.withoutIncludes&&!lockOrder||state.withoutIncludes&&!state.include?.length&&startRequest.length===0)&&getOrder():[config.accessToken,state.order==null,state.loading,state.withoutIncludes].every(Boolean)?dispatch({type:"setLoading",payload:{loading:!1}}):[config.accessToken,state.order==null,state.loading,state.withoutIncludes===!1].every(Boolean)&&dispatch({type:"setLoading",payload:{loading:!1}}),()=>{state.order==null&&state.loading&&state.withoutIncludes===!1&&(state.include?.length===0&&startRequest.length>0?dispatch({type:"setLoading",payload:{loading:!1}}):state.include&&state.include?.length>0&&(dispatch({type:"setIncludesResource",payload:{include:[]}}),setLockOrder(!1)))}},[config.accessToken,Object.keys(state.includeLoaded??{}).length,state.include?.length,orderId,Object.keys(state?.order??{}).length,state.loading,state.withoutIncludes,lockOrder]);const orderValue=useMemo(()=>(fetchOrder!=null&&state?.order!=null&&fetchOrder(state.order),{...state,setOrder:order=>{setOrder(order,dispatch)},getOrder:async id=>await getApiOrder({id,dispatch,config,state}),setOrderErrors:errors=>setOrderErrors({dispatch,errors}),createOrder:async()=>await createOrder({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes,setLocalOrder}),addToCart:async params=>await addToCart({...params,persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder}),saveAddressToCustomerAddressBook:args=>{defaultOrderContext.saveAddressToCustomerAddressBook({...args,dispatch})},setGiftCardOrCouponCode:async({code,codeType})=>await defaultOrderContext.setGiftCardOrCouponCode({code,codeType,dispatch,order:state.order,config,include:state.include,state}),removeGiftCardOrCouponCode:async({codeType})=>await defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include,state}),addResourceToInclude:args=>{defaultOrderContext.addResourceToInclude({...args,dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded})},updateOrder:async args=>await defaultOrderContext.updateOrder({...args,dispatch,config,include:state.include,state})}),[state,config.accessToken,persistKey]);return _jsx(OrderContext.Provider,{value:orderValue,children})}export default OrderContainer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useMemo,useState,useEffect}from"react";import CustomerContext from"../../context/CustomerContext";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import OrderListPagination from"../../context/OrderListPaginationContext";import{useReactTable,getCoreRowModel,getPaginationRowModel,getSortedRowModel,flexRender}from"@tanstack/react-table";import{sortDescIcon,sortAscIcon}from"../../utils/icons";import filterChildren from"../../utils/filterChildren";const rowComponents=["OrderListRow","OrderListEmpty"],paginationComponents=["OrderListPaginationInfo","OrderListPaginationButtons"];export function OrderList({type="orders",children,columns,loadingElement,showActions=!1,showPagination=!1,sortBy=[{id:"number",desc:!0}],pageSize=10,paginationContainerClassName,actionsComponent,actionsContainerClassName,theadClassName,rowTrClassName,...p}){const[loading,setLoading]=useState(!0),[sorting,setSorting]=useState(sortBy),[{pageIndex,pageSize:currentPageSize},setPagination]=useState({pageIndex:0,pageSize}),{orders,subscriptions,getCustomerOrders,getCustomerSubscriptions}=useContext(CustomerContext);useEffect(()=>{type==="orders"&&getCustomerOrders!=null&&getCustomerOrders({pageNumber:pageIndex,pageSize:currentPageSize}),type==="subscriptions"&&getCustomerSubscriptions!=null&&getCustomerSubscriptions({pageNumber:pageIndex,pageSize:currentPageSize})},[pageIndex,currentPageSize]);const data=useMemo(()=>type==="subscriptions"?subscriptions??[]:orders??[],[orders,subscriptions]),cols=useMemo(()=>columns,[columns]),pagination=useMemo(()=>({pageIndex,pageSize:currentPageSize}),[pageIndex,currentPageSize]),pageCount=orders?.pageCount??subscriptions?.pageCount??-1,table=useReactTable({data,columns:cols,getSortedRowModel:getSortedRowModel(),getCoreRowModel:getCoreRowModel(),getPaginationRowModel:getPaginationRowModel(),manualPagination:!0,pageCount,state:{sorting,pagination},onSortingChange:setSorting,onPaginationChange:setPagination}),TableHtmlElement="table",TheadHtmlElement="thead",TbodyHtmlElement="tbody",ThHtmlElement="th",TrHtmlElement="tr";useEffect(()=>(type==="orders"&&orders!=null&&setLoading(!1),type==="subscriptions"&&subscriptions!=null&&setLoading(!1),()=>{setLoading(!0)}),[orders,subscriptions]);const LoadingComponent=loadingElement||_jsx("div",{children:"Loading..."}),headerComponent=table.getHeaderGroups().map(headerGroup=>{const columns2=headerGroup.headers.map((header,k)=>{const sortLabel=header.column.getIsSorted()!==!1?header.column.getIsSorted():"";return _jsx(ThHtmlElement,{"data-testid":`thead-${k}`,"data-sort":`${sortLabel||""}`,children:_jsxs("span",{className:header.column.getCanSort()?"cursor-pointer select-none":"",onClick:header.column.getToggleSortingHandler(),children:[flexRender(header.column.columnDef.header,header.getContext()),{asc:sortAscIcon,desc:sortDescIcon}[header.column.getIsSorted()]??null]})},header.id)});return _jsx(TrHtmlElement,{children:columns2},headerGroup.id)}),rowsComponents=filterChildren({children,filterBy:rowComponents,componentName:"OrderList"}),components=table.getRowModel().rows.map(row=>{const childProps={type,orders:type==="orders"?orders:subscriptions,order:row.original,row,showActions,actionsComponent,actionsContainerClassName};return _jsx(TrHtmlElement,{className:rowTrClassName,children:_jsx(OrderListChildrenContext.Provider,{value:childProps,children:rowsComponents})},row.id)}),pagComponents=filterChildren({children,filterBy:paginationComponents,componentName:"OrderList"}),totalRows=orders?.meta.recordCount??subscriptions?.meta.recordCount??0,Pagination=()=>showPagination?_jsx(OrderListPagination.Provider,{value:{canNextPage:table.getCanNextPage(),canPreviousPage:table.getCanPreviousPage(),gotoPage:table.setPageIndex,nextPage:table.nextPage,pageCount:table.getPageCount(),pageIndex:table.getState().pagination.pageIndex,pageOptions:table.getPageOptions(),pageSize:table.getState().pagination.pageSize,previousPage:table.previousPage,setPageSize:table.setPageSize,totalRows},children:pagComponents}):null;return loading&&(orders==null||subscriptions==null)?_jsx(_Fragment,{children:LoadingComponent}):orders?.length===0||subscriptions?.length===0?_jsxs(OrderListChildrenContext.Provider,{value:{orders:type==="orders"?orders:subscriptions},children:[rowsComponents,_jsx(Pagination,{})]}):_jsxs(_Fragment,{children:[_jsxs(TableHtmlElement,{...p,children:[_jsx(TheadHtmlElement,{className:theadClassName,children:headerComponent}),_jsx(TbodyHtmlElement,{children:components})]}),totalRows<=pageSize?null:_jsx("div",{className:paginationContainerClassName,children:_jsx(Pagination,{})})]})}export default OrderList;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import{useContext}from"react";export function OrderListEmpty(props){const{children,emptyText="No orders available",...p}=props,{orders}=useContext(OrderListChildrenContext),parentProps={emptyText,...p};return orders!=null&&orders.length>0?null:children!==void 0?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:emptyText})}OrderListEmpty.displayName="OrderListEmpty";export default OrderListEmpty;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import Parent from"../utils/Parent";import OrderListPaginationContext from"../../context/OrderListPaginationContext";import useCustomContext from"../../utils/hooks/useCustomContext";import omit from"../../utils/omit";export function OrderListPaginationButtons({previousPageButton,nextPageButton,navigationButtons,children,...props}){const{...prevButton}={show:!0,...previousPageButton},{...nextButton}={show:!0,...nextPageButton},{...navButton}={show:!0,...navigationButtons},ctx=useCustomContext({context:OrderListPaginationContext,contextComponentName:"OrderList",currentComponentName:"OrderListPaginationButtons",key:"totalRows"}),PrevButton=prevButton.show?prevButton.hideWhenDisabled===!0&&ctx?.canPreviousPage===!1?null:_jsx("button",{"data-testid":"prev-button",...omit(prevButton,["show","hideWhenDisabled"]),disabled:ctx?.canPreviousPage===!1,onClick:()=>ctx?.previousPage(),children:previousPageButton?.label??"<"}):null,NextButton=nextButton.show?nextButton.hideWhenDisabled===!0&&ctx?.canNextPage===!1?null:_jsx("button",{"data-testid":"next-button",...omit(nextButton,["show","hideWhenDisabled"]),disabled:ctx?.canNextPage===!1,onClick:()=>ctx?.nextPage(),children:nextButton?.label??">"}):null,pagesToShow=ctx?.canPreviousPage===!1?ctx?.pageOptions.slice(0,3).map(v=>v+1):ctx?.canNextPage===!1?ctx?.pageOptions.slice(ctx?.pageOptions.length-3,ctx?.pageOptions.length).map(v=>v+1):ctx?.pageOptions.slice(ctx?.pageIndex-1,ctx?.pageIndex+2).map(v=>v+1),NavButtons=navButton.show?pagesToShow?.map(v=>{const className=(ctx?.pageIndex!=null?ctx?.pageIndex+1:1)===v?`${navButton?.className??""} ${navButton?.activeClassName??""}`:navButton?.className;return _jsx("button",{"data-testid":`page-${v}`,...omit(navButton,["show","activeClassName","className"]),className,onClick:()=>ctx?.gotoPage(v-1),children:v},`page-${v}`)}):null,parentProps={navigationButtons,prevButton,nextButton,...ctx,...props};return children==null?ctx?.totalRows===0?null:_jsxs("div",{...props,children:[PrevButton,NavButtons,NextButton]}):_jsx(Parent,{...parentProps,children})}OrderListPaginationButtons.displayName="OrderListPaginationButtons";export default OrderListPaginationButtons;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import OrderListPaginationContext from"../../context/OrderListPaginationContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function OrderListPaginationInfo({as="span",children,...props}){const ctx=useCustomContext({context:OrderListPaginationContext,contextComponentName:"OrderList",currentComponentName:"OrderListPaginationInfo",key:"totalRows"}),TagElement=as,totRows=ctx?.totalRows??0,pageIndex=ctx?.pageIndex??0,pageSize=ctx?.pageSize??10;let firstRow=pageIndex===0?pageIndex+1:pageIndex,lastRow=firstRow*pageSize;ctx?.canPreviousPage===!0&&(firstRow=Math.floor(firstRow*pageSize)+1,lastRow=Math.floor(firstRow+pageSize-1)),ctx?.canNextPage===!1&&(lastRow=totRows);const parentProps={...props,as,firstRow,lastRow,totRows};return children==null?totRows===0?null:_jsx(TagElement,{...props,children:`${firstRow} - ${lastRow} of ${totRows}`}):_jsx(Parent,{...parentProps,children})}OrderListPaginationInfo.displayName="OrderListPaginationInfo";export default OrderListPaginationInfo;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{createElement as _createElement}from"react";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import isDate from"../../utils/isDate";import last from"lodash/last";import{flexRender}from"@tanstack/react-table";export function OrderListRow({field,children,...p}){const{order,row,showActions,actionsComponent,actionsContainerClassName}=useContext(OrderListChildrenContext),cell=row?.getVisibleCells().filter(cell2=>cell2.column.id===field),isLastRow=last(row?.getVisibleCells())?.column.id===field,As="td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&_jsx(As,{"data-testid":"action-cell",...p,className:actionsContainerClassName,children:_jsx(Parent,{...parentProps,children:actionsComponent})})||null,parentProps={...p,field,order,row,cell};return children?_jsxs(As,{children:[_jsx(Parent,{...parentProps,children}),_jsx(ActionRow,{})]}):_jsxs(_Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.getValue(),value=isDate(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():flexRender(cell2.column.columnDef.cell,cell2.getContext());return _createElement(As,{"data-testid":`cell-${k}`,...p,key:cell2.id},value)}),_jsx(ActionRow,{})]})}OrderListRow.displayName="OrderListRow";export default OrderListRow;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import OrderStorageContext from"../../context/OrderStorageContext";import{getLocalOrder,setLocalOrder,deleteLocalOrder}from"../../utils/localStorage";export function OrderStorage(props){const{children,clearWhenPlaced=!0,...p}=props;return _jsx(OrderStorageContext.Provider,{value:{...p,setLocalOrder,getLocalOrder,deleteLocalOrder,clearWhenPlaced},children})}export default OrderStorage;
|
|
@@ -3,11 +3,24 @@ import { type ChildrenFunction } from '../../typings/index';
|
|
|
3
3
|
import type { BaseError } from '../../typings/errors';
|
|
4
4
|
import type { Order } from '@commercelayer/sdk';
|
|
5
5
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
6
|
+
/**
|
|
7
|
+
* Callback function to place the order
|
|
8
|
+
*/
|
|
6
9
|
handleClick: () => Promise<void>;
|
|
7
10
|
}
|
|
8
11
|
interface Props extends Omit<JSX.IntrinsicElements['button'], 'children' | 'onClick'> {
|
|
9
12
|
children?: ChildrenFunction<ChildrenProps>;
|
|
13
|
+
/**
|
|
14
|
+
* The label of the button
|
|
15
|
+
*/
|
|
10
16
|
label?: string | ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* If false, the button doesn't place the order automatically. Default: true
|
|
19
|
+
*/
|
|
20
|
+
autoPlaceOrder?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Callback function that is fired when the button is clicked
|
|
23
|
+
*/
|
|
11
24
|
onClick?: (response: {
|
|
12
25
|
placed: boolean;
|
|
13
26
|
order?: Order;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import Parent from"../utils/Parent";import PlaceOrderContext from"../../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import getCardDetails from"../../utils/getCardDetails";export function PlaceOrderButton(props){const ref=useRef(null),{children,label="Place order",autoPlaceOrder=!0,disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType,setButtonRef}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree&&isPermitted||currentPaymentMethodRef?.current?.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,currentPaymentMethodRef?.current?.onsubmit,loading,currentPaymentMethodType,order,paymentSource]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder&&handleClick()},[options?.paypalPayerId,paymentType]),useEffect(()=>{paymentType==="stripe_payments"&&options?.stripe?.redirectStatus==="succeeded"&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder&&handleClick()},[options?.stripe?.redirectStatus,paymentType]),useEffect(()=>{if(order?.status!=null&&["draft","pending"].includes(order?.status))if(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&paymentSource!=null){const attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode,errorCode=res?.payment_response?.errorCode,message=res?.payment_response?.message;["Authorised","Pending","Received"].includes(resultCode)&&autoPlaceOrder?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}else(paymentType==="adyen_payments"&&options?.adyen?.MD&&options?.adyen?.PaRes&&autoPlaceOrder||paymentType==="adyen_payments"&&order?.payment_source?.payment_response?.resultCode==="Authorised"&&ref?.current?.disabled===!1&&autoPlaceOrder)&&handleClick()},[options?.adyen,paymentType,order?.payment_source?.payment_response?.resultCode]),useEffect(()=>{paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder&&handleClick()},[options?.checkoutCom,paymentType]),useEffect(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref]);const handleClick=async e=>{e?.preventDefault(),e?.stopPropagation();let isValid=!0;setForceDisable(!0);const checkPaymentSource=await setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}),card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:checkPaymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit(checkPaymentSource),!isValid&&checkPaymentSource.payment_response?.resultCode==="Authorised"&&(isValid=!0)):card?.brand&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&await setPlaceOrder({paymentSource:checkPaymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps={...p,label,disabled:disabledButton,handleClick,ref};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{ref,type:"button",disabled:disabledButton||forceDisable,onClick:e=>{handleClick(e)},...p,children:isFunction(label)?label():label})}export default PlaceOrderButton;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import PlaceOrderContext from"../../context/PlaceOrderContext";import{useContext,useEffect,useReducer}from"react";import placeOrderReducer,{placeOrderInitialState,placeOrderPermitted,setButtonRef}from"../../reducers/PlaceOrderReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import{setPlaceOrder}from"../../reducers/PlaceOrderReducer";import useCustomContext from"../../utils/hooks/useCustomContext";export function PlaceOrderContainer(props){const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrder,setOrderErrors,include,addResourceToInclude,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PlaceOrderContainer",key:"order"}),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.stock_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.stock_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location"]}),include?.includes("billing_address")?includeLoaded?.billing_address||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address",resourcesIncluded:include}),order&&placeOrderPermitted({config,dispatch,order,options:{...options}})},[order,include,includeLoaded]);const contextValue={...state,setPlaceOrder:async({paymentSource})=>await setPlaceOrder({config,order,state,setOrderErrors,paymentSource,include,setOrder}),placeOrderPermitted:()=>{placeOrderPermitted({config,dispatch,order,options:{...options}})},setButtonRef:ref=>{setButtonRef(ref,dispatch)}};return _jsx(PlaceOrderContext.Provider,{value:contextValue,children})}export default PlaceOrderContainer;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import{useContext,useEffect,useState}from"react";import BaseInput from"../utils/BaseInput";export function PrivacyAndTermsCheckbox(props){const{order}=useContext(OrderContext),{placeOrderPermitted}=useContext(PlaceOrderContext),[forceDisabled,setForceDisabled]=useState(!0),[checked,setChecked]=useState(!1),fieldName="privacy-terms",handleChange=e=>{const v=e.target?.checked;setChecked(v),localStorage.setItem(fieldName,v.toString()),placeOrderPermitted&&placeOrderPermitted()};return useEffect(()=>(order?.privacy_url&&order?.terms_url&&setForceDisabled(!1),checked||localStorage.setItem(fieldName,checked.toString()),()=>{setForceDisabled(!0),localStorage.removeItem(fieldName)}),[order?.privacy_url,order?.terms_url]),_jsx(BaseInput,{type:"checkbox",name:fieldName,disabled:forceDisabled,onChange:handleChange,checked,...props})}export default PrivacyAndTermsCheckbox;
|