@commercelayer/react-components 2.53.3 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +3 -3
- package/lib/components/AdyenPayment.d.ts +3 -3
- package/lib/components/AdyenPayment.js +1 -1
- package/lib/components/AvailabilityContainer.d.ts +10 -3
- package/lib/components/AvailabilityContainer.js +1 -1
- package/lib/components/AvailabilityTemplate.d.ts +13 -4
- package/lib/components/AvailabilityTemplate.js +1 -1
- package/lib/components/BillingAddressContainer.d.ts +7 -2
- package/lib/components/BillingAddressContainer.js +1 -1
- package/lib/components/BillingAddressForm.d.ts +8 -3
- package/lib/components/BillingAddressForm.js +1 -1
- package/lib/components/BraintreePayment.d.ts +3 -3
- package/lib/components/BraintreePayment.js +1 -1
- package/lib/components/CheckoutComPayment.d.ts +23 -0
- package/lib/components/CheckoutComPayment.js +1 -0
- package/lib/components/CheckoutLink.d.ts +16 -4
- package/lib/components/CheckoutLink.js +1 -1
- package/lib/components/DeliveryLeadTime.d.ts +11 -4
- package/lib/components/DeliveryLeadTime.js +1 -1
- package/lib/components/DiscountAmount.d.ts +16 -2
- package/lib/components/DiscountAmount.js +1 -1
- package/lib/components/Errors.d.ts +4 -4
- package/lib/components/Errors.js +1 -1
- package/lib/components/ExternalFunction.d.ts +9 -2
- package/lib/components/ExternalFunction.js +1 -1
- package/lib/components/GiftCard.d.ts +13 -3
- package/lib/components/GiftCard.js +1 -1
- package/lib/components/GiftCardContainer.d.ts +9 -3
- package/lib/components/GiftCardContainer.js +1 -1
- package/lib/components/GiftCardCurrencySelector.d.ts +18 -3
- package/lib/components/GiftCardCurrencySelector.js +1 -1
- package/lib/components/GiftCardInput.d.ts +12 -3
- package/lib/components/GiftCardInput.js +1 -1
- package/lib/components/GiftCardOrCouponCode.d.ts +17 -6
- package/lib/components/GiftCardOrCouponCode.js +1 -1
- package/lib/components/GiftCardOrCouponForm.d.ts +9 -4
- package/lib/components/GiftCardOrCouponForm.js +1 -1
- package/lib/components/GiftCardOrCouponInput.d.ts +14 -3
- package/lib/components/GiftCardOrCouponInput.js +1 -1
- package/lib/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
- package/lib/components/GiftCardOrCouponRemoveButton.js +1 -1
- package/lib/components/GiftCardOrCouponSubmit.d.ts +11 -4
- package/lib/components/GiftCardOrCouponSubmit.js +1 -1
- package/lib/components/ItemContainer.d.ts +14 -3
- package/lib/components/ItemContainer.js +1 -1
- package/lib/components/KlarnaPayment.d.ts +10 -0
- package/lib/components/KlarnaPayment.js +1 -0
- package/lib/components/LineItem.d.ts +10 -3
- package/lib/components/LineItem.js +1 -1
- package/lib/components/LineItemAmount.d.ts +16 -3
- package/lib/components/LineItemAmount.js +1 -1
- package/lib/components/LineItemCode.d.ts +10 -4
- package/lib/components/LineItemCode.js +1 -1
- package/lib/components/LineItemImage.d.ts +11 -4
- package/lib/components/LineItemImage.js +1 -1
- package/lib/components/LineItemName.d.ts +11 -5
- package/lib/components/LineItemName.js +1 -1
- package/lib/components/LineItemOption.d.ts +15 -4
- package/lib/components/LineItemOption.js +1 -1
- package/lib/components/LineItemOptions.d.ts +8 -3
- package/lib/components/LineItemOptions.js +1 -1
- package/lib/components/LineItemQuantity.d.ts +16 -4
- package/lib/components/LineItemQuantity.js +1 -1
- package/lib/components/LineItemRemoveLink.d.ts +15 -5
- package/lib/components/LineItemRemoveLink.js +1 -1
- package/lib/components/LineItemsContainer.d.ts +15 -3
- package/lib/components/LineItemsContainer.js +1 -1
- package/lib/components/LineItemsCount.d.ts +14 -4
- package/lib/components/LineItemsCount.js +1 -1
- package/lib/components/LineItemsEmpty.d.ts +13 -2
- package/lib/components/LineItemsEmpty.js +1 -1
- package/lib/components/MetadataInput.d.ts +13 -3
- package/lib/components/MetadataInput.js +1 -1
- package/lib/components/PaymentGateway.d.ts +4 -4
- package/lib/components/PaymentGateway.js +1 -1
- package/lib/components/PaymentMethod.d.ts +9 -3
- package/lib/components/PaymentMethod.js +1 -1
- package/lib/components/PaymentMethodAmount.d.ts +16 -2
- package/lib/components/PaymentMethodAmount.js +1 -1
- package/lib/components/PaymentMethodName.d.ts +10 -4
- package/lib/components/PaymentMethodName.js +1 -1
- package/lib/components/PaymentMethodPrice.d.ts +15 -4
- package/lib/components/PaymentMethodPrice.js +1 -1
- package/lib/components/PaymentMethodRadioButton.d.ts +11 -4
- package/lib/components/PaymentMethodRadioButton.js +1 -1
- package/lib/components/PaymentMethodsContainer.d.ts +9 -3
- package/lib/components/PaymentMethodsContainer.js +1 -1
- package/lib/components/PaymentSource.d.ts +9 -2
- package/lib/components/PaymentSource.js +1 -1
- package/lib/components/PaymentSourceBrandIcon.d.ts +14 -4
- package/lib/components/PaymentSourceBrandIcon.js +1 -1
- package/lib/components/PaymentSourceBrandName.d.ts +11 -4
- package/lib/components/PaymentSourceBrandName.js +1 -1
- package/lib/components/PaymentSourceDetail.d.ts +8 -2
- package/lib/components/PaymentSourceDetail.js +1 -1
- package/lib/components/PaymentSourceEditButton.d.ts +9 -2
- package/lib/components/PaymentSourceEditButton.js +1 -1
- package/lib/components/PaypalPayment.d.ts +2 -2
- package/lib/components/PaypalPayment.js +1 -1
- package/lib/components/Price.d.ts +15 -3
- package/lib/components/Price.js +1 -1
- package/lib/components/PricesContainer.d.ts +19 -3
- package/lib/components/PricesContainer.js +1 -1
- package/lib/components/QuantitySelector.d.ts +19 -5
- package/lib/components/QuantitySelector.js +1 -1
- package/lib/components/SaveAddressesButton.d.ts +18 -5
- package/lib/components/SaveAddressesButton.js +1 -1
- package/lib/components/SaveCustomerButton.d.ts +16 -5
- package/lib/components/SaveCustomerButton.js +1 -1
- package/lib/components/Shipment.d.ts +9 -2
- package/lib/components/Shipment.js +1 -1
- package/lib/components/ShipmentField.d.ts +11 -4
- package/lib/components/ShipmentField.js +1 -1
- package/lib/components/ShipmentsContainer.d.ts +9 -3
- package/lib/components/ShipmentsContainer.js +1 -1
- package/lib/components/ShippingAddressContainer.d.ts +7 -2
- package/lib/components/ShippingAddressContainer.js +1 -1
- package/lib/components/ShippingAddressForm.d.ts +8 -3
- package/lib/components/ShippingAddressForm.js +1 -1
- package/lib/components/ShippingAmount.d.ts +13 -2
- package/lib/components/ShippingAmount.js +1 -1
- package/lib/components/ShippingMethod.d.ts +10 -3
- package/lib/components/ShippingMethod.js +1 -1
- package/lib/components/ShippingMethodName.d.ts +11 -5
- package/lib/components/ShippingMethodName.js +1 -1
- package/lib/components/ShippingMethodPrice.d.ts +15 -3
- package/lib/components/ShippingMethodPrice.js +1 -1
- package/lib/components/ShippingMethodRadioButton.d.ts +11 -5
- package/lib/components/ShippingMethodRadioButton.js +1 -1
- package/lib/components/StockTransfer.d.ts +9 -3
- package/lib/components/StockTransfer.js +1 -1
- package/lib/components/StockTransferField.d.ts +9 -8
- package/lib/components/StockTransferField.js +1 -1
- package/lib/components/StripePayment.d.ts +3 -3
- package/lib/components/StripePayment.js +1 -1
- package/lib/components/SubmitButton.d.ts +15 -5
- package/lib/components/SubmitButton.js +1 -1
- package/lib/components/VariantSelector.d.ts +28 -5
- package/lib/components/VariantSelector.js +1 -1
- package/lib/components/VariantsContainer.d.ts +15 -3
- package/lib/components/VariantsContainer.js +1 -1
- package/lib/components/WireTransferPayment.d.ts +2 -2
- package/lib/components/WireTransferPayment.js +1 -1
- package/lib/components/addresses/Address.d.ts +18 -0
- package/lib/components/addresses/Address.js +1 -0
- package/lib/components/addresses/AddressCountrySelector.d.ts +26 -0
- package/lib/components/addresses/AddressCountrySelector.js +1 -0
- package/lib/components/addresses/AddressField.d.ts +43 -0
- package/lib/components/addresses/AddressField.js +1 -0
- package/lib/components/addresses/AddressInput.d.ts +19 -0
- package/lib/components/addresses/AddressInput.js +1 -0
- package/lib/components/addresses/AddressStateSelector.d.ts +27 -0
- package/lib/components/addresses/AddressStateSelector.js +1 -0
- package/lib/components/addresses/AddressesContainer.d.ts +15 -0
- package/lib/components/addresses/AddressesContainer.js +1 -0
- package/lib/components/auth/CommerceLayer.d.ts +15 -0
- package/lib/components/auth/CommerceLayer.js +1 -0
- package/lib/components/customers/CustomerAddressForm.d.ts +13 -0
- package/lib/components/customers/CustomerAddressForm.js +1 -0
- package/lib/components/customers/CustomerContainer.d.ts +17 -0
- package/lib/components/customers/CustomerContainer.js +1 -0
- package/lib/components/customers/CustomerField.d.ts +10 -0
- package/lib/components/customers/CustomerField.js +1 -0
- package/lib/components/customers/CustomerInput.d.ts +23 -0
- package/lib/components/customers/CustomerInput.js +1 -0
- package/lib/components/gateways/AdyenGateway.d.ts +2 -2
- package/lib/components/gateways/AdyenGateway.js +1 -1
- package/lib/components/gateways/BraintreeGateway.d.ts +2 -2
- package/lib/components/gateways/BraintreeGateway.js +1 -1
- package/lib/components/gateways/CheckoutComGateway.d.ts +5 -0
- package/lib/components/gateways/CheckoutComGateway.js +1 -0
- package/lib/components/gateways/KlarnaGateway.d.ts +5 -0
- package/lib/components/gateways/KlarnaGateway.js +1 -0
- package/lib/components/gateways/PaypalGateway.d.ts +3 -3
- package/lib/components/gateways/PaypalGateway.js +1 -1
- package/lib/components/gateways/StripeGateway.d.ts +2 -2
- package/lib/components/gateways/StripeGateway.js +1 -1
- package/lib/components/gateways/WireTransferGateway.d.ts +2 -2
- package/lib/components/gateways/WireTransferGateway.js +1 -1
- package/lib/components/orders/AddToCartButton.d.ts +34 -0
- package/lib/components/orders/AddToCartButton.js +1 -0
- package/lib/components/orders/AdjustmentAmount.d.ts +18 -0
- package/lib/components/orders/AdjustmentAmount.js +1 -0
- package/lib/components/orders/CartLink.d.ts +12 -0
- package/lib/components/orders/CartLink.js +1 -0
- package/lib/components/orders/GiftCardAmount.d.ts +15 -0
- package/lib/components/orders/GiftCardAmount.js +1 -0
- package/lib/components/orders/OrderContainer.d.ts +26 -0
- package/lib/components/orders/OrderContainer.js +1 -0
- package/lib/components/orders/OrderList.d.ts +61 -0
- package/lib/components/orders/OrderList.js +1 -0
- package/lib/components/orders/OrderListRow.d.ts +30 -0
- package/lib/components/orders/OrderListRow.js +1 -0
- package/lib/components/orders/OrderNumber.d.ts +11 -0
- package/lib/components/orders/OrderNumber.js +1 -0
- package/lib/components/orders/OrderStorage.d.ts +16 -0
- package/lib/components/orders/OrderStorage.js +1 -0
- package/lib/components/orders/PlaceOrderButton.d.ts +24 -0
- package/lib/components/orders/PlaceOrderButton.js +1 -0
- package/lib/components/orders/PlaceOrderContainer.d.ts +14 -0
- package/lib/components/orders/PlaceOrderContainer.js +1 -0
- package/lib/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
- package/lib/components/orders/PrivacyAndTermsCheckbox.js +1 -0
- package/lib/components/orders/SubTotalAmount.d.ts +18 -0
- package/lib/components/orders/SubTotalAmount.js +1 -0
- package/lib/components/orders/TaxesAmount.d.ts +18 -0
- package/lib/components/orders/TaxesAmount.js +1 -0
- package/lib/components/orders/TotalAmount.d.ts +18 -0
- package/lib/components/orders/TotalAmount.js +1 -0
- package/lib/components/skus/SkuField.d.ts +14 -0
- package/lib/components/skus/SkuField.js +1 -0
- package/lib/components/skus/SkuList.d.ts +14 -0
- package/lib/components/skus/SkuList.js +1 -0
- package/lib/components/skus/SkuListsContainer.d.ts +12 -0
- package/lib/components/skus/SkuListsContainer.js +1 -0
- package/lib/components/skus/SkuOption.d.ts +14 -0
- package/lib/components/skus/SkuOption.js +1 -0
- package/lib/components/skus/SkuOptionInput.d.ts +15 -0
- package/lib/components/skus/SkuOptionInput.js +1 -0
- package/lib/components/skus/SkuOptionsContainer.d.ts +14 -0
- package/lib/components/skus/SkuOptionsContainer.js +1 -0
- package/lib/components/skus/Skus.d.ts +11 -0
- package/lib/components/skus/Skus.js +1 -0
- package/lib/components/skus/SkusContainer.d.ts +23 -0
- package/lib/components/skus/SkusContainer.js +1 -0
- package/lib/components/utils/AddressCardsTemplate.d.ts +1 -1
- package/lib/components/utils/AddressCardsTemplate.js +1 -1
- package/lib/components/utils/BaseField.js +1 -1
- package/lib/components/utils/BaseInput.d.ts +1 -1
- package/lib/components/utils/BaseInput.js +1 -1
- package/lib/components/utils/BaseOrderPrice.js +1 -1
- package/lib/components/utils/BaseSelect.js +1 -1
- package/lib/components/utils/GenericFieldComponent.d.ts +42 -0
- package/lib/components/utils/GenericFieldComponent.js +1 -0
- package/lib/components/utils/Parent.d.ts +3 -5
- package/lib/components/utils/Parent.js +1 -1
- package/lib/components/utils/PaymentCardsTemplate.d.ts +2 -2
- package/lib/components/utils/PaymentCardsTemplate.js +1 -1
- package/lib/components/utils/PriceTemplate.d.ts +2 -2
- package/lib/components/utils/PriceTemplate.js +1 -1
- package/lib/components/utils/VariantTemplate.js +1 -1
- package/lib/components/utils/getAllErrors.js +1 -1
- package/lib/config/components.d.ts +77 -35
- package/lib/config/components.js +1 -1
- package/lib/context/AddressChildrenContext.d.ts +1 -1
- package/lib/context/AddressChildrenContext.js +1 -1
- package/lib/context/AddressContext.d.ts +1 -1
- package/lib/context/BillingAddressContext.d.ts +2 -4
- package/lib/context/BillingAddressContext.js +1 -1
- package/lib/context/BillingAddressFormContext.d.ts +17 -10
- package/lib/context/CouponAndGiftCardFormContext.d.ts +2 -0
- package/lib/context/CustomerAddressFormContext.d.ts +20 -0
- package/lib/context/CustomerAddressFormContext.js +1 -0
- package/lib/context/CustomerContext.d.ts +17 -11
- package/lib/context/CustomerContext.js +1 -1
- package/lib/context/OrderContext.d.ts +8 -4
- package/lib/context/OrderContext.js +1 -1
- package/lib/context/OrderListChildrenContext.d.ts +60 -0
- package/lib/context/OrderListChildrenContext.js +1 -0
- package/lib/context/PaymentSourceContext.d.ts +4 -4
- package/lib/context/PlaceOrderContext.d.ts +4 -2
- package/lib/context/ShippingAddressContext.d.ts +1 -1
- package/lib/context/SkuChildrenContext.d.ts +9 -0
- package/lib/context/SkuChildrenContext.js +1 -0
- package/lib/context/SkuContext.d.ts +9 -0
- package/lib/context/SkuContext.js +1 -0
- package/lib/index.d.ts +101 -90
- package/lib/index.js +1 -1
- package/lib/reducers/AddressReducer.d.ts +4 -2
- package/lib/reducers/AddressReducer.js +1 -1
- package/lib/reducers/AvailabilityReducer.d.ts +8 -0
- package/lib/reducers/AvailabilityReducer.js +1 -1
- package/lib/reducers/BillingAddressReducer.js +1 -1
- package/lib/reducers/CustomerReducer.d.ts +98 -17
- package/lib/reducers/CustomerReducer.js +1 -1
- package/lib/reducers/GiftCardReducer.js +1 -1
- package/lib/reducers/LineItemReducer.js +1 -1
- package/lib/reducers/OrderReducer.d.ts +24 -8
- package/lib/reducers/OrderReducer.js +1 -1
- package/lib/reducers/PaymentMethodReducer.d.ts +51 -5
- package/lib/reducers/PaymentMethodReducer.js +1 -1
- package/lib/reducers/PlaceOrderReducer.d.ts +9 -2
- package/lib/reducers/PlaceOrderReducer.js +1 -1
- package/lib/reducers/ShipmentReducer.js +1 -1
- package/lib/reducers/ShippingAddressReducer.js +1 -1
- package/lib/reducers/SkuReducer.d.ts +21 -0
- package/lib/reducers/SkuReducer.js +1 -0
- package/lib/reducers/VariantReducer.d.ts +1 -0
- package/lib/reducers/VariantReducer.js +1 -1
- package/lib/typings/errors.d.ts +13 -4
- package/lib/typings/errors.js +1 -1
- package/lib/typings/index.d.ts +17 -6
- package/lib/utils/addressesManager.d.ts +1 -1
- package/lib/utils/addressesManager.js +1 -1
- package/lib/utils/checkIncludeResource.d.ts +8 -0
- package/lib/utils/checkIncludeResource.js +1 -0
- package/lib/utils/childrenTypes.d.ts +1 -1
- package/lib/utils/childrenTypes.js +1 -1
- package/lib/utils/compareObjAttribute.d.ts +7 -0
- package/lib/utils/compareObjAttribute.js +1 -0
- package/lib/utils/customMessages.d.ts +1 -7
- package/lib/utils/customMessages.js +1 -1
- package/lib/utils/getCardDetails.d.ts +15 -0
- package/lib/utils/getCardDetails.js +1 -0
- package/lib/utils/getCartLink.d.ts +7 -0
- package/lib/utils/getCartLink.js +1 -0
- package/lib/utils/getCurrentItemKey.js +1 -1
- package/lib/utils/getErrors.d.ts +1 -1
- package/lib/utils/getErrors.js +1 -1
- package/lib/utils/getLineItemsCount.d.ts +8 -10
- package/lib/utils/getLineItemsCount.js +1 -1
- package/lib/utils/getLoaderComponent.js +1 -1
- package/lib/utils/getPrices.js +1 -1
- package/lib/utils/getSkus.js +1 -1
- package/lib/utils/hooks/useExternalScript.d.ts +1 -0
- package/lib/utils/hooks/useExternalScript.js +1 -0
- package/lib/utils/icons.d.ts +3 -0
- package/lib/utils/icons.js +1 -0
- package/lib/utils/isDate.d.ts +1 -0
- package/lib/utils/isDate.js +1 -0
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/placeholderImages.d.ts +2 -0
- package/lib/utils/placeholderImages.js +1 -0
- package/lib/utils/promisify.js +1 -1
- package/lib/utils/scrollbarWidth.d.ts +1 -0
- package/lib/utils/scrollbarWidth.js +1 -0
- package/lib/utils/shipments.d.ts +2 -1
- package/lib/utils/shipments.js +1 -1
- package/lib/utils/validateFormFields.d.ts +2 -0
- package/lib/utils/validateFormFields.js +1 -1
- package/package.json +96 -93
- package/lib/components/AddToCartButton.d.ts +0 -20
- package/lib/components/AddToCartButton.js +0 -1
- package/lib/components/Address.d.ts +0 -13
- package/lib/components/Address.js +0 -1
- package/lib/components/AddressCountrySelector.d.ts +0 -9
- package/lib/components/AddressCountrySelector.js +0 -1
- package/lib/components/AddressField.d.ts +0 -15
- package/lib/components/AddressField.js +0 -1
- package/lib/components/AddressInput.d.ts +0 -7
- package/lib/components/AddressInput.js +0 -1
- package/lib/components/AddressStateSelector.d.ts +0 -11
- package/lib/components/AddressStateSelector.js +0 -1
- package/lib/components/AddressesContainer.d.ts +0 -7
- package/lib/components/AddressesContainer.js +0 -1
- package/lib/components/AdjustmentAmount.d.ts +0 -4
- package/lib/components/AdjustmentAmount.js +0 -1
- package/lib/components/CommerceLayer.d.ts +0 -8
- package/lib/components/CommerceLayer.js +0 -1
- package/lib/components/CustomerContainer.d.ts +0 -7
- package/lib/components/CustomerContainer.js +0 -1
- package/lib/components/CustomerInput.d.ts +0 -11
- package/lib/components/CustomerInput.js +0 -1
- package/lib/components/GiftCardAmount.d.ts +0 -4
- package/lib/components/GiftCardAmount.js +0 -1
- package/lib/components/OrderContainer.d.ts +0 -11
- package/lib/components/OrderContainer.js +0 -1
- package/lib/components/OrderNumber.d.ts +0 -5
- package/lib/components/OrderNumber.js +0 -1
- package/lib/components/OrderStorage.d.ts +0 -8
- package/lib/components/OrderStorage.js +0 -1
- package/lib/components/PlaceOrderButton.d.ts +0 -12
- package/lib/components/PlaceOrderButton.js +0 -1
- package/lib/components/PlaceOrderContainer.d.ts +0 -8
- package/lib/components/PlaceOrderContainer.js +0 -1
- package/lib/components/PrivacyAndTermsCheckbox.d.ts +0 -4
- package/lib/components/PrivacyAndTermsCheckbox.js +0 -1
- package/lib/components/SkuList.d.ts +0 -7
- package/lib/components/SkuList.js +0 -1
- package/lib/components/SkuListsContainer.d.ts +0 -6
- package/lib/components/SkuListsContainer.js +0 -1
- package/lib/components/SkuOption.d.ts +0 -7
- package/lib/components/SkuOption.js +0 -1
- package/lib/components/SkuOptionInput.d.ts +0 -5
- package/lib/components/SkuOptionInput.js +0 -1
- package/lib/components/SkuOptionsContainer.d.ts +0 -7
- package/lib/components/SkuOptionsContainer.js +0 -1
- package/lib/components/SubTotalAmount.d.ts +0 -4
- package/lib/components/SubTotalAmount.js +0 -1
- package/lib/components/TaxesAmount.d.ts +0 -4
- package/lib/components/TaxesAmount.js +0 -1
- package/lib/components/TotalAmount.d.ts +0 -4
- package/lib/components/TotalAmount.js +0 -1
package/lib/typings/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, ReactNode, RefObject } from 'react';
|
|
1
|
+
import { Dispatch, ForwardedRef, ReactNode, RefObject } from 'react';
|
|
2
2
|
import PropTypes, { InferProps } from 'prop-types';
|
|
3
3
|
import { BaseError } from './errors';
|
|
4
4
|
export declare const BC: {
|
|
@@ -37,6 +37,7 @@ export interface BaseSelectComponentProps {
|
|
|
37
37
|
className?: string;
|
|
38
38
|
required?: boolean;
|
|
39
39
|
name: string;
|
|
40
|
+
onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
40
41
|
}
|
|
41
42
|
export declare const BaseInputComponentPropTypes: {
|
|
42
43
|
children: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -47,6 +48,7 @@ export declare const BaseInputComponentPropTypes: {
|
|
|
47
48
|
};
|
|
48
49
|
declare type BaseInputChildrenComponentProps = Omit<BaseInputComponentProps, 'children'> & {
|
|
49
50
|
handleChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
51
|
+
parentRef: ForwardedRef<any>;
|
|
50
52
|
};
|
|
51
53
|
export interface BaseInputComponentProps {
|
|
52
54
|
ref?: () => RefObject<any>;
|
|
@@ -57,9 +59,9 @@ export interface BaseInputComponentProps {
|
|
|
57
59
|
}
|
|
58
60
|
export declare type LineItemType = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
|
|
59
61
|
export declare type GiftCardInputName = 'balanceCents' | 'balanceMaxCents' | 'singleUse' | 'rechargeable' | 'imageUrl' | 'expiresAt' | 'referenceOrigin' | 'email' | 'firstName' | 'lastName' | 'reference';
|
|
60
|
-
export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
|
|
61
|
-
export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code';
|
|
62
|
-
export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code';
|
|
62
|
+
export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'customer_address_city' | 'customer_address_company' | 'customer_address_first_name' | 'customer_address_email' | 'customer_address_last_name' | 'customer_address_line_1' | 'customer_address_line_2' | 'customer_address_phone' | 'customer_address_state_code' | 'customer_address_zip_code' | 'customer_address_billing_info' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
|
|
63
|
+
export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code' | 'customer_address_country_code';
|
|
64
|
+
export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code' | 'customer_address_state_code';
|
|
63
65
|
export declare type BaseInputType = 'checkbox' | 'date' | 'email' | 'number' | 'tel' | 'text' | 'textarea';
|
|
64
66
|
export declare type LoaderType = string | ReactNode;
|
|
65
67
|
export declare const BMObject: PropTypes.Requireable<{
|
|
@@ -70,9 +72,9 @@ export declare type BaseMetadataObject = {
|
|
|
70
72
|
};
|
|
71
73
|
export declare type TimeFormat = 'days' | 'hours';
|
|
72
74
|
export declare type BaseComponent = InferProps<typeof BC>;
|
|
73
|
-
export interface BaseAction<A = string
|
|
75
|
+
export interface BaseAction<A = string, P = Record<string, any>> {
|
|
74
76
|
type: A;
|
|
75
|
-
payload:
|
|
77
|
+
payload: P;
|
|
76
78
|
}
|
|
77
79
|
export interface BaseState {
|
|
78
80
|
[key: string]: any;
|
|
@@ -123,4 +125,13 @@ export declare type BaseAmountComponent = {
|
|
|
123
125
|
export interface FunctionChildren<P = Record<string, any>> {
|
|
124
126
|
(props: P): ReactNode;
|
|
125
127
|
}
|
|
128
|
+
export declare type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JSX.IntrinsicElements, T>;
|
|
129
|
+
export declare type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
|
|
130
|
+
export declare type ConditionalElement<E> = ({
|
|
131
|
+
attribute: Extract<keyof E, 'image_url'>;
|
|
132
|
+
tagElement: ExtractTag<'img'>;
|
|
133
|
+
} & JSX.IntrinsicElements['img']) | ({
|
|
134
|
+
attribute: Exclude<keyof E, 'image_url'>;
|
|
135
|
+
tagElement: ExcludeTag<'img'>;
|
|
136
|
+
} & JSX.IntrinsicElements[ExcludeTag<'img'>]);
|
|
126
137
|
export {};
|
|
@@ -8,7 +8,7 @@ declare type BillingAddressController = (params: {
|
|
|
8
8
|
}) => boolean;
|
|
9
9
|
export declare const billingAddressController: BillingAddressController;
|
|
10
10
|
declare type ShippingAddressController = (params: {
|
|
11
|
-
billingDisable
|
|
11
|
+
billingDisable?: boolean;
|
|
12
12
|
errors?: BaseError[];
|
|
13
13
|
shipToDifferentAddress?: boolean;
|
|
14
14
|
shipping_address?: AddressCreate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses
|
|
1
|
+
import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo=!1})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===billingAddressId||a?.reference===billingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}if(countryCodeLock&&!isEmpty(billing_address)&&!shipToDifferentAddress)return billing_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(shipping_address)&&shipToDifferentAddress)return shipping_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(addresses)&&shippingAddressId&&shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===shippingAddressId||a?.reference===shippingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}return!1};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResourceIncluded } from '../reducers/OrderReducer';
|
|
2
|
+
import type { Order } from '@commercelayer/sdk';
|
|
3
|
+
declare type Params = {
|
|
4
|
+
order: Order;
|
|
5
|
+
resourceInclude: ResourceIncluded[];
|
|
6
|
+
};
|
|
7
|
+
export default function checkIncludeResources({ order, resourceInclude, }: Params): boolean;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function checkIncludeResources({order,resourceInclude}){const checkKeys=[];return resourceInclude.forEach(v=>{if(v.includes(".")){const[first]=v.split(".");order?.[first]===void 0&&checkKeys.push(!1)}else order?.[v]===void 0&&checkKeys.push(!1)}),checkKeys.length===0}
|
|
@@ -5,5 +5,5 @@ export interface CheckChildrenTypes {
|
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}, propName: string, componentName: string, location: string, propFullName: string): Error | null;
|
|
7
7
|
}
|
|
8
|
-
declare const _default: Requireable<ReactNode>;
|
|
8
|
+
declare const _default: Requireable<ReactNode | (() => ReactNode)>;
|
|
9
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(props,propName,componentName)=>{let error=null;const children=props[propName],cpName=componentName.replace("CL","");return(isEmpty(children)&&typeof children!="function"||typeof children=="function"&&!children)&&props.isRequired&&(error=new Error(`The prop '${propName}' is marked as required in '${cpName}', but its value is '${children}'.`)),Children.map(children,c=>{if(error)return error;const type=c
|
|
1
|
+
import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(props,propName,componentName)=>{let error=null;const children=props[propName],cpName=componentName.replace("CL","");return(isEmpty(children)&&typeof children!="function"||typeof children=="function"&&!children)&&props.isRequired&&(error=new Error(`The prop '${propName}' is marked as required in '${cpName}', but its value is '${children}'.`)),Children.map(children,c=>{if(error)return error;const type=c?.type,itemTypes=get(components,`${cpName}.permittedChildren`),errorMsg=`Invalid prop '${propName}' supplied to ${cpName}. Only components ${itemTypes.join(", ")} are allowed.`;if(isFunction(type)&&has(type,"displayName")){const displayName=get(type,"displayName"),childComponentName=type.name;displayName&&displayName===`${childComponentName}`&&(itemTypes.includes(childComponentName)||(error=new Error(errorMsg)))}!isValidElement(c)&&c!==null&&(error=new Error(errorMsg))}),error},childrenTypes=checkChildrenTypes;childrenTypes.isRequired=(props,propName,componentName,location,propFullName)=>checkChildrenTypes(Object.assign(Object.assign({},props),{isRequired:!0}),propName,componentName,location,propFullName);export default childrenTypes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function sortObj(obj){return Object.keys(obj).sort().reduce((result,key)=>(result[key]=obj[key],result),{})}export default function compareObjAttribute({attributes,object}){const returnObj={};return Object.keys(object).forEach(v=>{const element=attributes[v],compare=object[v];if(typeof element=="object"&&element){const elementSorted=sortObj(element),compareSorted=sortObj(compare);JSON.stringify(elementSorted)!==JSON.stringify(compareSorted)&&(returnObj[v]=element)}typeof element!="object"&&element&&element!==compare&&(returnObj[v]=element)}),returnObj}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import { BaseError } from '../typings/errors';
|
|
2
|
-
export
|
|
3
|
-
(messages: BaseError[], v: BaseError): {
|
|
4
|
-
message?: string;
|
|
5
|
-
} | null;
|
|
6
|
-
}
|
|
7
|
-
declare const customMessages: CustomMessages;
|
|
8
|
-
export default customMessages;
|
|
2
|
+
export default function customMessages(messages: BaseError[] | undefined, v: BaseError): BaseError | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import findIndex from"lodash/findIndex";import pick from"lodash/pick";
|
|
1
|
+
import findIndex from"lodash/findIndex";import pick from"lodash/pick";export default function customMessages(messages=[],v){const i=findIndex(messages,pick(v,["field","code","resource"]));return i!==-1?messages[i]:null}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconBrand } from '../context/PaymentSourceContext';
|
|
2
|
+
import { PaymentResource } from '../reducers/PaymentMethodReducer';
|
|
3
|
+
import { CustomerPaymentSource } from '@commercelayer/sdk';
|
|
4
|
+
declare type CardDetails = {
|
|
5
|
+
brand: IconBrand | string;
|
|
6
|
+
last4: string;
|
|
7
|
+
exp_month: number | string;
|
|
8
|
+
exp_year: number | string;
|
|
9
|
+
};
|
|
10
|
+
declare type Args = {
|
|
11
|
+
paymentType: PaymentResource;
|
|
12
|
+
customerPayment: Partial<CustomerPaymentSource>;
|
|
13
|
+
};
|
|
14
|
+
export default function getCardDetails({ paymentType, customerPayment, }: Args): CardDetails;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCardDetails({paymentType,customerPayment}){var _a,_b,_c,_d,_e;switch(paymentType){case"checkout_com_payments":{const ps=customerPayment.payment_source,source=(_a=ps?.payment_response)===null||_a===void 0?void 0:_a.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":case"braintree_payments":{const ps=customerPayment.payment_source,source=(_b=ps?.options)===null||_b===void 0?void 0:_b.card;if(source)return Object.assign({},source);break}case"adyen_payments":{const ps=customerPayment.payment_source,source=(_c=ps?.payment_request_data)===null||_c===void 0?void 0:_c.payment_method,authorized=((_d=ps?.payment_response)===null||_d===void 0?void 0:_d.resultCode)==="Authorised";if(source&&authorized)return Object.assign(Object.assign({},source),{brand:source?.brand?source.brand:"credit-card"});break}default:{const ps=customerPayment.payment_source,source=(_e=ps?.metadata)===null||_e===void 0?void 0:_e.card;if(source)return Object.assign({},source);break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCartLink({orderId,accessToken,slug}){const env=process.env.NODE_ENV==="production"?"":"stg.";return`${slug}.${env}commercelayer.app/cart/${orderId}?accessToken=${accessToken}`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import first from"lodash/first";import keys from"lodash/keys";const getCurrentItemKey=item=>first(keys(item))||"";export default getCurrentItemKey;
|
package/lib/utils/getErrors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseError, ResourceErrorType } from '../typings/errors';
|
|
2
2
|
import { Dispatch } from 'react';
|
|
3
|
-
export default function getErrors(error: any, resource: ResourceErrorType): BaseError[];
|
|
3
|
+
export default function getErrors(error: any, resource: ResourceErrorType, field?: string): BaseError[];
|
|
4
4
|
declare type SetErrorsArgs<D> = {
|
|
5
5
|
currentErrors?: BaseError[];
|
|
6
6
|
newErrors?: BaseError[];
|
package/lib/utils/getErrors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import differenceBy from"lodash/differenceBy";export default function getErrors(error,resource){var _a;return(_a=error
|
|
1
|
+
import differenceBy from"lodash/differenceBy";export default function getErrors(error,resource,field){var _a;return(_a=error?.errors)===null||_a===void 0?void 0:_a.map(e=>Object.assign(Object.assign(Object.assign({},e),{resource}),field&&{field}))}export function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=differenceBy(currentErrors,newErrors,filterBy),mergeErrors=currentErrors?.length===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];if(!dispatch)return errors;dispatch({type:"setErrors",payload:{errors}})}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { LineItem } from '@commercelayer/sdk';
|
|
1
|
+
import type { LineItem } from '@commercelayer/sdk';
|
|
2
2
|
import { LineItemType } from '../typings/index';
|
|
3
|
-
export interface GetLineItemsCountInterface {
|
|
4
|
-
(args: {
|
|
5
|
-
lineItems: LineItem[];
|
|
6
|
-
quantity?: number;
|
|
7
|
-
typeAccepted?: TypeAccepted[];
|
|
8
|
-
}): number;
|
|
9
|
-
}
|
|
10
3
|
export declare type TypeAccepted = Extract<LineItemType, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
|
|
11
|
-
declare
|
|
12
|
-
|
|
4
|
+
declare type Args = {
|
|
5
|
+
lineItems: LineItem[];
|
|
6
|
+
quantity?: number;
|
|
7
|
+
typeAccepted?: TypeAccepted[];
|
|
8
|
+
};
|
|
9
|
+
export default function getLineItemsCount({ lineItems, quantity, typeAccepted, }: Args): number;
|
|
10
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export default function getLineItemsCount({lineItems,quantity=0,typeAccepted=["skus","gift_cards","bundles","adjustments"]}){return lineItems.filter(l=>typeAccepted.includes(l.item_type)&&l?.total_amount_cents!==void 0&&l.total_amount_cents>=0).forEach(l=>{l.quantity&&(quantity+=l.quantity)}),quantity}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(Loader){return typeof Loader=="function"?_jsx(Loader,{}
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(Loader){return typeof Loader=="function"?_jsx(Loader,{}):_jsx(_Fragment,{children:Loader})}
|
package/lib/utils/getPrices.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(skuPrices,code="")=>code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices),getPricesComponent=(skuPrices,props)=>isEmpty(skuPrices)?_jsx(PriceTemplate,Object.assign({},props)
|
|
1
|
+
import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(skuPrices,code="")=>code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices),getPricesComponent=(skuPrices,props)=>isEmpty(skuPrices)?_jsx(PriceTemplate,Object.assign({},props)):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return _createElement(PriceTemplate,Object.assign({},props,{key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount}))});export default function getPrices(prices){const obj={};return isArray(prices)&&prices.forEach(p=>{const sku=p.sku_code;has(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}
|
package/lib/utils/getSkus.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const getSkus=(skus,sortBy)=>{const obj={};return sortBy.forEach(sku=>{skus.forEach(o=>{
|
|
1
|
+
const getSkus=(skus,sortBy)=>{const obj={};return sortBy.forEach(sku=>{skus.forEach(o=>{o?.code===sku&&(obj[o.code]=o)})}),obj};export default getSkus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useExternalScript(url: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect,useState}from"react";export default function useExternalScript(url){const[loaded,setLoaded]=useState(!1);return useEffect(()=>{const script=document.createElement("script");return script.src=url,script.async=!0,document.body.appendChild(script),script.onload=()=>{setLoaded(!0)},()=>{document.body.removeChild(script),setLoaded(!1)}},[url]),loaded}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";export const sortDescIcon=_jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},{children:_jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4"})})),sortAscIcon=_jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},{children:_jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isDate(value: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isDate(value){return!isNaN(Date.parse(value))}
|
package/lib/utils/jwt.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultImgUrl="https://data.commercelayer.app/assets/images/placeholders/img_placeholder.svg",defaultGiftCardImgUrl="https://data.commercelayer.app/assets/images/placeholders/gift_placeholder.svg";
|
package/lib/utils/promisify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import isFunction from"lodash/isFunction";export default function promisify(cb,params){return new Promise((resolve,reject)=>{params?cb(params,(err,res)=>{err&&reject(err),resolve(res)}):isFunction(cb
|
|
1
|
+
import isFunction from"lodash/isFunction";export default function promisify(cb,params){return new Promise((resolve,reject)=>{params?cb(params,(err,res)=>{err&&reject(err),resolve(res)}):isFunction(cb?.tokenize)?cb?.tokenize((err,payload)=>{err&&reject(err),resolve(payload)}):cb((err,res)=>{err&&reject(err),resolve(res)})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function scrollbarWidth(): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function scrollbarWidth(){if(typeof document>"u")return 0;const scrollDiv=document.createElement("div");scrollDiv.setAttribute("style","width: 100px; height: 100px; overflow: scroll; position:absolute; top:-9999px;"),document.body.appendChild(scrollDiv);const scrollbarWidth2=scrollDiv.offsetWidth-scrollDiv.clientWidth;return document.body.removeChild(scrollDiv),scrollbarWidth2}
|
package/lib/utils/shipments.d.ts
CHANGED
package/lib/utils/shipments.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}
|
|
1
|
+
import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}export function isDoNotShip(lineItems){const itemDoNotShip=[],items=lineItems?lineItems.filter(({item_type})=>item_type==="skus").map(lineItem=>{var _a;return lineItem.item&&((_a=lineItem.item)===null||_a===void 0?void 0:_a.do_not_ship)&&itemDoNotShip.push(!0),lineItem}):[];return itemDoNotShip.length>0&&itemDoNotShip.length===items.length}
|
|
@@ -2,6 +2,7 @@ import { BaseState } from '../typings/index';
|
|
|
2
2
|
import { ResourceErrorType, BaseError } from '../typings/errors';
|
|
3
3
|
import { AddressField } from '../reducers/AddressReducer';
|
|
4
4
|
import { AddressCreate } from '@commercelayer/sdk';
|
|
5
|
+
import { AddressInputName } from '../typings/index';
|
|
5
6
|
export interface ValidateFormFields {
|
|
6
7
|
<R extends string[]>(fields: HTMLFormControlsCollection, required: R, resourceType: ResourceErrorType): {
|
|
7
8
|
errors: BaseError[];
|
|
@@ -17,4 +18,5 @@ export interface FieldsExist {
|
|
|
17
18
|
(address: AddressCreate, schema?: AddressField[]): boolean;
|
|
18
19
|
}
|
|
19
20
|
export declare const fieldsExist: FieldsExist;
|
|
21
|
+
export declare function businessMandatoryField(fieldName: AddressInputName, isBusiness?: boolean): boolean;
|
|
20
22
|
export default validateFormFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import get from"lodash/get";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const isTick=!!get(v,"checked"),val=isTick||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.indexOf(attrName)!==-1||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values=Object.assign(Object.assign({},values),{[`${v.name}`]:val})}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?Object.assign(Object.assign({},values),{metadata:Object.assign(Object.assign({},values.metadata),{[`${v.name}`]:val})}):Object.assign(Object.assign({},values),{[`${v.name}`]:val}))}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};export default validateFormFields;
|
|
1
|
+
import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import get from"lodash/get";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const isTick=!!get(v,"checked"),val=isTick||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.indexOf(attrName)!==-1||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values=Object.assign(Object.assign({},values),{[`${v.name}`]:val})}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?Object.assign(Object.assign({},values),{metadata:Object.assign(Object.assign({},values.metadata),{[`${v.name}`]:val})}):Object.assign(Object.assign({},values),{[`${v.name}`]:val}))}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};const businessOptionalFields=["billing_address_first_name","billing_address_last_name","shipping_address_first_name","shipping_address_last_name","first_name","last_name"],customerOptionalFields=["billing_address_company","shipping_address_company","company"];export function businessMandatoryField(fieldName,isBusiness){return!(isBusiness&&businessOptionalFields.includes(fieldName)||!isBusiness&&customerOptionalFields.includes(fieldName))}export default validateFormFields;
|
package/package.json
CHANGED
|
@@ -1,57 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/react-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"description": "The Official Commerce Layer React Components",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
6
7
|
"files": [
|
|
7
8
|
"lib",
|
|
8
9
|
"package.json",
|
|
9
10
|
"README.md"
|
|
10
11
|
],
|
|
11
|
-
"
|
|
12
|
-
"
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./lib/index.js",
|
|
14
|
+
"./auth/*": "./lib/components/auth/*.js",
|
|
15
|
+
"./orders/*": "./lib/components/orders/*.js",
|
|
16
|
+
"./skus/*": "./lib/components/skus/*.js",
|
|
17
|
+
"./customers/*": "./lib/components/customers/*.js"
|
|
13
18
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"plugins": [
|
|
30
|
-
"@semantic-release/commit-analyzer",
|
|
31
|
-
"@semantic-release/release-notes-generator",
|
|
32
|
-
"@semantic-release/changelog",
|
|
33
|
-
"@semantic-release/npm",
|
|
34
|
-
"@semantic-release/git",
|
|
35
|
-
[
|
|
36
|
-
"@semantic-release/github",
|
|
37
|
-
{
|
|
38
|
-
"addReleases": "top"
|
|
39
|
-
}
|
|
19
|
+
"typesVersions": {
|
|
20
|
+
"*": {
|
|
21
|
+
"auth/*": [
|
|
22
|
+
"lib/components/auth/*.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"orders/*": [
|
|
25
|
+
"lib/components/orders/*.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"skus/*": [
|
|
28
|
+
"lib/components/skus/*.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"customers/*": [
|
|
31
|
+
"lib/components/customers/*.d.ts"
|
|
40
32
|
]
|
|
41
|
-
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
42
37
|
},
|
|
43
38
|
"scripts": {
|
|
44
39
|
"test": "jest",
|
|
45
40
|
"test:coverage": "jest --coverage",
|
|
46
|
-
"
|
|
41
|
+
"test:e2e": "NODE_ENV=test playwright test",
|
|
42
|
+
"test:e2e:coverage": "nyc pnpm test:e2e && pnpm coverage:report",
|
|
43
|
+
"coverage:report": "nyc report --reporter=html",
|
|
44
|
+
"lint": "eslint src",
|
|
45
|
+
"build": "tsc -b tsconfig.prod.json --verbose && pnpm postbuild",
|
|
46
|
+
"build:dev": "tsc -b tsconfig.prod.json --verbose && tsc-alias -p tsconfig.prod.json",
|
|
47
47
|
"postbuild": "tsc-alias -p tsconfig.prod.json && minimize-js lib -w -s",
|
|
48
|
-
"start": "NODE_OPTIONS='--inspect' next dev"
|
|
49
|
-
"version:fix": "npm version patch",
|
|
50
|
-
"version:feat": "npm version minor",
|
|
51
|
-
"version:perf": "npm version major",
|
|
52
|
-
"publish:fix": "npm run build && npm run version:fix && git push --follow-tags && npm publish --access public",
|
|
53
|
-
"publish:feat": "npm run build && npm run version:feat && git push --follow-tags && npm publish --access public",
|
|
54
|
-
"publish:perf": "npm run build && npm run version:perf && git push --follow-tags && npm publish --access public"
|
|
48
|
+
"start": "NODE_OPTIONS='--inspect' next dev"
|
|
55
49
|
},
|
|
56
50
|
"repository": {
|
|
57
51
|
"type": "git",
|
|
@@ -76,77 +70,86 @@
|
|
|
76
70
|
},
|
|
77
71
|
"homepage": "https://github.com/commercelayer/commercelayer-react-components#readme",
|
|
78
72
|
"dependencies": {
|
|
79
|
-
"@ac-dev/countries-service": "^1.
|
|
80
|
-
"@ac-dev/states-service": "^1.0
|
|
81
|
-
"@adyen/adyen-web": "^5.
|
|
82
|
-
"@commercelayer/
|
|
83
|
-
"@
|
|
84
|
-
"@stripe/
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
73
|
+
"@ac-dev/countries-service": "^1.2.0",
|
|
74
|
+
"@ac-dev/states-service": "^1.1.0",
|
|
75
|
+
"@adyen/adyen-web": "^5.16.2",
|
|
76
|
+
"@commercelayer/sdk": "^4.14.0",
|
|
77
|
+
"@stripe/react-stripe-js": "^1.9.0",
|
|
78
|
+
"@stripe/stripe-js": "^1.32.0",
|
|
79
|
+
"axios": "^0.27.2",
|
|
80
|
+
"braintree-web": "^3.85.3",
|
|
81
|
+
"frames-react": "^1.0.10",
|
|
88
82
|
"jwt-decode": "^3.1.2",
|
|
89
83
|
"lodash": "^4.17.21",
|
|
90
84
|
"lodash-es": "^4.17.21",
|
|
91
|
-
"rapid-form": "^1.6.
|
|
85
|
+
"rapid-form": "^1.6.2",
|
|
86
|
+
"react-table": "^7.8.0",
|
|
87
|
+
"react-window": "^1.8.7"
|
|
92
88
|
},
|
|
93
89
|
"devDependencies": {
|
|
94
|
-
"@babel/
|
|
95
|
-
"@babel/
|
|
96
|
-
"@babel/
|
|
97
|
-
"@babel/
|
|
98
|
-
"@
|
|
90
|
+
"@babel/core": "^7.18.5",
|
|
91
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
92
|
+
"@babel/plugin-syntax-flow": "^7.17.12",
|
|
93
|
+
"@babel/plugin-transform-react-jsx": "^7.17.12",
|
|
94
|
+
"@babel/preset-env": "^7.18.2",
|
|
95
|
+
"@babel/preset-react": "^7.17.12",
|
|
96
|
+
"@babel/preset-typescript": "^7.17.12",
|
|
97
|
+
"@commercelayer/js-auth": "^2.3.0",
|
|
98
|
+
"@playwright/test": "^1.22.2",
|
|
99
99
|
"@semantic-release/changelog": "^6.0.1",
|
|
100
100
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
101
101
|
"@semantic-release/git": "^10.0.1",
|
|
102
|
-
"@semantic-release/github": "^8.0.
|
|
103
|
-
"@semantic-release/npm": "^
|
|
102
|
+
"@semantic-release/github": "^8.0.4",
|
|
103
|
+
"@semantic-release/npm": "^9.0.1",
|
|
104
104
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
105
|
-
"@tailwindcss/aspect-ratio": "^0.
|
|
106
|
-
"@tailwindcss/forms": "^0.
|
|
107
|
-
"@tailwindcss/
|
|
108
|
-
"@
|
|
109
|
-
"@types/
|
|
110
|
-
"@types/
|
|
111
|
-
"@types/
|
|
112
|
-
"@types/
|
|
113
|
-
"@types/
|
|
114
|
-
"@types/react
|
|
115
|
-
"@
|
|
116
|
-
"@
|
|
117
|
-
"@
|
|
105
|
+
"@tailwindcss/aspect-ratio": "^0.4.0",
|
|
106
|
+
"@tailwindcss/forms": "^0.5.2",
|
|
107
|
+
"@tailwindcss/line-clamp": "^0.4.0",
|
|
108
|
+
"@tailwindcss/typography": "^0.5.2",
|
|
109
|
+
"@types/braintree-web": "^3.75.19",
|
|
110
|
+
"@types/jest": "^27.5.2",
|
|
111
|
+
"@types/lodash": "^4.14.182",
|
|
112
|
+
"@types/node": "^17.0.45",
|
|
113
|
+
"@types/prop-types": "^15.7.5",
|
|
114
|
+
"@types/react": "^17.0.47",
|
|
115
|
+
"@types/react-table": "^7.7.12",
|
|
116
|
+
"@types/react-test-renderer": "^17.0.2",
|
|
117
|
+
"@types/react-window": "^1.8.5",
|
|
118
|
+
"@typescript-eslint/eslint-plugin": "^5.29.0",
|
|
119
|
+
"@typescript-eslint/parser": "^5.29.0",
|
|
118
120
|
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
119
|
-
"autoprefixer": "^10.4.
|
|
120
|
-
"babel-jest": "^
|
|
121
|
-
"babel-loader": "^8.2.
|
|
121
|
+
"autoprefixer": "^10.4.7",
|
|
122
|
+
"babel-jest": "^28.1.1",
|
|
123
|
+
"babel-loader": "^8.2.5",
|
|
122
124
|
"babel-plugin-istanbul": "^6.1.1",
|
|
123
|
-
"dotenv": "^
|
|
124
|
-
"eslint": "^8.
|
|
125
|
-
"eslint-config-prettier": "^8.
|
|
126
|
-
"eslint-config-react-app": "^
|
|
127
|
-
"eslint-plugin-react": "^7.
|
|
128
|
-
"eslint-plugin-react-hooks": "^4.
|
|
129
|
-
"jest": "^
|
|
130
|
-
"minimize-js": "^1.
|
|
131
|
-
"next": "^12.
|
|
132
|
-
"
|
|
133
|
-
"
|
|
125
|
+
"dotenv": "^16.0.1",
|
|
126
|
+
"eslint": "^8.18.0",
|
|
127
|
+
"eslint-config-prettier": "^8.5.0",
|
|
128
|
+
"eslint-config-react-app": "^7.0.1",
|
|
129
|
+
"eslint-plugin-react": "^7.30.1",
|
|
130
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
131
|
+
"jest": "^28.1.1",
|
|
132
|
+
"minimize-js": "^1.3.0",
|
|
133
|
+
"next": "^12.1.6",
|
|
134
|
+
"nyc": "^15.1.0",
|
|
135
|
+
"playwright": "^1.22.2",
|
|
136
|
+
"postcss": "^8.4.14",
|
|
134
137
|
"postcss-loader": "^6.2.1",
|
|
135
|
-
"prettier": "^2.
|
|
136
|
-
"prop-types": "^15.
|
|
138
|
+
"prettier": "^2.7.1",
|
|
139
|
+
"prop-types": "^15.8.1",
|
|
137
140
|
"react": "^17.0.2",
|
|
138
141
|
"react-dom": "^17.0.2",
|
|
139
142
|
"react-test-renderer": "^17.0.2",
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"ts-
|
|
144
|
-
"
|
|
145
|
-
"tsc-alias": "^1.4.2",
|
|
143
|
+
"semantic-release": "^19.0.3",
|
|
144
|
+
"tailwindcss": "^3.1.4",
|
|
145
|
+
"ts-jest": "^28.0.5",
|
|
146
|
+
"ts-loader": "^9.3.1",
|
|
147
|
+
"tsc-alias": "^1.6.11",
|
|
146
148
|
"tsconfig-paths-jest": "^0.0.1",
|
|
147
|
-
"
|
|
148
|
-
"typescript": "^4.
|
|
149
|
-
"v8-to-istanbul": "^
|
|
149
|
+
"tslib": "^2.4.0",
|
|
150
|
+
"typescript": "^4.7.4",
|
|
151
|
+
"v8-to-istanbul": "^9.0.1",
|
|
152
|
+
"webpack": "^5.73.0"
|
|
150
153
|
},
|
|
151
154
|
"peerDependencies": {
|
|
152
155
|
"react": "^17.0.2"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent, PropsWithoutRef, ReactNode } from 'react';
|
|
2
|
-
import { FunctionChildren } from '../typings/index';
|
|
3
|
-
import { AddToCartReturn } from '../reducers/OrderReducer';
|
|
4
|
-
import { VariantOption } from './VariantSelector';
|
|
5
|
-
declare type ChildrenProps = {
|
|
6
|
-
handleClick: () => AddToCartReturn;
|
|
7
|
-
} & Omit<AddToCartButtonProps, 'children'>;
|
|
8
|
-
declare type AddToCartButtonChildrenProps = FunctionChildren<ChildrenProps>;
|
|
9
|
-
export declare type AddToCartButtonType = ChildrenProps;
|
|
10
|
-
declare type AddToCartButtonProps = {
|
|
11
|
-
children?: AddToCartButtonChildrenProps;
|
|
12
|
-
label?: string | ReactNode;
|
|
13
|
-
skuCode?: string;
|
|
14
|
-
bundleCode?: string;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
skuListId?: string;
|
|
17
|
-
lineItem?: VariantOption['lineItem'];
|
|
18
|
-
} & PropsWithoutRef<JSX.IntrinsicElements['button']>;
|
|
19
|
-
declare const AddToCartButton: FunctionComponent<AddToCartButtonProps>;
|
|
20
|
-
export default AddToCartButton;
|