@commercelayer/react-components 4.5.0-beta.9 → 4.5.2-beta.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.
Files changed (261) hide show
  1. package/lib/cjs/components/MetadataInput.d.ts +1 -0
  2. package/lib/cjs/components/addresses/Address.d.ts +2 -1
  3. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +1 -0
  4. package/lib/cjs/components/addresses/AddressInput.d.ts +1 -0
  5. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +1 -0
  6. package/lib/cjs/components/addresses/AddressesEmpty.d.ts +1 -0
  7. package/lib/cjs/components/addresses/BillingAddressForm.js +1 -1
  8. package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +1 -0
  9. package/lib/cjs/components/auth/CommerceLayer.d.ts +1 -0
  10. package/lib/cjs/components/customers/CustomerContainer.d.ts +1 -0
  11. package/lib/cjs/components/customers/CustomerField.d.ts +1 -0
  12. package/lib/cjs/components/customers/CustomerInput.d.ts +1 -0
  13. package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +1 -0
  14. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
  15. package/lib/cjs/components/customers/MyAccountLink.d.ts +2 -1
  16. package/lib/cjs/components/customers/MyIdentityLink.d.ts +2 -1
  17. package/lib/cjs/components/errors/Errors.d.ts +1 -0
  18. package/lib/cjs/components/gift_cards/GiftCard.d.ts +1 -0
  19. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
  20. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -0
  21. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
  22. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
  23. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
  24. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
  25. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
  26. package/lib/cjs/components/line_items/LineItem.d.ts +1 -0
  27. package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -0
  28. package/lib/cjs/components/line_items/LineItemCode.d.ts +1 -0
  29. package/lib/cjs/components/line_items/LineItemField.d.ts +1 -0
  30. package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -0
  31. package/lib/cjs/components/line_items/LineItemName.d.ts +1 -0
  32. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +1 -0
  33. package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -0
  34. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +1 -0
  35. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +1 -0
  36. package/lib/cjs/components/orders/CartLink.js +1 -1
  37. package/lib/cjs/components/orders/CheckoutLink.d.ts +1 -0
  38. package/lib/cjs/components/orders/DiscountAmount.d.ts +1 -0
  39. package/lib/cjs/components/orders/GiftCardAmount.d.ts +1 -0
  40. package/lib/cjs/components/orders/HostedCart.d.ts +2 -0
  41. package/lib/cjs/components/orders/HostedCart.js +1 -1
  42. package/lib/cjs/components/orders/OrderContainer.d.ts +1 -0
  43. package/lib/cjs/components/orders/OrderList.d.ts +1 -0
  44. package/lib/cjs/components/orders/OrderListEmpty.d.ts +1 -0
  45. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +1 -0
  46. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +1 -0
  47. package/lib/cjs/components/orders/OrderListRow.d.ts +1 -0
  48. package/lib/cjs/components/orders/OrderNumber.d.ts +1 -0
  49. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +1 -0
  50. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
  51. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  52. package/lib/cjs/components/orders/ShippingAmount.d.ts +1 -0
  53. package/lib/cjs/components/orders/SubTotalAmount.d.ts +1 -0
  54. package/lib/cjs/components/orders/TaxesAmount.d.ts +1 -0
  55. package/lib/cjs/components/orders/TotalAmount.d.ts +1 -0
  56. package/lib/cjs/components/parcels/ParcelField.d.ts +1 -0
  57. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +1 -0
  58. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +1 -0
  59. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  60. package/lib/cjs/components/parcels/Parcels.d.ts +1 -0
  61. package/lib/cjs/components/parcels/ParcelsCount.d.ts +1 -0
  62. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -0
  63. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  64. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  65. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +1 -0
  66. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  67. package/lib/cjs/components/payment_gateways/KlarnaGateway.js +1 -1
  68. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +1 -0
  69. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -0
  70. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -0
  71. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  72. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -0
  73. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +1 -0
  74. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  75. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +2 -1
  76. package/lib/cjs/components/payment_source/BraintreePayment.js +1 -1
  77. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +1 -0
  78. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +1 -0
  79. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -0
  80. package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -1
  81. package/lib/cjs/components/payment_source/PaymentSource.d.ts +1 -0
  82. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  83. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  84. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  85. package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +1 -0
  86. package/lib/cjs/components/payment_source/StripePayment.d.ts +1 -1
  87. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +1 -0
  88. package/lib/cjs/components/prices/Price.d.ts +1 -0
  89. package/lib/cjs/components/prices/PricesContainer.d.ts +1 -0
  90. package/lib/cjs/components/shipments/Shipment.js +1 -1
  91. package/lib/cjs/components/shipments/ShipmentField.d.ts +1 -0
  92. package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -1
  93. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +1 -0
  94. package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -1
  95. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  96. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  97. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  98. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
  99. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +6 -0
  100. package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -1
  101. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +1 -0
  102. package/lib/cjs/components/skus/SkuField.d.ts +1 -0
  103. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +1 -0
  104. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +1 -0
  105. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -0
  106. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +1 -0
  107. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +1 -0
  108. package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -0
  109. package/lib/cjs/components/utils/getAllErrors.d.ts +1 -0
  110. package/lib/cjs/context/OrderContext.d.ts +3 -3
  111. package/lib/cjs/context/ShipmentChildrenContext.d.ts +1 -1
  112. package/lib/cjs/hooks/useCustomerContainer.d.ts +5 -0
  113. package/lib/cjs/hooks/useCustomerContainer.js +2 -0
  114. package/lib/cjs/hooks/useOrderContainer.d.ts +9 -5
  115. package/lib/cjs/hooks/useOrderContainer.js +1 -1
  116. package/lib/cjs/reducers/GiftCardReducer.d.ts +2 -2
  117. package/lib/cjs/reducers/GiftCardReducer.js +1 -1
  118. package/lib/cjs/reducers/OrderReducer.d.ts +1 -2
  119. package/lib/cjs/reducers/OrderReducer.js +1 -1
  120. package/lib/cjs/reducers/PlaceOrderReducer.js +1 -1
  121. package/lib/cjs/typings/globals.d.ts +1 -0
  122. package/lib/cjs/utils/filterChildren.d.ts +1 -0
  123. package/lib/cjs/utils/getCardDetails.d.ts +1 -1
  124. package/lib/cjs/utils/getCardDetails.js +1 -1
  125. package/lib/cjs/utils/getLoaderComponent.d.ts +1 -0
  126. package/lib/cjs/utils/getPaymentAttributes.d.ts +1 -1
  127. package/lib/cjs/utils/getPaymentAttributes.js +1 -1
  128. package/lib/cjs/utils/getPrices.d.ts +1 -0
  129. package/lib/cjs/utils/shipments.js +1 -1
  130. package/lib/cjs/utils/validateFormFields.js +1 -1
  131. package/lib/esm/components/MetadataInput.d.ts +1 -0
  132. package/lib/esm/components/addresses/Address.d.ts +2 -1
  133. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +1 -0
  134. package/lib/esm/components/addresses/AddressInput.d.ts +1 -0
  135. package/lib/esm/components/addresses/AddressStateSelector.d.ts +1 -0
  136. package/lib/esm/components/addresses/AddressesEmpty.d.ts +1 -0
  137. package/lib/esm/components/addresses/BillingAddressForm.js +1 -1
  138. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +1 -0
  139. package/lib/esm/components/auth/CommerceLayer.d.ts +1 -0
  140. package/lib/esm/components/customers/CustomerContainer.d.ts +1 -0
  141. package/lib/esm/components/customers/CustomerField.d.ts +1 -0
  142. package/lib/esm/components/customers/CustomerInput.d.ts +1 -0
  143. package/lib/esm/components/customers/CustomerPaymentSource.d.ts +1 -0
  144. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
  145. package/lib/esm/components/customers/MyAccountLink.d.ts +2 -1
  146. package/lib/esm/components/customers/MyIdentityLink.d.ts +2 -1
  147. package/lib/esm/components/errors/Errors.d.ts +1 -0
  148. package/lib/esm/components/gift_cards/GiftCard.d.ts +1 -0
  149. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
  150. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -0
  151. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
  152. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
  153. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
  154. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
  155. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
  156. package/lib/esm/components/line_items/LineItem.d.ts +1 -0
  157. package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -0
  158. package/lib/esm/components/line_items/LineItemCode.d.ts +1 -0
  159. package/lib/esm/components/line_items/LineItemField.d.ts +1 -0
  160. package/lib/esm/components/line_items/LineItemImage.d.ts +1 -0
  161. package/lib/esm/components/line_items/LineItemName.d.ts +1 -0
  162. package/lib/esm/components/line_items/LineItemsContainer.d.ts +1 -0
  163. package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -0
  164. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +1 -0
  165. package/lib/esm/components/orders/AdjustmentAmount.d.ts +1 -0
  166. package/lib/esm/components/orders/CartLink.js +1 -1
  167. package/lib/esm/components/orders/CheckoutLink.d.ts +1 -0
  168. package/lib/esm/components/orders/DiscountAmount.d.ts +1 -0
  169. package/lib/esm/components/orders/GiftCardAmount.d.ts +1 -0
  170. package/lib/esm/components/orders/HostedCart.d.ts +2 -0
  171. package/lib/esm/components/orders/HostedCart.js +1 -1
  172. package/lib/esm/components/orders/OrderContainer.d.ts +1 -0
  173. package/lib/esm/components/orders/OrderList.d.ts +1 -0
  174. package/lib/esm/components/orders/OrderListEmpty.d.ts +1 -0
  175. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +1 -0
  176. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +1 -0
  177. package/lib/esm/components/orders/OrderListRow.d.ts +1 -0
  178. package/lib/esm/components/orders/OrderNumber.d.ts +1 -0
  179. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +1 -0
  180. package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
  181. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  182. package/lib/esm/components/orders/ShippingAmount.d.ts +1 -0
  183. package/lib/esm/components/orders/SubTotalAmount.d.ts +1 -0
  184. package/lib/esm/components/orders/TaxesAmount.d.ts +1 -0
  185. package/lib/esm/components/orders/TotalAmount.d.ts +1 -0
  186. package/lib/esm/components/parcels/ParcelField.d.ts +1 -0
  187. package/lib/esm/components/parcels/ParcelLineItem.d.ts +1 -0
  188. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +1 -0
  189. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  190. package/lib/esm/components/parcels/Parcels.d.ts +1 -0
  191. package/lib/esm/components/parcels/ParcelsCount.d.ts +1 -0
  192. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -0
  193. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  194. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  195. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +1 -0
  196. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  197. package/lib/esm/components/payment_gateways/KlarnaGateway.js +1 -1
  198. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +1 -0
  199. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -0
  200. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -0
  201. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  202. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -0
  203. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +1 -0
  204. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  205. package/lib/esm/components/payment_source/BraintreePayment.d.ts +2 -1
  206. package/lib/esm/components/payment_source/BraintreePayment.js +1 -1
  207. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +1 -0
  208. package/lib/esm/components/payment_source/ExternalPayment.d.ts +1 -0
  209. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -0
  210. package/lib/esm/components/payment_source/KlarnaPayment.js +1 -1
  211. package/lib/esm/components/payment_source/PaymentSource.d.ts +1 -0
  212. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  213. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  214. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  215. package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +1 -0
  216. package/lib/esm/components/payment_source/StripePayment.d.ts +1 -1
  217. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +1 -0
  218. package/lib/esm/components/prices/Price.d.ts +1 -0
  219. package/lib/esm/components/prices/PricesContainer.d.ts +1 -0
  220. package/lib/esm/components/shipments/Shipment.js +1 -1
  221. package/lib/esm/components/shipments/ShipmentField.d.ts +1 -0
  222. package/lib/esm/components/shipments/ShipmentsContainer.js +1 -1
  223. package/lib/esm/components/shipments/ShipmentsCount.d.ts +1 -0
  224. package/lib/esm/components/shipping_methods/ShippingMethod.js +1 -1
  225. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  226. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  227. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  228. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
  229. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +6 -0
  230. package/lib/esm/components/skus/AvailabilityTemplate.js +1 -1
  231. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +1 -0
  232. package/lib/esm/components/skus/SkuField.d.ts +1 -0
  233. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +1 -0
  234. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +1 -0
  235. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -0
  236. package/lib/esm/components/utils/BaseOrderPrice.d.ts +1 -0
  237. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +1 -0
  238. package/lib/esm/components/utils/PriceTemplate.d.ts +1 -0
  239. package/lib/esm/components/utils/getAllErrors.d.ts +1 -0
  240. package/lib/esm/context/OrderContext.d.ts +3 -3
  241. package/lib/esm/context/ShipmentChildrenContext.d.ts +1 -1
  242. package/lib/esm/hooks/useCustomerContainer.d.ts +5 -0
  243. package/lib/esm/hooks/useCustomerContainer.js +2 -0
  244. package/lib/esm/hooks/useOrderContainer.d.ts +9 -5
  245. package/lib/esm/hooks/useOrderContainer.js +1 -1
  246. package/lib/esm/reducers/GiftCardReducer.d.ts +2 -2
  247. package/lib/esm/reducers/GiftCardReducer.js +1 -1
  248. package/lib/esm/reducers/OrderReducer.d.ts +1 -2
  249. package/lib/esm/reducers/OrderReducer.js +1 -1
  250. package/lib/esm/reducers/PlaceOrderReducer.js +1 -1
  251. package/lib/esm/typings/globals.d.ts +1 -0
  252. package/lib/esm/utils/filterChildren.d.ts +1 -0
  253. package/lib/esm/utils/getCardDetails.d.ts +1 -1
  254. package/lib/esm/utils/getCardDetails.js +1 -1
  255. package/lib/esm/utils/getLoaderComponent.d.ts +1 -0
  256. package/lib/esm/utils/getPaymentAttributes.d.ts +1 -1
  257. package/lib/esm/utils/getPaymentAttributes.js +1 -1
  258. package/lib/esm/utils/getPrices.d.ts +1 -0
  259. package/lib/esm/utils/shipments.js +1 -1
  260. package/lib/esm/utils/validateFormFields.js +1 -1
  261. package/package.json +22 -22
