@commercelayer/react-components 4.17.0-beta.2 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/cjs/components/ExternalFunction.d.ts +1 -1
- package/lib/cjs/components/MetadataInput.d.ts +1 -0
- package/lib/cjs/components/SubmitButton.d.ts +2 -2
- package/lib/cjs/components/addresses/Address.d.ts +1 -0
- package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +1 -0
- package/lib/cjs/components/addresses/AddressField.d.ts +1 -1
- package/lib/cjs/components/addresses/AddressInput.d.ts +1 -0
- package/lib/cjs/components/addresses/AddressInputSelect.d.ts +1 -0
- package/lib/cjs/components/addresses/AddressStateSelector.d.ts +1 -0
- package/lib/cjs/components/addresses/AddressesContainer.d.ts +1 -1
- package/lib/cjs/components/addresses/AddressesEmpty.d.ts +1 -0
- package/lib/cjs/components/addresses/BillingAddressContainer.d.ts +1 -1
- package/lib/cjs/components/addresses/BillingAddressForm.d.ts +1 -1
- package/lib/cjs/components/addresses/SaveAddressesButton.d.ts +1 -1
- package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +1 -0
- package/lib/cjs/components/addresses/ShippingAddressForm.d.ts +1 -1
- package/lib/cjs/components/auth/CommerceLayer.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerAddressForm.d.ts +1 -1
- package/lib/cjs/components/customers/CustomerContainer.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerField.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerInput.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
- package/lib/cjs/components/customers/MyAccountLink.d.ts +1 -0
- package/lib/cjs/components/customers/MyAccountLink.js +1 -1
- package/lib/cjs/components/customers/MyIdentityLink.d.ts +1 -0
- package/lib/cjs/components/customers/MyIdentityLink.js +1 -1
- package/lib/cjs/components/customers/SaveCustomerButton.d.ts +1 -1
- package/lib/cjs/components/errors/Errors.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCard.d.ts +3 -1
- package/lib/cjs/components/gift_cards/GiftCard.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardContainer.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.d.ts +1 -1
- package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
- package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItem.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemCode.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemField.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemName.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemOption.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemOptions.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemQuantity.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemRemoveLink.d.ts +1 -1
- package/lib/cjs/components/line_items/LineItemsContainer.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +1 -0
- package/lib/cjs/components/orders/AddToCartButton.d.ts +1 -1
- package/lib/cjs/components/orders/AddToCartButton.js +1 -1
- package/lib/cjs/components/orders/AdjustmentAmount.d.ts +1 -0
- package/lib/cjs/components/orders/CartLink.d.ts +1 -1
- package/lib/cjs/components/orders/CartLink.js +1 -1
- package/lib/cjs/components/orders/CheckoutLink.d.ts +1 -0
- package/lib/cjs/components/orders/CheckoutLink.js +1 -1
- package/lib/cjs/components/orders/DiscountAmount.d.ts +1 -0
- package/lib/cjs/components/orders/GiftCardAmount.d.ts +1 -0
- package/lib/cjs/components/orders/HostedCart.d.ts +1 -1
- package/lib/cjs/components/orders/HostedCart.js +1 -1
- package/lib/cjs/components/orders/OrderContainer.d.ts +1 -0
- package/lib/cjs/components/orders/OrderList.d.ts +1 -0
- package/lib/cjs/components/orders/OrderListEmpty.d.ts +1 -0
- package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +1 -0
- package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +1 -0
- package/lib/cjs/components/orders/OrderListRow.d.ts +1 -0
- package/lib/cjs/components/orders/OrderNumber.d.ts +1 -0
- package/lib/cjs/components/orders/OrderStorage.d.ts +1 -1
- package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +1 -0
- package/lib/cjs/components/orders/PlaceOrderButton.d.ts +1 -1
- package/lib/cjs/components/orders/PlaceOrderContainer.d.ts +1 -1
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
- package/lib/cjs/components/orders/ShippingAmount.d.ts +1 -0
- package/lib/cjs/components/orders/SubTotalAmount.d.ts +1 -0
- package/lib/cjs/components/orders/TaxesAmount.d.ts +1 -0
- package/lib/cjs/components/orders/TotalAmount.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelField.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelLineItem.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +1 -0
- package/lib/cjs/components/parcels/Parcels.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelsCount.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.d.ts +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodsContainer.d.ts +1 -1
- package/lib/cjs/components/payment_source/AdyenPayment.d.ts +1 -1
- package/lib/cjs/components/payment_source/BraintreePayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/ExternalPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSource.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceEditButton.d.ts +1 -1
- package/lib/cjs/components/payment_source/PaypalPayment.d.ts +1 -1
- package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/StripePayment.d.ts +2 -1
- package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +1 -0
- package/lib/cjs/components/prices/Price.d.ts +2 -1
- package/lib/cjs/components/prices/PricesContainer.d.ts +1 -0
- package/lib/cjs/components/shipments/Shipment.d.ts +1 -1
- package/lib/cjs/components/shipments/ShipmentField.d.ts +2 -1
- package/lib/cjs/components/shipments/ShipmentsContainer.d.ts +1 -1
- package/lib/cjs/components/shipments/ShipmentsCount.d.ts +2 -1
- package/lib/cjs/components/shipping_methods/ShippingMethod.d.ts +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +2 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +2 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
- package/lib/cjs/components/skus/AvailabilityContainer.d.ts +1 -1
- package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +2 -1
- package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +3 -2
- package/lib/cjs/components/skus/SkuField.d.ts +1 -0
- package/lib/cjs/components/skus/SkuList.d.ts +1 -1
- package/lib/cjs/components/skus/SkuListsContainer.d.ts +1 -1
- package/lib/cjs/components/skus/Skus.d.ts +1 -1
- package/lib/cjs/components/skus/SkusContainer.d.ts +1 -1
- package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +1 -0
- package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +1 -0
- package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -0
- package/lib/cjs/components/utils/BaseField.d.ts +2 -2
- package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
- package/lib/cjs/components/utils/BaseOrderPrice.d.ts +2 -1
- package/lib/cjs/components/utils/ErrorBoundary.d.ts +1 -1
- package/lib/cjs/components/utils/GenericFieldComponent.d.ts +1 -1
- package/lib/cjs/components/utils/Parent.d.ts +1 -1
- package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +1 -0
- package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -0
- package/lib/cjs/components/utils/getAllErrors.d.ts +2 -1
- package/lib/cjs/context/OrderListChildrenContext.d.ts +1 -0
- package/lib/cjs/context/PlaceOrderContext.d.ts +1 -1
- package/lib/cjs/reducers/OrderReducer.js +1 -1
- package/lib/cjs/reducers/PlaceOrderReducer.d.ts +2 -2
- package/lib/cjs/typings/globals.d.ts +1 -0
- package/lib/cjs/typings/index.d.ts +2 -2
- package/lib/cjs/utils/filterChildren.d.ts +1 -0
- package/lib/cjs/utils/getLoaderComponent.d.ts +1 -0
- package/lib/cjs/utils/getPrices.d.ts +1 -0
- package/lib/cjs/utils/organization.js +1 -1
- package/lib/esm/components/ExternalFunction.d.ts +1 -1
- package/lib/esm/components/MetadataInput.d.ts +1 -0
- package/lib/esm/components/SubmitButton.d.ts +2 -2
- package/lib/esm/components/addresses/Address.d.ts +1 -0
- package/lib/esm/components/addresses/AddressCountrySelector.d.ts +1 -0
- package/lib/esm/components/addresses/AddressField.d.ts +1 -1
- package/lib/esm/components/addresses/AddressInput.d.ts +1 -0
- package/lib/esm/components/addresses/AddressInputSelect.d.ts +1 -0
- package/lib/esm/components/addresses/AddressStateSelector.d.ts +1 -0
- package/lib/esm/components/addresses/AddressesContainer.d.ts +1 -1
- package/lib/esm/components/addresses/AddressesEmpty.d.ts +1 -0
- package/lib/esm/components/addresses/BillingAddressContainer.d.ts +1 -1
- package/lib/esm/components/addresses/BillingAddressForm.d.ts +1 -1
- package/lib/esm/components/addresses/SaveAddressesButton.d.ts +1 -1
- package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +1 -0
- package/lib/esm/components/addresses/ShippingAddressForm.d.ts +1 -1
- package/lib/esm/components/auth/CommerceLayer.d.ts +1 -0
- package/lib/esm/components/customers/CustomerAddressForm.d.ts +1 -1
- package/lib/esm/components/customers/CustomerContainer.d.ts +1 -0
- package/lib/esm/components/customers/CustomerField.d.ts +1 -0
- package/lib/esm/components/customers/CustomerInput.d.ts +1 -0
- package/lib/esm/components/customers/CustomerPaymentSource.d.ts +1 -0
- package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
- package/lib/esm/components/customers/MyAccountLink.d.ts +1 -0
- package/lib/esm/components/customers/MyAccountLink.js +1 -1
- package/lib/esm/components/customers/MyIdentityLink.d.ts +1 -0
- package/lib/esm/components/customers/MyIdentityLink.js +1 -1
- package/lib/esm/components/customers/SaveCustomerButton.d.ts +1 -1
- package/lib/esm/components/errors/Errors.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCard.d.ts +3 -1
- package/lib/esm/components/gift_cards/GiftCard.js +1 -1
- package/lib/esm/components/gift_cards/GiftCardContainer.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +1 -1
- package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.d.ts +1 -1
- package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
- package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
- package/lib/esm/components/line_items/LineItem.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemCode.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemField.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemImage.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemName.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemOption.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemOptions.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemQuantity.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemRemoveLink.d.ts +1 -1
- package/lib/esm/components/line_items/LineItemsContainer.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemsEmpty.d.ts +1 -0
- package/lib/esm/components/orders/AddToCartButton.d.ts +1 -1
- package/lib/esm/components/orders/AddToCartButton.js +1 -1
- package/lib/esm/components/orders/AdjustmentAmount.d.ts +1 -0
- package/lib/esm/components/orders/CartLink.d.ts +1 -1
- package/lib/esm/components/orders/CartLink.js +1 -1
- package/lib/esm/components/orders/CheckoutLink.d.ts +1 -0
- package/lib/esm/components/orders/CheckoutLink.js +1 -1
- package/lib/esm/components/orders/DiscountAmount.d.ts +1 -0
- package/lib/esm/components/orders/GiftCardAmount.d.ts +1 -0
- package/lib/esm/components/orders/HostedCart.d.ts +1 -1
- package/lib/esm/components/orders/HostedCart.js +1 -1
- package/lib/esm/components/orders/OrderContainer.d.ts +1 -0
- package/lib/esm/components/orders/OrderList.d.ts +1 -0
- package/lib/esm/components/orders/OrderListEmpty.d.ts +1 -0
- package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +1 -0
- package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +1 -0
- package/lib/esm/components/orders/OrderListRow.d.ts +1 -0
- package/lib/esm/components/orders/OrderNumber.d.ts +1 -0
- package/lib/esm/components/orders/OrderStorage.d.ts +1 -1
- package/lib/esm/components/orders/PaymentMethodAmount.d.ts +1 -0
- package/lib/esm/components/orders/PlaceOrderButton.d.ts +1 -1
- package/lib/esm/components/orders/PlaceOrderContainer.d.ts +1 -1
- package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
- package/lib/esm/components/orders/ShippingAmount.d.ts +1 -0
- package/lib/esm/components/orders/SubTotalAmount.d.ts +1 -0
- package/lib/esm/components/orders/TaxesAmount.d.ts +1 -0
- package/lib/esm/components/orders/TotalAmount.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelField.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelLineItem.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelLineItemField.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +1 -0
- package/lib/esm/components/parcels/Parcels.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelsCount.d.ts +1 -0
- package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -0
- package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodRadioButton.d.ts +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodsContainer.d.ts +1 -1
- package/lib/esm/components/payment_source/AdyenPayment.d.ts +1 -1
- package/lib/esm/components/payment_source/BraintreePayment.d.ts +1 -0
- package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/ExternalPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSource.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSourceEditButton.d.ts +1 -1
- package/lib/esm/components/payment_source/PaypalPayment.d.ts +1 -1
- package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/StripePayment.d.ts +2 -1
- package/lib/esm/components/payment_source/WireTransferPayment.d.ts +1 -0
- package/lib/esm/components/prices/Price.d.ts +2 -1
- package/lib/esm/components/prices/PricesContainer.d.ts +1 -0
- package/lib/esm/components/shipments/Shipment.d.ts +1 -1
- package/lib/esm/components/shipments/ShipmentField.d.ts +2 -1
- package/lib/esm/components/shipments/ShipmentsContainer.d.ts +1 -1
- package/lib/esm/components/shipments/ShipmentsCount.d.ts +2 -1
- package/lib/esm/components/shipping_methods/ShippingMethod.d.ts +1 -1
- package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +2 -1
- package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +2 -1
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
- package/lib/esm/components/skus/AvailabilityContainer.d.ts +1 -1
- package/lib/esm/components/skus/AvailabilityTemplate.d.ts +2 -1
- package/lib/esm/components/skus/DeliveryLeadTime.d.ts +3 -2
- package/lib/esm/components/skus/SkuField.d.ts +1 -0
- package/lib/esm/components/skus/SkuList.d.ts +1 -1
- package/lib/esm/components/skus/SkuListsContainer.d.ts +1 -1
- package/lib/esm/components/skus/Skus.d.ts +1 -1
- package/lib/esm/components/skus/SkusContainer.d.ts +1 -1
- package/lib/esm/components/stock_transfers/StockTransfer.d.ts +1 -0
- package/lib/esm/components/stock_transfers/StockTransferField.d.ts +1 -0
- package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -0
- package/lib/esm/components/utils/BaseField.d.ts +2 -2
- package/lib/esm/components/utils/BaseInput.d.ts +1 -1
- package/lib/esm/components/utils/BaseOrderPrice.d.ts +2 -1
- package/lib/esm/components/utils/ErrorBoundary.d.ts +1 -1
- package/lib/esm/components/utils/GenericFieldComponent.d.ts +1 -1
- package/lib/esm/components/utils/Parent.d.ts +1 -1
- package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +1 -0
- package/lib/esm/components/utils/PriceTemplate.d.ts +1 -0
- package/lib/esm/components/utils/getAllErrors.d.ts +2 -1
- package/lib/esm/context/OrderListChildrenContext.d.ts +1 -0
- package/lib/esm/context/PlaceOrderContext.d.ts +1 -1
- package/lib/esm/reducers/OrderReducer.js +1 -1
- package/lib/esm/reducers/PlaceOrderReducer.d.ts +2 -2
- package/lib/esm/typings/globals.d.ts +1 -0
- package/lib/esm/typings/index.d.ts +2 -2
- package/lib/esm/utils/filterChildren.d.ts +1 -0
- package/lib/esm/utils/getLoaderComponent.d.ts +1 -0
- package/lib/esm/utils/getPrices.d.ts +1 -0
- package/lib/esm/utils/organization.js +1 -1
- package/package.json +27 -27
package/README.md
CHANGED
|
@@ -47,9 +47,9 @@ You can check [our documentation](https://docs.commercelayer.io/api/authenticati
|
|
|
47
47
|
|
|
48
48
|
## Need help?
|
|
49
49
|
|
|
50
|
-
- Join [Commerce Layer's
|
|
50
|
+
- Join [Commerce Layer's Discord community](https://discord.gg/commercelayer).
|
|
51
51
|
- Open a new [Q&A discussion](https://github.com/commercelayer/commercelayer-react-components/discussions/categories/q-a)
|
|
52
|
-
- Ping us
|
|
52
|
+
- Ping us on [Bluesky](https://bsky.app/profile/commercelayer.io), [X (formerly Twitter)](https://x.com/commercelayer), or [LinkedIn](https://www.linkedin.com/company/commerce-layer).
|
|
53
53
|
- Is there a bug? Create an [issue](https://github.com/commercelayer/commercelayer-react-components/issues) on this repository.
|
|
54
54
|
|
|
55
55
|
### License
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BaseInputComponentProps } from '../typings/index';
|
|
2
|
+
import type { JSX } from "react";
|
|
2
3
|
type Props = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
|
|
3
4
|
export declare function MetadataInput(props: Props): JSX.Element;
|
|
4
5
|
export default MetadataInput;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode, type JSX } from 'react';
|
|
2
2
|
import { type ChildrenFunction } from '../typings/index';
|
|
3
3
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
4
|
}
|
|
5
|
-
interface Props extends Omit<JSX.IntrinsicElements['button'], 'children'> {
|
|
5
|
+
interface Props extends Omit<JSX.IntrinsicElements['button'], 'children' | 'ref'> {
|
|
6
6
|
children?: ChildrenFunction<ChildrenProps>;
|
|
7
7
|
label?: string | ReactNode;
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode, type JSX } from 'react';
|
|
2
2
|
import { type AddressFieldView } from '../../reducers/AddressReducer';
|
|
3
3
|
import type { Address } from '@commercelayer/sdk';
|
|
4
4
|
import { type ChildrenFunction } from '../../typings/index';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JSX } from 'react';
|
|
1
2
|
import { type BaseSelectComponentProps } from '../../typings/index';
|
|
2
3
|
import { type AddressValuesKeys } from '../../context/BillingAddressFormContext';
|
|
3
4
|
type SelectFieldName = `billing_address_${`metadata_${string}`}` | `shipping_address_${`metadata_${string}`}`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ConditionalElement } from '../../typings/index';
|
|
2
2
|
import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
|
|
3
|
+
import type { JSX } from "react";
|
|
3
4
|
type StockTransferFieldChildrenProps = TGenericChildrenProps<TResources['Customer']>;
|
|
4
5
|
type TCondition = ConditionalElement<Exclude<TResources['Customer'], 'resource'>>;
|
|
5
6
|
type Props = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MyAccountLink=MyAccountLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),jwt_1=require("../../utils/jwt"),organization_1=require("../../utils/organization");function MyAccountLink(props){const{label="Go to my account",children,customDomain}=props,p=tslib_1.__rest(props,["label","children","customDomain"]),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyAccountLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint),disabled=!("owner"in(0,jwt_1.jwt)(accessToken)),href=(0,getApplicationLink_1.getApplicationLink)({slug,accessToken,applicationType:"my-account",domain,customDomain}),parentProps=Object.assign({disabled,label,href},p);function handleClick(e){!disabled&&accessToken&&endpoint&&(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken}}).then(config=>{var _a;!((_a=config?.links)===null||_a===void 0)&&_a.my_account&&(e.preventDefault(),location.href=config.links.my_account)})}return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({"aria-disabled":disabled,onClick:handleClick,href},p,{children:label}))}exports.default=MyAccountLink;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MyAccountLink=MyAccountLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),jwt_1=require("../../utils/jwt"),organization_1=require("../../utils/organization");function MyAccountLink(props){const{label="Go to my account",children,customDomain}=props,p=tslib_1.__rest(props,["label","children","customDomain"]),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyAccountLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint),disabled=!("owner"in(0,jwt_1.jwt)(accessToken)),href=(0,getApplicationLink_1.getApplicationLink)({slug,accessToken,applicationType:"my-account",domain,customDomain}),parentProps=Object.assign({disabled,label,href},p);function handleClick(e){!disabled&&accessToken&&endpoint&&(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken,slug}}).then(config=>{var _a;!((_a=config?.links)===null||_a===void 0)&&_a.my_account&&(e.preventDefault(),location.href=config.links.my_account)})}return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({"aria-disabled":disabled,onClick:handleClick,href},p,{children:label}))}exports.default=MyAccountLink;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MyIdentityLink=MyIdentityLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),organization_1=require("../../utils/organization");function MyIdentityLink(props){const{label,children,type,clientId,scope,returnUrl,customDomain,resetPasswordUrl}=props,p=tslib_1.__rest(props,["label","children","type","clientId","scope","returnUrl","customDomain","resetPasswordUrl"]),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default),[href,setHref]=(0,react_1.useState)(void 0);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyIdentityLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint);(0,react_1.useEffect)(()=>(accessToken&&endpoint&&(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken}}).then(config=>{var _a;if(!((_a=config?.links)===null||_a===void 0)&&_a.identity)setHref(config.links.identity);else{const link=(0,getApplicationLink_1.getApplicationLink)({slug,accessToken,applicationType:"identity",domain,modeType:type,clientId,scope,returnUrl:returnUrl??window.location.href,resetPasswordUrl,customDomain});setHref(link)}}),()=>{setHref(void 0)}),[accessToken,endpoint]);const parentProps=Object.assign({label,href,clientId,scope},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href},p,{children:label}))}exports.default=MyIdentityLink;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MyIdentityLink=MyIdentityLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),organization_1=require("../../utils/organization");function MyIdentityLink(props){const{label,children,type,clientId,scope,returnUrl,customDomain,resetPasswordUrl}=props,p=tslib_1.__rest(props,["label","children","type","clientId","scope","returnUrl","customDomain","resetPasswordUrl"]),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default),[href,setHref]=(0,react_1.useState)(void 0);if(accessToken==null||endpoint==null)throw new Error("Cannot use `MyIdentityLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint);(0,react_1.useEffect)(()=>(accessToken&&endpoint&&(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken,slug}}).then(config=>{var _a;if(!((_a=config?.links)===null||_a===void 0)&&_a.identity)setHref(config.links.identity);else{const link=(0,getApplicationLink_1.getApplicationLink)({slug,accessToken,applicationType:"identity",domain,modeType:type,clientId,scope,returnUrl:returnUrl??window.location.href,resetPasswordUrl,customDomain});setHref(link)}}),()=>{setHref(void 0)}),[accessToken,endpoint]);const parentProps=Object.assign({label,href,clientId,scope},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href},p,{children:label}))}exports.default=MyIdentityLink;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JSX } from 'react';
|
|
1
2
|
import type { CodeErrorType } from '../../typings/errors';
|
|
2
3
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
4
|
export type TResourceError = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipments' | 'shipping_address' | 'customer_address' | 'sku_options' | 'variant' | 'in_stock_subscriptions';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { type RefObject, type JSX } from 'react';
|
|
1
2
|
import { type BaseState } from '../../typings/index';
|
|
2
3
|
import type { DefaultChildrenType } from '../../typings/globals';
|
|
3
|
-
interface Props extends Omit<JSX.IntrinsicElements['form'], 'children'> {
|
|
4
|
+
interface Props extends Omit<JSX.IntrinsicElements['form'], 'children' | 'ref'> {
|
|
4
5
|
children: DefaultChildrenType;
|
|
5
6
|
onSubmit?: (values: BaseState) => void;
|
|
7
|
+
ref?: RefObject<HTMLFormElement | null>;
|
|
6
8
|
}
|
|
7
9
|
export declare function GiftCard(props: Props): JSX.Element;
|
|
8
10
|
export default GiftCard;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GiftCard=GiftCard;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),validateFormFields_1=tslib_1.__importDefault(require("../../utils/validateFormFields")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),GiftCardContext_1=tslib_1.__importDefault(require("../../context/GiftCardContext"));function GiftCard(props){const{children,onSubmit}=props,name="giftCardForm",ref=(0,react_1.useRef)(null),{addGiftCard,addGiftCardError}=(0,react_1.useContext)(GiftCardContext_1.default),handleSubmit=e=>{e.preventDefault();const currentForm=ref.current,elements=currentForm?.elements,{errors,values}=(0,validateFormFields_1.default)(elements,["currencyCode","balanceCents"],"gift_cards");(0,isEmpty_1.default)(errors)?(addGiftCard(values),currentForm?.reset(),onSubmit&&onSubmit(values)):addGiftCardError(errors)};return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:(0,jsx_runtime_1.jsx)("form",{name,
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GiftCard=GiftCard;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),validateFormFields_1=tslib_1.__importDefault(require("../../utils/validateFormFields")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),GiftCardContext_1=tslib_1.__importDefault(require("../../context/GiftCardContext"));function GiftCard(props){const{children,onSubmit}=props,name="giftCardForm",ref=(0,react_1.useRef)(null),{addGiftCard,addGiftCardError}=(0,react_1.useContext)(GiftCardContext_1.default),handleSubmit=e=>{e.preventDefault();const currentForm=ref.current,elements=currentForm?.elements,{errors,values}=(0,validateFormFields_1.default)(elements,["currencyCode","balanceCents"],"gift_cards");(0,isEmpty_1.default)(errors)?(addGiftCard(values),currentForm?.reset(),onSubmit&&onSubmit(values)):addGiftCardError(errors)};return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:(0,jsx_runtime_1.jsx)("form",{name,onSubmit:handleSubmit,children},name)})}exports.default=GiftCard;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BaseInputComponentProps, type GiftCardInputName } from '../../typings/index';
|
|
2
|
+
import type { JSX } from "react";
|
|
2
3
|
type Props = {
|
|
3
4
|
name: GiftCardInputName;
|
|
4
5
|
} & Omit<BaseInputComponentProps, 'name'> & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode, type JSX } from 'react';
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
3
|
import { type CodeType, type OrderCodeType } from '../../reducers/OrderReducer';
|
|
4
4
|
import type { Order } from '@commercelayer/sdk';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ConditionalElement } from '../../typings/index';
|
|
2
2
|
import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
|
|
3
|
+
import type { JSX } from "react";
|
|
3
4
|
type LineItemFieldChildrenProps = TGenericChildrenProps<TResources['LineItem']>;
|
|
4
5
|
type TCondition = ConditionalElement<Exclude<TResources['LineItem'], 'resource'>>;
|
|
5
6
|
type Props = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CSSProperties } from 'react';
|
|
1
|
+
import { type CSSProperties, type JSX } from 'react';
|
|
2
2
|
import { type LineItemOption as LineItemOptionType } from '@commercelayer/sdk';
|
|
3
3
|
import { type ChildrenFunction } from '../../typings/index';
|
|
4
4
|
export interface TLineItemOption extends Omit<Props, 'children'> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PropsWithoutRef } from 'react';
|
|
1
|
+
import { type PropsWithoutRef, type JSX } from 'react';
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
3
|
import { type LineItem } from '@commercelayer/sdk';
|
|
4
4
|
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PropsWithoutRef } from 'react';
|
|
1
|
+
import { type PropsWithoutRef, type JSX } from 'react';
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
3
|
import { type AddToCartReturn, type CustomLineItem, type LineItemOption } from '../../reducers/OrderReducer';
|
|
4
4
|
interface TAddToCartButton extends Omit<Props, 'children'> {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AddToCartButton=AddToCartButton;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),SkuListsContext_1=tslib_1.__importDefault(require("../../context/SkuListsContext")),ExternalFunctionContext_1=tslib_1.__importDefault(require("../../context/ExternalFunctionContext")),SkuChildrenContext_1=tslib_1.__importDefault(require("../../context/SkuChildrenContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext")),getDomain_1=require("../../utils/getDomain"),events_1=require("../../utils/events"),organization_1=require("../../utils/organization");function AddToCartButton(props){var _a;const{label="Add to cart",children,skuCode,bundleCode,skuListId,lineItem,buyNowMode=!1,checkoutUrl,redirectToHostedCart,hostedCartUrl,quantity,lineItemOption,protocol="https"}=props,p=tslib_1.__rest(props,["label","children","skuCode","bundleCode","skuListId","lineItem","buyNowMode","checkoutUrl","redirectToHostedCart","hostedCartUrl","quantity","lineItemOption","protocol"]),{accessToken,endpoint}=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"AddToCartButton",key:"accessToken"}),{addToCart,orderId,getOrder,setOrderErrors}=(0,useCustomContext_1.default)({context:OrderContext_1.default,contextComponentName:"OrderContainer",currentComponentName:"AddToCartButton",key:"addToCart"}),{url,callExternalFunction}=(0,react_1.useContext)(ExternalFunctionContext_1.default),{skuLists}=(0,react_1.useContext)(SkuListsContext_1.default),{sku}=(0,react_1.useContext)(SkuChildrenContext_1.default),sCode=(_a=sku?.code)!==null&&_a!==void 0?_a:skuCode,handleClick=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a2,_b,_c;const qty=quantity!=null?parseInt(quantity):1;if(skuLists!=null&&skuListId&&url&&skuListId in skuLists){const lineItems=(_a2=skuLists?.[skuListId])===null||_a2===void 0?void 0:_a2.map(skuCode2=>({skuCode:skuCode2,quantity:qty,_update_quantity:1}));return yield callExternalFunction({url,data:{resourceType:"orders",inputs:[{id:orderId,lineItems}]}}).then(res=>tslib_1.__awaiter(this,void 0,void 0,function*(){return getOrder&&orderId&&(yield getOrder(orderId)),buyNowMode||(0,events_1.publish)("open-cart"),res})).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))}if(!url&&addToCart!=null){const res=yield addToCart({bundleCode,skuCode:sCode,quantity:qty,lineItemOption,lineItem,buyNowMode,checkoutUrl});if(redirectToHostedCart&&accessToken!=null&&endpoint!=null){const{slug,domain}=(0,getDomain_1.getDomain)(endpoint),orderId2=res?.orderId;if(hostedCartUrl&&orderId2)location.href=`${protocol}://${hostedCartUrl}/${orderId2}?accessToken=${accessToken}`;else if(orderId2&&slug){const config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:orderId2,accessToken}});location.href=(_c=(_b=config?.links)===null||_b===void 0?void 0:_b.cart)!==null&&_c!==void 0?_c:(0,getApplicationLink_1.getApplicationLink)({orderId:orderId2,slug,accessToken,domain,applicationType:"cart"})}}return res}else if(url)return yield callExternalFunction({url,data:{bundleCode,skuCode:sCode,quantity:qty,lineItemOption,lineItem,buyNowMode,checkoutUrl}}).then(res=>tslib_1.__awaiter(this,void 0,void 0,function*(){return getOrder&&orderId&&(yield getOrder(orderId)),buyNowMode||(0,events_1.publish)("open-cart"),res})).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))}),parentProps=Object.assign({handleClick,label},props);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("button",Object.assign({},p,{onClick:()=>{handleClick()},children:label}))}exports.default=AddToCartButton;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AddToCartButton=AddToCartButton;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),SkuListsContext_1=tslib_1.__importDefault(require("../../context/SkuListsContext")),ExternalFunctionContext_1=tslib_1.__importDefault(require("../../context/ExternalFunctionContext")),SkuChildrenContext_1=tslib_1.__importDefault(require("../../context/SkuChildrenContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext")),getDomain_1=require("../../utils/getDomain"),events_1=require("../../utils/events"),organization_1=require("../../utils/organization");function AddToCartButton(props){var _a;const{label="Add to cart",children,skuCode,bundleCode,skuListId,lineItem,buyNowMode=!1,checkoutUrl,redirectToHostedCart,hostedCartUrl,quantity,lineItemOption,protocol="https"}=props,p=tslib_1.__rest(props,["label","children","skuCode","bundleCode","skuListId","lineItem","buyNowMode","checkoutUrl","redirectToHostedCart","hostedCartUrl","quantity","lineItemOption","protocol"]),{accessToken,endpoint}=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"AddToCartButton",key:"accessToken"}),{addToCart,orderId,getOrder,setOrderErrors}=(0,useCustomContext_1.default)({context:OrderContext_1.default,contextComponentName:"OrderContainer",currentComponentName:"AddToCartButton",key:"addToCart"}),{url,callExternalFunction}=(0,react_1.useContext)(ExternalFunctionContext_1.default),{skuLists}=(0,react_1.useContext)(SkuListsContext_1.default),{sku}=(0,react_1.useContext)(SkuChildrenContext_1.default),sCode=(_a=sku?.code)!==null&&_a!==void 0?_a:skuCode,handleClick=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a2,_b,_c;const qty=quantity!=null?parseInt(quantity):1;if(skuLists!=null&&skuListId&&url&&skuListId in skuLists){const lineItems=(_a2=skuLists?.[skuListId])===null||_a2===void 0?void 0:_a2.map(skuCode2=>({skuCode:skuCode2,quantity:qty,_update_quantity:1}));return yield callExternalFunction({url,data:{resourceType:"orders",inputs:[{id:orderId,lineItems}]}}).then(res=>tslib_1.__awaiter(this,void 0,void 0,function*(){return getOrder&&orderId&&(yield getOrder(orderId)),buyNowMode||(0,events_1.publish)("open-cart"),res})).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))}if(!url&&addToCart!=null){const res=yield addToCart({bundleCode,skuCode:sCode,quantity:qty,lineItemOption,lineItem,buyNowMode,checkoutUrl});if(redirectToHostedCart&&accessToken!=null&&endpoint!=null){const{slug,domain}=(0,getDomain_1.getDomain)(endpoint),orderId2=res?.orderId;if(hostedCartUrl&&orderId2)location.href=`${protocol}://${hostedCartUrl}/${orderId2}?accessToken=${accessToken}`;else if(orderId2&&slug){const config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:orderId2,accessToken,slug}});location.href=(_c=(_b=config?.links)===null||_b===void 0?void 0:_b.cart)!==null&&_c!==void 0?_c:(0,getApplicationLink_1.getApplicationLink)({orderId:orderId2,slug,accessToken,domain,applicationType:"cart"})}}return res}else if(url)return yield callExternalFunction({url,data:{bundleCode,skuCode:sCode,quantity:qty,lineItemOption,lineItem,buyNowMode,checkoutUrl}}).then(res=>tslib_1.__awaiter(this,void 0,void 0,function*(){return getOrder&&orderId&&(yield getOrder(orderId)),buyNowMode||(0,events_1.publish)("open-cart"),res})).catch(({response})=>(setOrderErrors&&setOrderErrors(response.data),response))}),parentProps=Object.assign({handleClick,label},props);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("button",Object.assign({},p,{onClick:()=>{handleClick()},children:label}))}exports.default=AddToCartButton;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CartLink=CartLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),events_1=require("../../utils/events"),organization_1=require("../../utils/organization");function CartLink(props){const{label,children,type,customDomain}=props,p=tslib_1.__rest(props,["label","children","type","customDomain"]),{order,createOrder}=(0,react_1.useContext)(OrderContext_1.default),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);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}=(0,getDomain_1.getDomain)(endpoint),href=slug&&order?.id?(0,getApplicationLink_1.getApplicationLink)({slug,orderId:order?.id,accessToken,domain,applicationType:"cart",customDomain}):void 0,handleClick=event=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e;if(event.preventDefault(),type!=="mini")if(order?.id){const config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken}});location.href=(_c=(_b=(_a=config?.links)===null||_a===void 0?void 0:_a.cart)!==null&&_b!==void 0?_b:href)!==null&&_c!==void 0?_c:""}else{const orderId=yield createOrder({}),config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken}});slug&&(location.href=(_e=(_d=config?.links)===null||_d===void 0?void 0:_d.cart)!==null&&_e!==void 0?_e:(0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain}))}else(0,events_1.publish)("open-cart")}),parentProps=Object.assign({handleClick,label,href,orderId:order?.id,accessToken},p);return accessToken?children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href,onClick:e=>{handleClick(e)}},p,{children:label})):null}exports.default=CartLink;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CartLink=CartLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),events_1=require("../../utils/events"),organization_1=require("../../utils/organization");function CartLink(props){const{label,children,type,customDomain}=props,p=tslib_1.__rest(props,["label","children","type","customDomain"]),{order,createOrder}=(0,react_1.useContext)(OrderContext_1.default),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);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}=(0,getDomain_1.getDomain)(endpoint),href=slug&&order?.id?(0,getApplicationLink_1.getApplicationLink)({slug,orderId:order?.id,accessToken,domain,applicationType:"cart",customDomain}):void 0,handleClick=event=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a,_b,_c,_d,_e;if(event.preventDefault(),type!=="mini")if(order?.id){const config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken,slug}});location.href=(_c=(_b=(_a=config?.links)===null||_a===void 0?void 0:_a.cart)!==null&&_b!==void 0?_b:href)!==null&&_c!==void 0?_c:""}else{const orderId=yield createOrder({}),config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken,slug}});slug&&(location.href=(_e=(_d=config?.links)===null||_d===void 0?void 0:_d.cart)!==null&&_e!==void 0?_e:(0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain}))}else(0,events_1.publish)("open-cart")}),parentProps=Object.assign({handleClick,label,href,orderId:order?.id,accessToken},p);return accessToken?children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href,onClick:e=>{handleClick(e)}},p,{children:label})):null}exports.default=CartLink;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CheckoutLink=CheckoutLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),organization_1=require("../../utils/organization");function CheckoutLink(props){var _a;const{label,hostedCheckout=!0,children,onClick}=props,p=tslib_1.__rest(props,["label","hostedCheckout","children","onClick"]),{order}=(0,react_1.useContext)(OrderContext_1.default),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);if(accessToken==null||endpoint==null)throw new Error("Cannot use `CheckoutLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint),href=hostedCheckout&&order?.id?(0,getApplicationLink_1.getApplicationLink)({slug,orderId:order?.id,accessToken,applicationType:"checkout",domain}):(_a=order?.checkout_url)!==null&&_a!==void 0?_a:"",parentProps=Object.assign({checkoutUrl:order?.checkout_url,hostedCheckout,label,href},p);function handleClick(e){e.preventDefault(),e.stopPropagation();const currentHref=e.currentTarget.href;accessToken&&endpoint&&order?.id?(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken,orderId:order?.id}}).then(config=>{var _a2;!((_a2=config?.links)===null||_a2===void 0)&&_a2.checkout?window.open(config.links.checkout,"_top"):window.open(currentHref,"_top")}):window.open(currentHref,"_top")}return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href,onClick:handleClick},p,{children:label}))}exports.default=CheckoutLink;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CheckoutLink=CheckoutLink;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),organization_1=require("../../utils/organization");function CheckoutLink(props){var _a;const{label,hostedCheckout=!0,children,onClick}=props,p=tslib_1.__rest(props,["label","hostedCheckout","children","onClick"]),{order}=(0,react_1.useContext)(OrderContext_1.default),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);if(accessToken==null||endpoint==null)throw new Error("Cannot use `CheckoutLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint),href=hostedCheckout&&order?.id?(0,getApplicationLink_1.getApplicationLink)({slug,orderId:order?.id,accessToken,applicationType:"checkout",domain}):(_a=order?.checkout_url)!==null&&_a!==void 0?_a:"",parentProps=Object.assign({checkoutUrl:order?.checkout_url,hostedCheckout,label,href},p);function handleClick(e){e.preventDefault(),e.stopPropagation();const currentHref=e.currentTarget.href;accessToken&&endpoint&&order?.id?(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{accessToken,slug,orderId:order?.id}}).then(config=>{var _a2;!((_a2=config?.links)===null||_a2===void 0)&&_a2.checkout?window.open(config.links.checkout,"_top"):window.open(currentHref,"_top")}):window.open(currentHref,"_top")}return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href,onClick:handleClick},p,{children:label}))}exports.default=CheckoutLink;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HostedCart=HostedCart;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),OrderStorageContext_1=tslib_1.__importDefault(require("../../context/OrderStorageContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext")),react_1=require("react"),iframe_resizer_1=require("iframe-resizer"),events_1=require("../../utils/events"),organization_1=require("../../utils/organization"),defaultIframeStyle={width:"1px",minWidth:"100%",minHeight:"100%",border:"none",paddingLeft:"20px",paddingRight:"20px"},defaultContainerStyle={position:"fixed",top:"0",right:"-25rem",height:"100%",width:"23rem",transition:"right 0.5s ease-in-out",pointerEvents:"none",overflow:"auto"},defaultBackgroundStyle={opacity:"0",position:"fixed",top:"0",left:"0",height:"100%",width:"100vw",transition:"opacity 0.5s ease-in-out",pointerEvents:"none",backgroundColor:"black"},defaultIconStyle={width:"1.25rem",height:"1.25rem"},defaultIconContainer={textAlign:"left",paddingLeft:"20px",paddingTop:"20px",background:"#ffffff",color:"#686E6E"},defaultStyle={cart:defaultIframeStyle,container:defaultContainerStyle,background:defaultBackgroundStyle,icon:defaultIconStyle,iconContainer:defaultIconContainer};function HostedCart(_a){var _b,_c,_d,_e,{type,openAdd=!1,style,open=!1,handleOpen,customDomain}=_a,props=tslib_1.__rest(_a,["type","openAdd","style","open","handleOpen","customDomain"]);const[isOpen,setOpen]=(0,react_1.useState)(!1),ref=(0,react_1.useRef)(null),{accessToken,endpoint}=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"HostedCart",key:"accessToken"}),[src,setSrc]=(0,react_1.useState)();if(accessToken==null||endpoint==null)return null;const{order,createOrder,getOrder}=(0,react_1.useContext)(OrderContext_1.default),{persistKey}=(0,react_1.useContext)(OrderStorageContext_1.default),{domain,slug}=(0,getDomain_1.getDomain)(endpoint);function setOrder(openCart){return tslib_1.__awaiter(this,void 0,void 0,function*(){var _a2,_b2,_c2;const orderId=(_a2=localStorage.getItem(persistKey))!==null&&_a2!==void 0?_a2:yield createOrder({});if(orderId!=null&&accessToken&&endpoint){const config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken}});setSrc((_c2=(_b2=config?.links)===null||_b2===void 0?void 0:_b2.cart)!==null&&_c2!==void 0?_c2:(0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain})),openCart&&setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300)}})}function onMessage(data){var _a2;switch(data.message.type){case"update":data.message.payload!=null&&getOrder(data.message.payload.id);break;case"close":type==="mini"&&(handleOpen!=null?handleOpen():setOpen(!1));break;case"blur":type==="mini"&&isOpen&&((_a2=ref.current)===null||_a2===void 0||_a2.focus());break}}(0,react_1.useEffect)(()=>{const orderId=localStorage.getItem(persistKey);let ignore=!1;return open!=null&&open!==isOpen&&setOpen(open),openAdd&&type==="mini"&&(0,events_1.subscribe)("open-cart",()=>{window.document.body.style.overflow="hidden",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)&&accessToken&&(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken}}).then(config=>{var _a2,_b2,_c2,_d2;setSrc((_b2=(_a2=config?.links)===null||_a2===void 0?void 0:_a2.cart)!==null&&_b2!==void 0?_b2:(0,getApplicationLink_1.getApplicationLink)({slug,orderId:(_d2=(_c2=order?.id)!==null&&_c2!==void 0?_c2:orderId)!==null&&_d2!==void 0?_d2:"",accessToken,domain,applicationType:"cart"}))}),src!=null&&ref.current!=null&&(ref.current.src=src),()=>{ignore=!0,openAdd&&type==="mini"&&(0,events_1.unsubscribe)("open-cart",()=>{})}},[src,open,order?.id,accessToken]),(0,react_1.useEffect)(()=>{ref.current!=null&&(0,iframe_resizer_1.iframeResizer)({checkOrigin:!1,onMessage},ref.current)},[ref.current!=null]);function onCloseCart(){window.document.body.style.removeProperty("overflow"),handleOpen!=null?handleOpen():setOpen(!1)}return src==null?null:type==="mini"?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)("div",{"aria-hidden":"true",style:Object.assign(Object.assign(Object.assign({},defaultStyle.background),style?.background),{opacity:isOpen?"0.5":(_b=defaultStyle.background)===null||_b===void 0?void 0:_b.opacity,pointerEvents:isOpen?"initial":(_c=defaultStyle.background)===null||_c===void 0?void 0:_c.pointerEvents}),onClick:onCloseCart}),(0,jsx_runtime_1.jsxs)("div",Object.assign({style:Object.assign(Object.assign(Object.assign({},defaultStyle.container),style?.container),{right:isOpen?"0":(_d=defaultStyle.container)===null||_d===void 0?void 0:_d.right,pointerEvents:isOpen?"initial":(_e=defaultStyle.container)===null||_e===void 0?void 0:_e.pointerEvents})},props,{children:[(0,jsx_runtime_1.jsx)("div",{style:Object.assign(Object.assign({},defaultStyle.iconContainer),style?.iconContainer),children:(0,jsx_runtime_1.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",style:Object.assign(Object.assign({},defaultStyle.icon),style?.icon),onClick:onCloseCart,children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})]}))]}):(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})}
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HostedCart=HostedCart;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),OrderStorageContext_1=tslib_1.__importDefault(require("../../context/OrderStorageContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext")),react_1=require("react"),iframe_resizer_1=require("iframe-resizer"),events_1=require("../../utils/events"),organization_1=require("../../utils/organization"),defaultIframeStyle={width:"1px",minWidth:"100%",minHeight:"100%",border:"none",paddingLeft:"20px",paddingRight:"20px"},defaultContainerStyle={position:"fixed",top:"0",right:"-25rem",height:"100%",width:"23rem",transition:"right 0.5s ease-in-out",pointerEvents:"none",overflow:"auto"},defaultBackgroundStyle={opacity:"0",position:"fixed",top:"0",left:"0",height:"100%",width:"100vw",transition:"opacity 0.5s ease-in-out",pointerEvents:"none",backgroundColor:"black"},defaultIconStyle={width:"1.25rem",height:"1.25rem"},defaultIconContainer={textAlign:"left",paddingLeft:"20px",paddingTop:"20px",background:"#ffffff",color:"#686E6E"},defaultStyle={cart:defaultIframeStyle,container:defaultContainerStyle,background:defaultBackgroundStyle,icon:defaultIconStyle,iconContainer:defaultIconContainer};function HostedCart(_a){var _b,_c,_d,_e,{type,openAdd=!1,style,open=!1,handleOpen,customDomain}=_a,props=tslib_1.__rest(_a,["type","openAdd","style","open","handleOpen","customDomain"]);const[isOpen,setOpen]=(0,react_1.useState)(!1),ref=(0,react_1.useRef)(null),{accessToken,endpoint}=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"HostedCart",key:"accessToken"}),[src,setSrc]=(0,react_1.useState)();if(accessToken==null||endpoint==null)return null;const{order,createOrder,getOrder}=(0,react_1.useContext)(OrderContext_1.default),{persistKey}=(0,react_1.useContext)(OrderStorageContext_1.default),{domain,slug}=(0,getDomain_1.getDomain)(endpoint);function setOrder(openCart){return tslib_1.__awaiter(this,void 0,void 0,function*(){var _a2,_b2,_c2;const orderId=(_a2=localStorage.getItem(persistKey))!==null&&_a2!==void 0?_a2:yield createOrder({});if(orderId!=null&&accessToken&&endpoint){const config=yield(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken,slug}});setSrc((_c2=(_b2=config?.links)===null||_b2===void 0?void 0:_b2.cart)!==null&&_c2!==void 0?_c2:(0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain})),openCart&&setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300)}})}function onMessage(data){var _a2;switch(data.message.type){case"update":data.message.payload!=null&&getOrder(data.message.payload.id);break;case"close":type==="mini"&&(handleOpen!=null?handleOpen():setOpen(!1));break;case"blur":type==="mini"&&isOpen&&((_a2=ref.current)===null||_a2===void 0||_a2.focus());break}}(0,react_1.useEffect)(()=>{const orderId=localStorage.getItem(persistKey);let ignore=!1;return open!=null&&open!==isOpen&&setOpen(open),openAdd&&type==="mini"&&(0,events_1.subscribe)("open-cart",()=>{window.document.body.style.overflow="hidden",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)&&accessToken&&(0,organization_1.getOrganizationConfig)({accessToken,endpoint,params:{orderId:order?.id,accessToken,slug}}).then(config=>{var _a2,_b2,_c2,_d2;setSrc((_b2=(_a2=config?.links)===null||_a2===void 0?void 0:_a2.cart)!==null&&_b2!==void 0?_b2:(0,getApplicationLink_1.getApplicationLink)({slug,orderId:(_d2=(_c2=order?.id)!==null&&_c2!==void 0?_c2:orderId)!==null&&_d2!==void 0?_d2:"",accessToken,domain,applicationType:"cart"}))}),src!=null&&ref.current!=null&&(ref.current.src=src),()=>{ignore=!0,openAdd&&type==="mini"&&(0,events_1.unsubscribe)("open-cart",()=>{})}},[src,open,order?.id,accessToken]),(0,react_1.useEffect)(()=>{ref.current!=null&&(0,iframe_resizer_1.iframeResizer)({checkOrigin:!1,onMessage},ref.current)},[ref.current!=null]);function onCloseCart(){window.document.body.style.removeProperty("overflow"),handleOpen!=null?handleOpen():setOpen(!1)}return src==null?null:type==="mini"?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)("div",{"aria-hidden":"true",style:Object.assign(Object.assign(Object.assign({},defaultStyle.background),style?.background),{opacity:isOpen?"0.5":(_b=defaultStyle.background)===null||_b===void 0?void 0:_b.opacity,pointerEvents:isOpen?"initial":(_c=defaultStyle.background)===null||_c===void 0?void 0:_c.pointerEvents}),onClick:onCloseCart}),(0,jsx_runtime_1.jsxs)("div",Object.assign({style:Object.assign(Object.assign(Object.assign({},defaultStyle.container),style?.container),{right:isOpen?"0":(_d=defaultStyle.container)===null||_d===void 0?void 0:_d.right,pointerEvents:isOpen?"initial":(_e=defaultStyle.container)===null||_e===void 0?void 0:_e.pointerEvents})},props,{children:[(0,jsx_runtime_1.jsx)("div",{style:Object.assign(Object.assign({},defaultStyle.iconContainer),style?.iconContainer),children:(0,jsx_runtime_1.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",style:Object.assign(Object.assign({},defaultStyle.icon),style?.icon),onClick:onCloseCart,children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})]}))]}):(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JSX } from 'react';
|
|
1
2
|
import { type TOrderList, type InitialOrderListContext, type OrderListContent } from '../../context/OrderListChildrenContext';
|
|
2
3
|
import { type ColumnDef, type SortingState } from '@tanstack/react-table';
|
|
3
4
|
import type { DefaultChildrenType, TRange } from '../../typings/globals';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type OrderListPaginationContext as TOrderListPaginationContext } from '../../context/OrderListPaginationContext';
|
|
2
2
|
import { type ChildrenFunction } from '../../typings/index';
|
|
3
|
+
import type { JSX } from "react";
|
|
3
4
|
interface PaginationButton extends Omit<JSX.IntrinsicElements['button'], 'children' | 'disabled'> {
|
|
4
5
|
/**
|
|
5
6
|
* Show or hide the pagination button. Default is true.
|