@@ -10,7 +10,7 @@ interface CardDetails {
10
10
  }
11
11
  interface Args {
12
12
  paymentType: PaymentResource;
13
- customerPayment: Partial<CustomerPaymentSource>;
13
+ customerPayment: CustomerPaymentSource;
14
14
  }
15
15
  export default function getCardDetails({ paymentType, customerPayment }: Args): CardDetails;
16
16
  export {};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export default function getCardDetails({paymentType,customerPayment}){switch(paymentType){case"checkout_com_payments":{const source=customerPayment.payment_source?.payment_response?.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":{const ps=customerPayment.payment_source,source=ps?.options?.card??ps?.payment_method?.card??ps?.payment_instrument?{brand:ps?.payment_instrument?.card_type,exp_month:ps?.payment_instrument?.card_expiry_month,exp_year:ps?.payment_instrument?.card_expiry_year,last4:ps?.payment_instrument?.card_last_digits,issuer_type:ps?.payment_instrument?.issuer_type}:void 0;if(source)return{...source};break}case"braintree_payments":{const source=customerPayment.payment_source?.options?.card;if(source)return{...source};break}case"adyen_payments":{const ps=customerPayment.payment_source,source=ps?.payment_request_data?.payment_method,authorized=ps?.payment_response?.resultCode==="Authorised",last4=ps?.payment_response?.additionalData?.cardSummary??ps?.payment_instrument?.card_last_digits??"****";if(source&&authorized){const brand=source.type==="scheme"?source.brand??"credit-card":source.type.replace("_account","");return{...source,last4,brand}}break}default:{const source=customerPayment.payment_source?.metadata?.card;if(source)return{...source};break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****",issuer_type:""}}
2
+ export default function getCardDetails({paymentType,customerPayment}){switch(paymentType){case"checkout_com_payments":{const source=customerPayment.payment_source?.payment_response?.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":{const ps=customerPayment.payment_source,source=ps?.options?.card??ps?.payment_method?.card??ps?.payment_instrument?{brand:ps?.payment_instrument?.card_type,exp_month:ps?.payment_instrument?.card_expiry_month,exp_year:ps?.payment_instrument?.card_expiry_year,last4:ps?.payment_instrument?.card_last_digits,issuer_type:ps?.payment_instrument?.issuer_type}:void 0;if(source)return{...source};break}case"klarna_payments":{const ps=customerPayment.payment_source,source=ps?.payment_instrument?{brand:"klarna",exp_month:"",exp_year:"",last4:"",issuer_type:ps?.payment_instrument?.issuer_type}:void 0;if(source)return{...source};break}case"braintree_payments":{const source=customerPayment.payment_source?.options?.card;if(source)return{...source};break}case"adyen_payments":{const ps=customerPayment.payment_source,source=ps?.payment_request_data?.payment_method,authorized=ps?.payment_response?.resultCode==="Authorised",last4=ps?.payment_response?.additionalData?.cardSummary??ps?.payment_instrument?.card_last_digits??"****";if(source&&authorized){const brand=source.type==="scheme"?source.brand??"credit-card":source.type.replace("_account","");return{...source,last4,brand}}break}default:{const source=customerPayment.payment_source?.metadata?.card;if(source)return{...source};break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****",issuer_type:""}}
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import { type LoaderType } from '../typings/index';
2
3
  export default function getLoaderComponent(loader: LoaderType): JSX.Element;
@@ -12,6 +12,6 @@ interface Params<R extends PaymentResource, C extends PaymentMethodConfig> {
12
12
  export type ResourceKeys<K extends PaymentResource> = SnakeToCamelCase<StringReplace<StringReplace<K, 'payments', 'payment'>, 'transfers', 'transfer'>>;
13
13
  export declare function getPaymentAttributes<R extends PaymentResource = PaymentResource, C extends PaymentMethodConfig = PaymentMethodConfig>(params: Params<R, C>): Pick<C, ResourceKeys<R>> | undefined;
14
14
  export declare function getPaypalAttributes(paymentResource: PaymentResource, config: PaymentMethodConfig): Pick<PaypalConfig, 'return_url' | 'cancel_url'> | undefined;
15
- export declare function getStripeAttributes(paymentResource: PaymentResource, config: PaymentMethodConfig): Pick<StripeConfig, 'return_url'> | undefined;
16
15
  export declare function getExternalPaymentAttributes(paymentResource: PaymentResource, config: PaymentMethodConfig): Pick<ExternalPayment, 'payment_source_token'> | undefined;
16
+ export declare function getStripeAttributes(paymentResource: PaymentResource, config: PaymentMethodConfig): Pick<StripeConfig, 'return_url'> | undefined;
17
17
  export {};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{getPaymentConfig}from"../reducers/PaymentMethodReducer";import{pick}from"./pick";import{replace}from"./replace";import{snakeToCamelCase}from"./snakeToCamelCase";export function getPaymentAttributes(params){const{resource,config,keys}=params,attributes=getPaymentConfig(resource,config),keysCamelCase=keys.map(key=>{const k=replace(replace(key,"payments","payment"),"transfers","transfer");return snakeToCamelCase(k)}),currentResource=snakeToCamelCase(replace(replace(resource,"payments","payment"),"transfers","transfer"));return attributes!=null&&currentResource in attributes?pick(attributes,keysCamelCase):void 0}export function getPaypalAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["paypal_payments"]});return attributes?.paypalPayment!=null&&"paypalPayment"in attributes?pick(attributes?.paypalPayment,["return_url","cancel_url"]):void 0}export function getStripeAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["stripe_payments"]});return attributes?.stripePayment!=null&&"stripePayment"in attributes?pick(attributes?.stripePayment,["return_url"]):void 0}export function getExternalPaymentAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["external_payments"]});return attributes?.externalPayment!=null&&"externalPayment"in attributes?pick(attributes?.externalPayment,["payment_source_token"]):void 0}
2
+ import{getPaymentConfig}from"../reducers/PaymentMethodReducer";import{pick}from"./pick";import{replace}from"./replace";import{snakeToCamelCase}from"./snakeToCamelCase";export function getPaymentAttributes(params){const{resource,config,keys}=params,attributes=getPaymentConfig(resource,config),keysCamelCase=keys.map(key=>{const k=replace(replace(key,"payments","payment"),"transfers","transfer");return snakeToCamelCase(k)}),currentResource=snakeToCamelCase(replace(replace(resource,"payments","payment"),"transfers","transfer"));return attributes!=null&&currentResource in attributes?pick(attributes,keysCamelCase):void 0}export function getPaypalAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["paypal_payments"]});return attributes?.paypalPayment!=null&&"paypalPayment"in attributes?pick(attributes?.paypalPayment,["return_url","cancel_url"]):void 0}export function getExternalPaymentAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["external_payments"]});return attributes?.externalPayment!=null&&"externalPayment"in attributes?pick(attributes?.externalPayment,["payment_source_token"]):void 0}export function getStripeAttributes(paymentResource,config){const attributes=getPaymentAttributes({resource:paymentResource,config,keys:["stripe_payments"]});return attributes?.stripePayment!=null&&"stripePayment"in attributes?pick(attributes?.stripePayment,["return_url"]):void 0}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type Price } from '@commercelayer/sdk';
2
3
  import { type PTemplateProps } from '../components/utils/PriceTemplate';
3
4
  export declare function getPriceByCode(skuPrices: Price[], code?: string): Price | undefined;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}export function isDoNotShip(lineItems){const itemDoNotShip=[],items=lineItems?lineItems.filter(({item_type})=>item_type==="skus").map(lineItem=>(lineItem.item&&lineItem?.item?.do_not_ship&&itemDoNotShip.push(!0),lineItem)):[];return itemDoNotShip.length>0&&itemDoNotShip.length===items.length}
2
+ import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}export function isDoNotShip(lineItems){const itemDoNotShip=[],items=lineItems?lineItems.filter(({item_type})=>item_type==="skus").map(lineItem=>(lineItem.item?.do_not_ship&&itemDoNotShip.push(!0),lineItem)):[];return itemDoNotShip.length>0&&itemDoNotShip.length===items.length}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const val="checked"in v||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.includes(attrName)||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values={...values,[`${v.name}`]:val}}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?{...values,metadata:{...values.metadata,[`${v.name}`]:val}}:{...values,[`${v.name}`]:val})}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};const businessOptionalFields=["billing_address_first_name","billing_address_last_name","shipping_address_first_name","shipping_address_last_name","first_name","last_name"],customerOptionalFields=["billing_address_company","shipping_address_company","company"];export function businessMandatoryField(fieldName,isBusiness){return!(isBusiness&&businessOptionalFields.includes(fieldName)||!isBusiness&&customerOptionalFields.includes(fieldName))}export default validateFormFields;
2
+ import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const val="checked"in v||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.includes(attrName)||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values={...values,[`${v.name}`]:val}}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?{...values,metadata:{...values.metadata,[`${v.name}`]:val}}:{...values,[`${v.name}`]:val})}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name","line_2"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};const businessOptionalFields=["billing_address_first_name","billing_address_last_name","shipping_address_first_name","shipping_address_last_name","first_name","last_name"],customerOptionalFields=["billing_address_company","shipping_address_company","company"];export function businessMandatoryField(fieldName,isBusiness){return!(isBusiness&&businessOptionalFields.includes(fieldName)||!isBusiness&&customerOptionalFields.includes(fieldName))}export default validateFormFields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/react-components",
3
- "version": "4.5.0-beta.9",
3
+ "version": "4.5.2-beta.0",
4
4
  "description": "The Official Commerce Layer React Components",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -167,14 +167,14 @@
167
167
  "dependencies": {
168
168
  "@ac-dev/countries-service": "^1.2.0",
169
169
  "@ac-dev/states-service": "^1.1.1",
170
- "@adyen/adyen-web": "^5.49.3",
171
- "@commercelayer/sdk": "^5.10.0",
172
- "@stripe/react-stripe-js": "^2.1.2",
173
- "@stripe/stripe-js": "^2.0.0",
174
- "@tanstack/react-table": "^8.9.3",
170
+ "@adyen/adyen-web": "^5.51.0",
171
+ "@commercelayer/sdk": "^5.13.2",
172
+ "@stripe/react-stripe-js": "^2.2.0",
173
+ "@stripe/stripe-js": "^2.1.3",
174
+ "@tanstack/react-table": "^8.9.8",
175
175
  "@types/iframe-resizer": "^3.5.9",
176
- "axios": "^1.4.0",
177
- "braintree-web": "^3.97.0",
176
+ "axios": "^1.5.0",
177
+ "braintree-web": "^3.97.1",
178
178
  "frames-react": "^1.1.0",
179
179
  "iframe-resizer": "^4.3.6",
180
180
  "jwt-decode": "^3.1.2",
@@ -184,38 +184,38 @@
184
184
  "devDependencies": {
185
185
  "@commercelayer/js-auth": "^4.1.1",
186
186
  "@faker-js/faker": "^8.0.2",
187
- "@playwright/test": "^1.36.2",
187
+ "@playwright/test": "^1.37.1",
188
188
  "@testing-library/dom": "^9.3.1",
189
189
  "@testing-library/react": "^14.0.0",
190
- "@types/braintree-web": "^3.94.0",
191
- "@types/lodash": "^4.14.197",
192
- "@types/node": "^20.4.9",
190
+ "@types/braintree-web": "^3.96.4",
191
+ "@types/lodash": "^4.14.198",
192
+ "@types/node": "^20.6.0",
193
193
  "@types/prop-types": "^15.7.5",
194
- "@types/react": "^18.2.20",
195
- "@types/react-test-renderer": "^18.0.0",
194
+ "@types/react": "^18.2.21",
195
+ "@types/react-test-renderer": "^18.0.1",
196
196
  "@types/react-window": "^1.8.5",
197
197
  "@vitejs/plugin-react": "^4.0.4",
198
198
  "@vitest/coverage-c8": "^0.33.0",
199
199
  "jsdom": "^22.1.0",
200
200
  "minimize-js": "^1.4.0",
201
- "msw": "^1.2.3",
201
+ "msw": "^1.3.0",
202
202
  "react": "^18.2.0",
203
203
  "react-dom": "^18.2.0",
204
204
  "react-test-renderer": "^18.2.0",
205
205
  "tsc-alias": "^1.8.7",
206
- "tslib": "^2.6.1",
207
- "typescript": "^5.1.6",
206
+ "tslib": "^2.6.2",
207
+ "typescript": "^5.2.2",
208
208
  "vite": "^4.4.9",
209
- "vite-tsconfig-paths": "^4.2.0",
210
- "vitest": "^0.34.1"
209
+ "vite-tsconfig-paths": "^4.2.1",
210
+ "vitest": "^0.34.4"
211
211
  },
212
212
  "peerDependencies": {
213
213
  "react": "^18.0.0"
214
214
  },
215
215
  "scripts": {
216
- "lint": "eslint src",
217
- "lint:fix": "eslint src --fix",
218
- "test": "pnpm run lint && vitest run --silent",
216
+ "lint": "eslint src --ext .ts,.tsx",
217
+ "lint:fix": "eslint src --ext .ts,.tsx --fix",
218
+ "test": "pnpm lint && vitest run --silent",
219
219
  "coverage": "vitest run --coverage",
220
220
  "test:e2e": "NODE_ENV=test playwright test",
221
221
  "test:e2e:coverage": "nyc pnpm test:e2e && pnpm coverage:report",