@commercelayer/react-components 4.5.0-beta.2 → 4.5.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/lib/cjs/components/ExternalFunction.js +1 -0
  2. package/lib/cjs/components/MetadataInput.js +1 -0
  3. package/lib/cjs/components/SubmitButton.js +1 -0
  4. package/lib/cjs/components/addresses/Address.js +1 -0
  5. package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -0
  6. package/lib/cjs/components/addresses/AddressField.js +1 -0
  7. package/lib/cjs/components/addresses/AddressInput.js +1 -0
  8. package/lib/cjs/components/addresses/AddressStateSelector.js +1 -0
  9. package/lib/cjs/components/addresses/AddressesContainer.js +1 -0
  10. package/lib/cjs/components/addresses/AddressesEmpty.js +1 -0
  11. package/lib/cjs/components/addresses/BillingAddressContainer.js +1 -0
  12. package/lib/cjs/components/addresses/BillingAddressForm.js +1 -0
  13. package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -0
  14. package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -0
  15. package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -0
  16. package/lib/cjs/components/auth/CommerceLayer.js +1 -0
  17. package/lib/cjs/components/customers/CustomerAddressForm.js +1 -0
  18. package/lib/cjs/components/customers/CustomerContainer.js +1 -0
  19. package/lib/cjs/components/customers/CustomerField.js +1 -0
  20. package/lib/cjs/components/customers/CustomerInput.js +1 -0
  21. package/lib/cjs/components/customers/CustomerPaymentSource.js +1 -0
  22. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.js +1 -0
  23. package/lib/cjs/components/customers/MyAccountLink.d.ts +23 -0
  24. package/lib/cjs/components/customers/MyAccountLink.js +2 -0
  25. package/lib/cjs/components/customers/MyIdentityLink.d.ts +35 -0
  26. package/lib/cjs/components/customers/MyIdentityLink.js +2 -0
  27. package/lib/cjs/components/customers/SaveCustomerButton.js +1 -0
  28. package/lib/cjs/components/errors/Errors.js +1 -0
  29. package/lib/cjs/components/gift_cards/GiftCard.js +1 -0
  30. package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -0
  31. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -0
  32. package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -0
  33. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -0
  34. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -0
  35. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -0
  36. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
  37. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
  38. package/lib/cjs/components/gift_cards/GiftCardRecipientInput.js +1 -0
  39. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -0
  40. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.js +1 -0
  41. package/lib/cjs/components/line_items/LineItem.js +1 -0
  42. package/lib/cjs/components/line_items/LineItemAmount.js +1 -0
  43. package/lib/cjs/components/line_items/LineItemCode.js +1 -0
  44. package/lib/cjs/components/line_items/LineItemField.js +1 -0
  45. package/lib/cjs/components/line_items/LineItemImage.js +1 -0
  46. package/lib/cjs/components/line_items/LineItemName.js +1 -0
  47. package/lib/cjs/components/line_items/LineItemOption.js +1 -0
  48. package/lib/cjs/components/line_items/LineItemOptions.js +1 -0
  49. package/lib/cjs/components/line_items/LineItemQuantity.js +1 -0
  50. package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -0
  51. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -0
  52. package/lib/cjs/components/line_items/LineItemsCount.js +1 -0
  53. package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -0
  54. package/lib/cjs/components/orders/AddToCartButton.js +2 -1
  55. package/lib/cjs/components/orders/AdjustmentAmount.js +1 -0
  56. package/lib/cjs/components/orders/CartLink.d.ts +23 -0
  57. package/lib/cjs/components/orders/CartLink.js +2 -1
  58. package/lib/cjs/components/orders/CheckoutLink.js +2 -1
  59. package/lib/cjs/components/orders/DiscountAmount.js +1 -0
  60. package/lib/cjs/components/orders/GiftCardAmount.js +1 -0
  61. package/lib/cjs/components/orders/HostedCart.d.ts +30 -0
  62. package/lib/cjs/components/orders/HostedCart.js +2 -0
  63. package/lib/cjs/components/orders/OrderContainer.js +1 -0
  64. package/lib/cjs/components/orders/OrderList.js +1 -0
  65. package/lib/cjs/components/orders/OrderListEmpty.js +1 -0
  66. package/lib/cjs/components/orders/OrderListPaginationButtons.js +1 -0
  67. package/lib/cjs/components/orders/OrderListPaginationInfo.js +1 -0
  68. package/lib/cjs/components/orders/OrderListRow.js +1 -0
  69. package/lib/cjs/components/orders/OrderNumber.js +1 -0
  70. package/lib/cjs/components/orders/OrderStorage.js +1 -0
  71. package/lib/cjs/components/orders/PaymentMethodAmount.js +1 -0
  72. package/lib/cjs/components/orders/PlaceOrderButton.d.ts +13 -0
  73. package/lib/cjs/components/orders/PlaceOrderButton.js +2 -1
  74. package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -0
  75. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  76. package/lib/cjs/components/orders/ShippingAmount.js +1 -0
  77. package/lib/cjs/components/orders/SubTotalAmount.js +1 -0
  78. package/lib/cjs/components/orders/TaxesAmount.js +1 -0
  79. package/lib/cjs/components/orders/TotalAmount.js +1 -0
  80. package/lib/cjs/components/parcels/ParcelField.js +1 -0
  81. package/lib/cjs/components/parcels/ParcelLineItem.js +1 -0
  82. package/lib/cjs/components/parcels/ParcelLineItemField.js +1 -0
  83. package/lib/cjs/components/parcels/ParcelLineItemsCount.js +1 -0
  84. package/lib/cjs/components/parcels/Parcels.js +1 -0
  85. package/lib/cjs/components/parcels/ParcelsCount.js +1 -0
  86. package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -0
  87. package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -0
  88. package/lib/cjs/components/payment_gateways/CheckoutComGateway.js +1 -0
  89. package/lib/cjs/components/payment_gateways/ExternalGateway.js +1 -0
  90. package/lib/cjs/components/payment_gateways/KlarnaGateway.js +1 -0
  91. package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -0
  92. package/lib/cjs/components/payment_gateways/PaypalGateway.js +1 -0
  93. package/lib/cjs/components/payment_gateways/StripeGateway.js +2 -1
  94. package/lib/cjs/components/payment_gateways/WireTransferGateway.js +1 -0
  95. package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -0
  96. package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -0
  97. package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -0
  98. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -0
  99. package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -0
  100. package/lib/cjs/components/payment_source/AdyenPayment.js +1 -0
  101. package/lib/cjs/components/payment_source/BraintreePayment.js +1 -0
  102. package/lib/cjs/components/payment_source/CheckoutComPayment.js +1 -0
  103. package/lib/cjs/components/payment_source/ExternalPayment.js +1 -0
  104. package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -0
  105. package/lib/cjs/components/payment_source/PaymentSource.js +1 -0
  106. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -0
  107. package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -0
  108. package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -0
  109. package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -0
  110. package/lib/cjs/components/payment_source/PaypalPayment.js +1 -0
  111. package/lib/cjs/components/payment_source/StripeExpressPayment.js +1 -0
  112. package/lib/cjs/components/payment_source/StripePayment.js +1 -0
  113. package/lib/cjs/components/payment_source/WireTransferPayment.js +1 -0
  114. package/lib/cjs/components/prices/Price.js +1 -0
  115. package/lib/cjs/components/prices/PricesContainer.js +1 -0
  116. package/lib/cjs/components/shipments/Shipment.js +1 -0
  117. package/lib/cjs/components/shipments/ShipmentField.js +1 -0
  118. package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -0
  119. package/lib/cjs/components/shipments/ShipmentsCount.js +1 -0
  120. package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -0
  121. package/lib/cjs/components/shipping_methods/ShippingMethodName.js +1 -0
  122. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.js +1 -0
  123. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -0
  124. package/lib/cjs/components/skus/AvailabilityContainer.js +1 -0
  125. package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -0
  126. package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -0
  127. package/lib/cjs/components/skus/SkuField.js +1 -0
  128. package/lib/cjs/components/skus/SkuList.js +1 -0
  129. package/lib/cjs/components/skus/SkuListsContainer.js +1 -0
  130. package/lib/cjs/components/skus/Skus.js +1 -0
  131. package/lib/cjs/components/skus/SkusContainer.js +1 -0
  132. package/lib/cjs/components/stock_transfers/StockTransfer.js +1 -0
  133. package/lib/cjs/components/stock_transfers/StockTransferField.js +1 -0
  134. package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -0
  135. package/lib/cjs/components/utils/BaseField.js +1 -0
  136. package/lib/cjs/components/utils/BaseInput.js +1 -0
  137. package/lib/cjs/components/utils/BaseOrderPrice.js +1 -0
  138. package/lib/cjs/components/utils/BaseSelect.js +1 -0
  139. package/lib/cjs/components/utils/ErrorBoundary.js +1 -0
  140. package/lib/cjs/components/utils/GenericFieldComponent.js +1 -0
  141. package/lib/cjs/components/utils/Parent.js +1 -0
  142. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +27 -2
  143. package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -0
  144. package/lib/cjs/components/utils/PriceTemplate.js +1 -0
  145. package/lib/cjs/components/utils/getAllErrors.js +1 -0
  146. package/lib/cjs/config/currency.js +1 -0
  147. package/lib/cjs/context/AddressChildrenContext.js +1 -0
  148. package/lib/cjs/context/AddressContext.js +1 -0
  149. package/lib/cjs/context/AvailabilityContext.js +1 -0
  150. package/lib/cjs/context/BillingAddressContext.js +1 -0
  151. package/lib/cjs/context/BillingAddressFormContext.js +1 -0
  152. package/lib/cjs/context/CommerceLayerContext.js +1 -0
  153. package/lib/cjs/context/CouponAndGiftCardFormContext.js +1 -0
  154. package/lib/cjs/context/CustomerAddressFormContext.js +1 -0
  155. package/lib/cjs/context/CustomerContext.js +1 -0
  156. package/lib/cjs/context/CustomerPaymentSourceContext.js +1 -0
  157. package/lib/cjs/context/ExternalFunctionContext.js +1 -0
  158. package/lib/cjs/context/GiftCardContext.js +1 -0
  159. package/lib/cjs/context/InStockSubscriptionContext.js +1 -0
  160. package/lib/cjs/context/LineItemChildrenContext.js +1 -0
  161. package/lib/cjs/context/LineItemContext.js +1 -0
  162. package/lib/cjs/context/LineItemOptionChildrenContext.js +1 -0
  163. package/lib/cjs/context/OrderContext.js +1 -0
  164. package/lib/cjs/context/OrderListChildrenContext.js +1 -0
  165. package/lib/cjs/context/OrderListPaginationContext.js +1 -0
  166. package/lib/cjs/context/OrderStorageContext.js +1 -0
  167. package/lib/cjs/context/ParcelChildrenContext.js +1 -0
  168. package/lib/cjs/context/ParcelLineItemChildrenContext.js +1 -0
  169. package/lib/cjs/context/PaymentMethodChildrenContext.js +1 -0
  170. package/lib/cjs/context/PaymentMethodContext.js +1 -0
  171. package/lib/cjs/context/PaymentSourceContext.js +1 -0
  172. package/lib/cjs/context/PlaceOrderContext.js +1 -0
  173. package/lib/cjs/context/PricesContext.js +1 -0
  174. package/lib/cjs/context/ShipmentChildrenContext.js +1 -0
  175. package/lib/cjs/context/ShipmentContext.js +1 -0
  176. package/lib/cjs/context/ShippingAddressContext.js +1 -0
  177. package/lib/cjs/context/ShippingAddressFormContext.js +1 -0
  178. package/lib/cjs/context/ShippingMethodChildrenContext.js +1 -0
  179. package/lib/cjs/context/SkuChildrenContext.js +1 -0
  180. package/lib/cjs/context/SkuContext.js +1 -0
  181. package/lib/cjs/context/SkuListsContext.js +1 -0
  182. package/lib/cjs/context/StockTransferChildrenContext.js +1 -0
  183. package/lib/cjs/hooks/useCommerceLayer.js +1 -0
  184. package/lib/cjs/hooks/useOrderContainer.js +1 -0
  185. package/lib/cjs/index.js +1 -0
  186. package/lib/cjs/reducers/AddressReducer.js +1 -0
  187. package/lib/cjs/reducers/AvailabilityReducer.js +1 -0
  188. package/lib/cjs/reducers/BillingAddressReducer.js +1 -0
  189. package/lib/cjs/reducers/CustomerReducer.js +1 -0
  190. package/lib/cjs/reducers/GiftCardReducer.js +1 -0
  191. package/lib/cjs/reducers/InStockSubscriptionReducer.js +1 -0
  192. package/lib/cjs/reducers/LineItemReducer.js +1 -0
  193. package/lib/cjs/reducers/OrderReducer.js +1 -0
  194. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -0
  195. package/lib/cjs/reducers/PlaceOrderReducer.js +1 -0
  196. package/lib/cjs/reducers/PriceReducer.js +1 -0
  197. package/lib/cjs/reducers/ShipmentReducer.js +1 -0
  198. package/lib/cjs/reducers/ShippingAddressReducer.js +1 -0
  199. package/lib/cjs/reducers/SkuListsReducer.js +1 -0
  200. package/lib/cjs/reducers/SkuReducer.js +1 -0
  201. package/lib/cjs/typings/errors.js +1 -0
  202. package/lib/cjs/typings/globals.js +1 -0
  203. package/lib/cjs/typings/index.js +1 -0
  204. package/lib/cjs/utils/PropsType.js +1 -0
  205. package/lib/cjs/utils/addressesManager.js +1 -0
  206. package/lib/cjs/utils/baseReducer.js +1 -0
  207. package/lib/cjs/utils/browserInfo.js +1 -0
  208. package/lib/cjs/utils/checkIncludeResource.js +1 -0
  209. package/lib/cjs/utils/compareObjAttribute.js +1 -0
  210. package/lib/cjs/utils/countryStateCity.js +1 -0
  211. package/lib/cjs/utils/customMessages.js +1 -0
  212. package/lib/cjs/utils/customerOrderOptions.js +1 -0
  213. package/lib/cjs/utils/events.d.ts +5 -0
  214. package/lib/cjs/utils/events.js +2 -0
  215. package/lib/cjs/utils/expressPaymentHelper.js +1 -0
  216. package/lib/cjs/utils/filterChildren.js +1 -0
  217. package/lib/cjs/utils/getAmount.js +1 -0
  218. package/lib/cjs/utils/getApplicationLink.d.ts +31 -0
  219. package/lib/cjs/utils/getApplicationLink.js +2 -0
  220. package/lib/cjs/utils/getCardDetails.js +2 -1
  221. package/lib/cjs/utils/getDomain.js +1 -0
  222. package/lib/cjs/utils/getErrors.js +1 -0
  223. package/lib/cjs/utils/getLineItemsCount.js +1 -0
  224. package/lib/cjs/utils/getLoaderComponent.js +1 -0
  225. package/lib/cjs/utils/getPaymentAttributes.js +1 -0
  226. package/lib/cjs/utils/getPrices.js +1 -0
  227. package/lib/cjs/utils/getSdk.js +1 -0
  228. package/lib/cjs/utils/getSkus.js +1 -0
  229. package/lib/cjs/utils/hasSubscriptions.js +1 -0
  230. package/lib/cjs/utils/hooks/useCustomContext.js +1 -0
  231. package/lib/cjs/utils/hooks/useExternalScript.js +1 -0
  232. package/lib/cjs/utils/icons.js +1 -0
  233. package/lib/cjs/utils/isDate.js +1 -0
  234. package/lib/cjs/utils/isEmpty.js +1 -0
  235. package/lib/cjs/utils/isEmptyStates.js +1 -0
  236. package/lib/cjs/utils/isJSON.js +1 -0
  237. package/lib/cjs/utils/jwt.js +1 -0
  238. package/lib/cjs/utils/localStorage.js +1 -0
  239. package/lib/cjs/utils/omit.js +1 -0
  240. package/lib/cjs/utils/organization.js +1 -0
  241. package/lib/cjs/utils/pick.js +1 -0
  242. package/lib/cjs/utils/placeholderImages.js +1 -0
  243. package/lib/cjs/utils/promisify.js +1 -0
  244. package/lib/cjs/utils/replace.js +1 -0
  245. package/lib/cjs/utils/scrollbarWidth.js +1 -0
  246. package/lib/cjs/utils/shipments.js +1 -0
  247. package/lib/cjs/utils/snakeToCamelCase.js +1 -0
  248. package/lib/cjs/utils/validateFormFields.js +1 -0
  249. package/lib/esm/components/ExternalFunction.js +1 -0
  250. package/lib/esm/components/MetadataInput.js +1 -0
  251. package/lib/esm/components/SubmitButton.js +1 -0
  252. package/lib/esm/components/addresses/Address.js +1 -0
  253. package/lib/esm/components/addresses/AddressCountrySelector.js +1 -0
  254. package/lib/esm/components/addresses/AddressField.js +1 -0
  255. package/lib/esm/components/addresses/AddressInput.js +1 -0
  256. package/lib/esm/components/addresses/AddressStateSelector.js +1 -0
  257. package/lib/esm/components/addresses/AddressesContainer.js +1 -0
  258. package/lib/esm/components/addresses/AddressesEmpty.js +1 -0
  259. package/lib/esm/components/addresses/BillingAddressContainer.js +1 -0
  260. package/lib/esm/components/addresses/BillingAddressForm.js +1 -0
  261. package/lib/esm/components/addresses/SaveAddressesButton.js +1 -0
  262. package/lib/esm/components/addresses/ShippingAddressContainer.js +1 -0
  263. package/lib/esm/components/addresses/ShippingAddressForm.js +1 -0
  264. package/lib/esm/components/auth/CommerceLayer.js +1 -0
  265. package/lib/esm/components/customers/CustomerAddressForm.js +1 -0
  266. package/lib/esm/components/customers/CustomerContainer.js +1 -0
  267. package/lib/esm/components/customers/CustomerField.js +1 -0
  268. package/lib/esm/components/customers/CustomerInput.js +1 -0
  269. package/lib/esm/components/customers/CustomerPaymentSource.js +1 -0
  270. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.js +1 -0
  271. package/lib/esm/components/customers/MyAccountLink.d.ts +23 -0
  272. package/lib/esm/components/customers/MyAccountLink.js +2 -0
  273. package/lib/esm/components/customers/MyIdentityLink.d.ts +35 -0
  274. package/lib/esm/components/customers/MyIdentityLink.js +2 -0
  275. package/lib/esm/components/customers/SaveCustomerButton.js +1 -0
  276. package/lib/esm/components/errors/Errors.js +1 -0
  277. package/lib/esm/components/gift_cards/GiftCard.js +1 -0
  278. package/lib/esm/components/gift_cards/GiftCardContainer.js +1 -0
  279. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.js +1 -0
  280. package/lib/esm/components/gift_cards/GiftCardInput.js +1 -0
  281. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.js +1 -0
  282. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.js +1 -0
  283. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.js +1 -0
  284. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
  285. package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
  286. package/lib/esm/components/gift_cards/GiftCardRecipientInput.js +1 -0
  287. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -0
  288. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.js +1 -0
  289. package/lib/esm/components/line_items/LineItem.js +1 -0
  290. package/lib/esm/components/line_items/LineItemAmount.js +1 -0
  291. package/lib/esm/components/line_items/LineItemCode.js +1 -0
  292. package/lib/esm/components/line_items/LineItemField.js +1 -0
  293. package/lib/esm/components/line_items/LineItemImage.js +1 -0
  294. package/lib/esm/components/line_items/LineItemName.js +1 -0
  295. package/lib/esm/components/line_items/LineItemOption.js +1 -0
  296. package/lib/esm/components/line_items/LineItemOptions.js +1 -0
  297. package/lib/esm/components/line_items/LineItemQuantity.js +1 -0
  298. package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -0
  299. package/lib/esm/components/line_items/LineItemsContainer.js +1 -0
  300. package/lib/esm/components/line_items/LineItemsCount.js +1 -0
  301. package/lib/esm/components/line_items/LineItemsEmpty.js +1 -0
  302. package/lib/esm/components/orders/AddToCartButton.js +2 -1
  303. package/lib/esm/components/orders/AdjustmentAmount.js +1 -0
  304. package/lib/esm/components/orders/CartLink.d.ts +23 -0
  305. package/lib/esm/components/orders/CartLink.js +2 -1
  306. package/lib/esm/components/orders/CheckoutLink.js +2 -1
  307. package/lib/esm/components/orders/DiscountAmount.js +1 -0
  308. package/lib/esm/components/orders/GiftCardAmount.js +1 -0
  309. package/lib/esm/components/orders/HostedCart.d.ts +30 -0
  310. package/lib/esm/components/orders/HostedCart.js +2 -0
  311. package/lib/esm/components/orders/OrderContainer.js +1 -0
  312. package/lib/esm/components/orders/OrderList.js +1 -0
  313. package/lib/esm/components/orders/OrderListEmpty.js +1 -0
  314. package/lib/esm/components/orders/OrderListPaginationButtons.js +1 -0
  315. package/lib/esm/components/orders/OrderListPaginationInfo.js +1 -0
  316. package/lib/esm/components/orders/OrderListRow.js +1 -0
  317. package/lib/esm/components/orders/OrderNumber.js +1 -0
  318. package/lib/esm/components/orders/OrderStorage.js +1 -0
  319. package/lib/esm/components/orders/PaymentMethodAmount.js +1 -0
  320. package/lib/esm/components/orders/PlaceOrderButton.d.ts +13 -0
  321. package/lib/esm/components/orders/PlaceOrderButton.js +2 -1
  322. package/lib/esm/components/orders/PlaceOrderContainer.js +1 -0
  323. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  324. package/lib/esm/components/orders/ShippingAmount.js +1 -0
  325. package/lib/esm/components/orders/SubTotalAmount.js +1 -0
  326. package/lib/esm/components/orders/TaxesAmount.js +1 -0
  327. package/lib/esm/components/orders/TotalAmount.js +1 -0
  328. package/lib/esm/components/parcels/ParcelField.js +1 -0
  329. package/lib/esm/components/parcels/ParcelLineItem.js +1 -0
  330. package/lib/esm/components/parcels/ParcelLineItemField.js +1 -0
  331. package/lib/esm/components/parcels/ParcelLineItemsCount.js +1 -0
  332. package/lib/esm/components/parcels/Parcels.js +1 -0
  333. package/lib/esm/components/parcels/ParcelsCount.js +1 -0
  334. package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -0
  335. package/lib/esm/components/payment_gateways/BraintreeGateway.js +1 -0
  336. package/lib/esm/components/payment_gateways/CheckoutComGateway.js +1 -0
  337. package/lib/esm/components/payment_gateways/ExternalGateway.js +1 -0
  338. package/lib/esm/components/payment_gateways/KlarnaGateway.js +1 -0
  339. package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -0
  340. package/lib/esm/components/payment_gateways/PaypalGateway.js +1 -0
  341. package/lib/esm/components/payment_gateways/StripeGateway.js +2 -1
  342. package/lib/esm/components/payment_gateways/WireTransferGateway.js +1 -0
  343. package/lib/esm/components/payment_methods/PaymentMethod.js +1 -0
  344. package/lib/esm/components/payment_methods/PaymentMethodName.js +1 -0
  345. package/lib/esm/components/payment_methods/PaymentMethodPrice.js +1 -0
  346. package/lib/esm/components/payment_methods/PaymentMethodRadioButton.js +1 -0
  347. package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -0
  348. package/lib/esm/components/payment_source/AdyenPayment.js +1 -0
  349. package/lib/esm/components/payment_source/BraintreePayment.js +1 -0
  350. package/lib/esm/components/payment_source/CheckoutComPayment.js +1 -0
  351. package/lib/esm/components/payment_source/ExternalPayment.js +1 -0
  352. package/lib/esm/components/payment_source/KlarnaPayment.js +1 -0
  353. package/lib/esm/components/payment_source/PaymentSource.js +1 -0
  354. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.js +1 -0
  355. package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -0
  356. package/lib/esm/components/payment_source/PaymentSourceDetail.js +1 -0
  357. package/lib/esm/components/payment_source/PaymentSourceEditButton.js +1 -0
  358. package/lib/esm/components/payment_source/PaypalPayment.js +1 -0
  359. package/lib/esm/components/payment_source/StripeExpressPayment.js +1 -0
  360. package/lib/esm/components/payment_source/StripePayment.js +1 -0
  361. package/lib/esm/components/payment_source/WireTransferPayment.js +1 -0
  362. package/lib/esm/components/prices/Price.js +1 -0
  363. package/lib/esm/components/prices/PricesContainer.js +1 -0
  364. package/lib/esm/components/shipments/Shipment.js +1 -0
  365. package/lib/esm/components/shipments/ShipmentField.js +1 -0
  366. package/lib/esm/components/shipments/ShipmentsContainer.js +1 -0
  367. package/lib/esm/components/shipments/ShipmentsCount.js +1 -0
  368. package/lib/esm/components/shipping_methods/ShippingMethod.js +1 -0
  369. package/lib/esm/components/shipping_methods/ShippingMethodName.js +1 -0
  370. package/lib/esm/components/shipping_methods/ShippingMethodPrice.js +1 -0
  371. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -0
  372. package/lib/esm/components/skus/AvailabilityContainer.js +1 -0
  373. package/lib/esm/components/skus/AvailabilityTemplate.js +1 -0
  374. package/lib/esm/components/skus/DeliveryLeadTime.js +1 -0
  375. package/lib/esm/components/skus/SkuField.js +1 -0
  376. package/lib/esm/components/skus/SkuList.js +1 -0
  377. package/lib/esm/components/skus/SkuListsContainer.js +1 -0
  378. package/lib/esm/components/skus/Skus.js +1 -0
  379. package/lib/esm/components/skus/SkusContainer.js +1 -0
  380. package/lib/esm/components/stock_transfers/StockTransfer.js +1 -0
  381. package/lib/esm/components/stock_transfers/StockTransferField.js +1 -0
  382. package/lib/esm/components/utils/AddressCardsTemplate.js +1 -0
  383. package/lib/esm/components/utils/BaseField.js +1 -0
  384. package/lib/esm/components/utils/BaseInput.js +1 -0
  385. package/lib/esm/components/utils/BaseOrderPrice.js +1 -0
  386. package/lib/esm/components/utils/BaseSelect.js +1 -0
  387. package/lib/esm/components/utils/ErrorBoundary.js +1 -0
  388. package/lib/esm/components/utils/GenericFieldComponent.js +1 -0
  389. package/lib/esm/components/utils/Parent.js +1 -0
  390. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +27 -2
  391. package/lib/esm/components/utils/PaymentCardsTemplate.js +1 -0
  392. package/lib/esm/components/utils/PriceTemplate.js +1 -0
  393. package/lib/esm/components/utils/getAllErrors.js +1 -0
  394. package/lib/esm/config/currency.js +1 -0
  395. package/lib/esm/context/AddressChildrenContext.js +1 -0
  396. package/lib/esm/context/AddressContext.js +1 -0
  397. package/lib/esm/context/AvailabilityContext.js +1 -0
  398. package/lib/esm/context/BillingAddressContext.js +1 -0
  399. package/lib/esm/context/BillingAddressFormContext.js +1 -0
  400. package/lib/esm/context/CommerceLayerContext.js +1 -0
  401. package/lib/esm/context/CouponAndGiftCardFormContext.js +1 -0
  402. package/lib/esm/context/CustomerAddressFormContext.js +1 -0
  403. package/lib/esm/context/CustomerContext.js +1 -0
  404. package/lib/esm/context/CustomerPaymentSourceContext.js +1 -0
  405. package/lib/esm/context/ExternalFunctionContext.js +1 -0
  406. package/lib/esm/context/GiftCardContext.js +1 -0
  407. package/lib/esm/context/InStockSubscriptionContext.js +1 -0
  408. package/lib/esm/context/LineItemChildrenContext.js +1 -0
  409. package/lib/esm/context/LineItemContext.js +1 -0
  410. package/lib/esm/context/LineItemOptionChildrenContext.js +1 -0
  411. package/lib/esm/context/OrderContext.js +1 -0
  412. package/lib/esm/context/OrderListChildrenContext.js +1 -0
  413. package/lib/esm/context/OrderListPaginationContext.js +1 -0
  414. package/lib/esm/context/OrderStorageContext.js +1 -0
  415. package/lib/esm/context/ParcelChildrenContext.js +1 -0
  416. package/lib/esm/context/ParcelLineItemChildrenContext.js +1 -0
  417. package/lib/esm/context/PaymentMethodChildrenContext.js +1 -0
  418. package/lib/esm/context/PaymentMethodContext.js +1 -0
  419. package/lib/esm/context/PaymentSourceContext.js +1 -0
  420. package/lib/esm/context/PlaceOrderContext.js +1 -0
  421. package/lib/esm/context/PricesContext.js +1 -0
  422. package/lib/esm/context/ShipmentChildrenContext.js +1 -0
  423. package/lib/esm/context/ShipmentContext.js +1 -0
  424. package/lib/esm/context/ShippingAddressContext.js +1 -0
  425. package/lib/esm/context/ShippingAddressFormContext.js +1 -0
  426. package/lib/esm/context/ShippingMethodChildrenContext.js +1 -0
  427. package/lib/esm/context/SkuChildrenContext.js +1 -0
  428. package/lib/esm/context/SkuContext.js +1 -0
  429. package/lib/esm/context/SkuListsContext.js +1 -0
  430. package/lib/esm/context/StockTransferChildrenContext.js +1 -0
  431. package/lib/esm/hooks/useCommerceLayer.js +1 -0
  432. package/lib/esm/hooks/useOrderContainer.js +1 -0
  433. package/lib/esm/index.js +1 -0
  434. package/lib/esm/reducers/AddressReducer.js +1 -0
  435. package/lib/esm/reducers/AvailabilityReducer.js +1 -0
  436. package/lib/esm/reducers/BillingAddressReducer.js +1 -0
  437. package/lib/esm/reducers/CustomerReducer.js +1 -0
  438. package/lib/esm/reducers/GiftCardReducer.js +1 -0
  439. package/lib/esm/reducers/InStockSubscriptionReducer.js +1 -0
  440. package/lib/esm/reducers/LineItemReducer.js +1 -0
  441. package/lib/esm/reducers/OrderReducer.js +1 -0
  442. package/lib/esm/reducers/PaymentMethodReducer.js +1 -0
  443. package/lib/esm/reducers/PlaceOrderReducer.js +1 -0
  444. package/lib/esm/reducers/PriceReducer.js +1 -0
  445. package/lib/esm/reducers/ShipmentReducer.js +1 -0
  446. package/lib/esm/reducers/ShippingAddressReducer.js +1 -0
  447. package/lib/esm/reducers/SkuListsReducer.js +1 -0
  448. package/lib/esm/reducers/SkuReducer.js +1 -0
  449. package/lib/esm/typings/errors.js +1 -0
  450. package/lib/esm/typings/globals.js +1 -0
  451. package/lib/esm/typings/index.js +1 -0
  452. package/lib/esm/utils/PropsType.js +1 -0
  453. package/lib/esm/utils/addressesManager.js +1 -0
  454. package/lib/esm/utils/baseReducer.js +1 -0
  455. package/lib/esm/utils/browserInfo.js +1 -0
  456. package/lib/esm/utils/checkIncludeResource.js +1 -0
  457. package/lib/esm/utils/compareObjAttribute.js +1 -0
  458. package/lib/esm/utils/countryStateCity.js +1 -0
  459. package/lib/esm/utils/customMessages.js +1 -0
  460. package/lib/esm/utils/customerOrderOptions.js +1 -0
  461. package/lib/esm/utils/events.d.ts +5 -0
  462. package/lib/esm/utils/events.js +2 -0
  463. package/lib/esm/utils/expressPaymentHelper.js +1 -0
  464. package/lib/esm/utils/filterChildren.js +1 -0
  465. package/lib/esm/utils/getAmount.js +1 -0
  466. package/lib/esm/utils/getApplicationLink.d.ts +31 -0
  467. package/lib/esm/utils/getApplicationLink.js +2 -0
  468. package/lib/esm/utils/getCardDetails.js +2 -1
  469. package/lib/esm/utils/getDomain.js +1 -0
  470. package/lib/esm/utils/getErrors.js +1 -0
  471. package/lib/esm/utils/getLineItemsCount.js +1 -0
  472. package/lib/esm/utils/getLoaderComponent.js +1 -0
  473. package/lib/esm/utils/getPaymentAttributes.js +1 -0
  474. package/lib/esm/utils/getPrices.js +1 -0
  475. package/lib/esm/utils/getSdk.js +1 -0
  476. package/lib/esm/utils/getSkus.js +1 -0
  477. package/lib/esm/utils/hasSubscriptions.js +1 -0
  478. package/lib/esm/utils/hooks/useCustomContext.js +1 -0
  479. package/lib/esm/utils/hooks/useExternalScript.js +1 -0
  480. package/lib/esm/utils/icons.js +1 -0
  481. package/lib/esm/utils/isDate.js +1 -0
  482. package/lib/esm/utils/isEmpty.js +1 -0
  483. package/lib/esm/utils/isEmptyStates.js +1 -0
  484. package/lib/esm/utils/isJSON.js +1 -0
  485. package/lib/esm/utils/jwt.js +1 -0
  486. package/lib/esm/utils/localStorage.js +1 -0
  487. package/lib/esm/utils/omit.js +1 -0
  488. package/lib/esm/utils/organization.js +1 -0
  489. package/lib/esm/utils/pick.js +1 -0
  490. package/lib/esm/utils/placeholderImages.js +1 -0
  491. package/lib/esm/utils/promisify.js +1 -0
  492. package/lib/esm/utils/replace.js +1 -0
  493. package/lib/esm/utils/scrollbarWidth.js +1 -0
  494. package/lib/esm/utils/shipments.js +1 -0
  495. package/lib/esm/utils/snakeToCamelCase.js +1 -0
  496. package/lib/esm/utils/validateFormFields.js +1 -0
  497. package/package.json +25 -23
  498. package/lib/cjs/utils/getCartLink.d.ts +0 -8
  499. package/lib/cjs/utils/getCartLink.js +0 -1
  500. package/lib/esm/utils/getCartLink.d.ts +0 -8
  501. package/lib/esm/utils/getCartLink.js +0 -1
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";export function SubTotalAmount(props){return _jsx(BaseOrderPrice,{base:"amount",type:"subtotal",...props})}export default SubTotalAmount;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";export function TaxesAmount(props){return _jsx(BaseOrderPrice,{base:"amount",type:"total_tax",...props})}export default TaxesAmount;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"../utils/BaseOrderPrice";export function TotalAmount(props){return _jsx(BaseOrderPrice,{base:"total_amount",type:"with_taxes",...props})}export default TotalAmount;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelChildrenContext from"../../context/ParcelChildrenContext";export function ParcelField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcel",attribute,tagElement,context:ParcelChildrenContext,...p,children})}export default ParcelField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import ParcelChildrenContext from"../../context/ParcelChildrenContext";import ParcelLineItemChildrenContext from"../../context/ParcelLineItemChildrenContext";import{useContext}from"react";export function ParcelLineItem({children}){const{parcel}=useContext(ParcelChildrenContext),components=parcel?.parcel_line_items?.map((parcelLineItem,key)=>_jsx(ParcelLineItemChildrenContext.Provider,{value:{parcelLineItem},children},key));return _jsx(_Fragment,{children:components})}export default ParcelLineItem;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelLineItemChildrenContext from"../../context/ParcelLineItemChildrenContext";export function ParcelLineItemField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcelLineItem",attribute,tagElement,context:ParcelLineItemChildrenContext,...p,children})}export default ParcelLineItemField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import ParcelChildrenContext from"../../context/ParcelChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function ParcelLineItemsCount({children,...p}){const{parcel}=useCustomContext({context:ParcelChildrenContext,contextComponentName:"Parcels",currentComponentName:"ParcelLineItemsCount",key:"parcel"}),quantity=parcel?.parcel_line_items?.length??0,childrenProps={...p,quantity,parcel};return children?_jsx(Parent,{...childrenProps,children}):_jsx("span",{...p,children:quantity})}export default ParcelLineItemsCount;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import ParcelChildrenContext from"../../context/ParcelChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import{useContext}from"react";export function Parcels({children,filterBy}){const{parcels}=useContext(ShipmentChildrenContext),components=parcels?.filter(parcel=>filterBy?.includes(parcel.id)??!0).map((parcel,key)=>_jsx(ParcelChildrenContext.Provider,{value:{parcel},children},key));return _jsx(_Fragment,{children:components})}export default Parcels;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function ParcelsCount({children,...p}){const{parcels}=useCustomContext({context:ShipmentChildrenContext,contextComponentName:"ShipmentsContainer",currentComponentName:"ParcelsCount",key:"parcels"}),quantity=parcels?.length??0,childrenProps={...p,quantity,parcels};return children?_jsx(Parent,{...childrenProps,children}):_jsx("span",{...p,children:quantity})}export default ParcelsCount;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import isEmpty from"lodash/isEmpty";import{useContext}from"react";import AdyenPayment from"../payment_source/AdyenPayment";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import jwt from"../../utils/jwt";import getCardDetails from"../../utils/getCardDetails";import{getPaymentAttributes}from"../../utils/getPaymentAttributes";export function AdyenGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=useContext(OrderContext),{accessToken}=useContext(CommerceLayerContext),{payment}=useContext(PaymentMethodChildrenContext),{payments,isGuest}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="adyen_payments",locale=order?.language_code,paymentMethods=paymentSource?.payment_methods;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientKey=paymentSource?.public_key,environment=accessToken&&jwt(accessToken).test?"test":"live",paymentConfig=getPaymentAttributes({resource:paymentResource,config:config??{},keys:["adyen_payments"]})?.adyenPayment,customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="adyen_payments"):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?clientKey&&!loading&&paymentMethods?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(AdyenPayment,{templateCustomerSaveToWallet,clientKey,locale,environment,config:paymentConfig})]}):loaderComponent:clientKey&&!loading&&paymentMethods?_jsx(AdyenPayment,{clientKey,locale,config:paymentConfig,environment}):loaderComponent}export default AdyenGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import BraintreePayment from"../payment_source/BraintreePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import{useContext}from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import{getPaymentAttributes}from"../../utils/getPaymentAttributes";export function BraintreeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=useContext(OrderContext),{payment}=useContext(PaymentMethodChildrenContext),{payments,isGuest}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="braintree_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const authorization=paymentSource?.client_token,paymentConfig=getPaymentAttributes({resource:paymentResource,config:config??{},keys:["braintree_payments"]})?.braintreePayment,customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="braintree_payments"):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?authorization&&!loading?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(BraintreePayment,{templateCustomerSaveToWallet,authorization,locale,config:paymentConfig})]}):loaderComponent:authorization&&!loading?_jsx(BraintreePayment,{locale,authorization,config:paymentConfig}):loaderComponent}export default BraintreeGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import CheckoutComPayment from"../payment_source/CheckoutComPayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import getCardDetails from"../../utils/getCardDetails";export function CheckoutComGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="checkout_com_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publicKey=paymentSource?.public_key,paymentConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return card.brand?_jsx(PaymentSourceContext.Provider,{value,children}):null}return!isGuest&&templateCustomerCards?publicKey&&!loading?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(CheckoutComPayment,{show,templateCustomerSaveToWallet,publicKey,locale,...paymentConfig})]}):loaderComponent:publicKey&&!loading?_jsx(CheckoutComPayment,{show,publicKey,locale,...paymentConfig}):loaderComponent}export default CheckoutComGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import ExternalPayment from"../payment_source/ExternalPayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function ExternalGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="external_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const paymentSourceToken=paymentSource?.payment_source_token,paymentSourceId=order?.payment_source?.id||paymentSource?.id,paymentConfig=(config?getPaymentConfig(paymentResource,config):{})?.externalPayment,customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(ExternalPayment,{show,templateCustomerSaveToWallet,paymentSourceToken,locale,...paymentConfig})]}):paymentSourceToken&&!loading&&paymentSourceId?_jsx(ExternalPayment,{show,paymentSourceToken,locale,...paymentConfig}):loaderComponent}export default ExternalGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import React from"react";import KlarnaPayment from"../payment_source/KlarnaPayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function KlarnaGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="klarna_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientToken=paymentSource?.client_token,klarnaConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=paymentSource?.options?.card,value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(KlarnaPayment,{clientToken,locale,...klarnaConfig})]}):clientToken&&!loading?_jsx(KlarnaPayment,{clientToken,locale,...klarnaConfig}):loaderComponent}export default KlarnaGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource&&!expressPayments){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show&&!expressPayments||(!paymentSource&&!expressPayments||paymentSource?.type!==paymentResource)&&show)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return expressPayments&&setLoading(!1),()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaypalPayment from"../payment_source/PaypalPayment";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import getCardDetails from"../../utils/getCardDetails";import{getPaymentAttributes}from"../../utils/getPaymentAttributes";import isEmpty from"lodash/isEmpty";import{useContext}from"react";export function PaypalGateway(props){const{readonly,showCard,handleEditClick,children,...p}=props,{order}=useContext(OrderContext),{payment}=useContext(PaymentMethodChildrenContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="paypal_payments";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:order?.payment_source||paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}const infoMessage=getPaymentAttributes({resource:paymentResource,config:config??{},keys:["paypal_payments"]})?.paypalPayment?.infoMessage;return delete p.show,delete p.templateCustomerCards,delete p.templateCustomerSaveToWallet,delete p.loading,delete p.loaderComponent,delete p.onClickCustomerCards,_jsx(PaypalPayment,{...p,infoMessage})}export default PaypalGateway;
@@ -1 +1,2 @@
1
- import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../payment_source/StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function StripeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment,expressPayments}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="stripe_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publishableKey=paymentSource?.publishable_key,clientSecret=paymentSource?.client_secret,paymentSourceId=order?.payment_source?.id||paymentSource?.id,stripeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(StripePayment,{show,templateCustomerSaveToWallet,publishableKey,clientSecret,expressPayments,locale,...stripeConfig})]}):publishableKey&&!loading&&paymentSourceId?_jsx(StripePayment,{show,publishableKey,clientSecret,locale,expressPayments,...stripeConfig}):loaderComponent}export default StripeGateway;
1
+ "use client";
2
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../payment_source/StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function StripeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment,expressPayments}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="stripe_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publishableKey=paymentSource?.publishable_key,clientSecret=paymentSource?.client_secret,paymentSourceId=order?.payment_source?.id||paymentSource?.id,stripeConfig=config?getPaymentConfig(paymentResource,config).stripePayment:{};console.log("stripeConfig",stripeConfig);const customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(StripePayment,{show,templateCustomerSaveToWallet,publishableKey,clientSecret,expressPayments,locale,...stripeConfig})]}):publishableKey&&!loading&&paymentSourceId?_jsx(StripePayment,{show,publishableKey,clientSecret,locale,expressPayments,...stripeConfig}):loaderComponent}export default StripeGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import WireTransferPayment from"../payment_source/WireTransferPayment";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import{useContext}from"react";export function WireTransferGateway(props){const{readonly,showCard,handleEditClick,children,...p}=props,{payment}=useContext(PaymentMethodChildrenContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="wire_transfers";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=paymentSource?.options?.card||paymentSource?.metadata?.card,value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}const wireTransferConfig=config&&paymentResource?getPaymentConfig(paymentResource,config):{};return _jsx(WireTransferPayment,{...p,...wireTransferConfig?.wireTransfer})}export default WireTransferGateway;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";import OrderContext from"../../context/OrderContext";import CustomerContext from"../../context/CustomerContext";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import{isEmpty}from"../../utils/isEmpty";import{getAvailableExpressPayments}from"../../utils/expressPaymentHelper";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,autoSelectSinglePaymentMethod,expressPayments,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder,paymentSource,setPaymentSource,config}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"}),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext);useEffect(()=>{if(paymentMethods!=null&&!isEmpty(paymentMethods)&&expressPayments){const[paymentMethod]=getAvailableExpressPayments(paymentMethods);!paymentSource&&paymentMethod!=null&&(async()=>{setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId}),await setPaymentSource({paymentResource,order})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),setLoadingPlaceOrder({loading:!1})})()}},[!isEmpty(paymentMethods),expressPayments]),useEffect(()=>{paymentMethods!=null&&autoSelectSinglePaymentMethod!=null&&!expressPayments&&(async()=>{if(paymentMethods.length===1){const[paymentMethod]=paymentMethods??[];if(paymentMethod&&!paymentSource){setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId});let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config)),await setPaymentSource({paymentResource,order,attributes})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),getCustomerPaymentSources&&getCustomerPaymentSources(),setLoadingPlaceOrder({loading:!1})}typeof autoSelectSinglePaymentMethod=="function"&&autoSelectSinglePaymentMethod()}else setTimeout(()=>{setLoading(!1)},200)})()},[paymentMethods,expressPayments]),useEffect(()=>(paymentMethods&&(paymentMethods.length===1&&autoSelectSinglePaymentMethod?paymentSource&&setTimeout(()=>{setLoading(!1)},200):setLoading(!1)),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected,expressPayments},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id,{order:order2}=await setPaymentMethod({paymentResource,paymentMethodId});onClick&&onClick({payment,order:order2}),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-testid":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodName(props){const{payment}=useCustomContext({context:PaymentMethodChildrenContext,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodName",key:"payment"}),labelName=payment?.name,htmlFor=payment?.payment_source_type,paymentGateway=payment?.payment_gateway,parentProps={htmlFor,labelName,paymentGateway,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("label",{htmlFor,...props,children:labelName})}export default PaymentMethodName;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect}from"react";import getAmount from"../../utils/getAmount";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodPrice(props){const{format="formatted",type="amount",labelFree="Free",...p}=props,{payment}=useCustomContext({context:PaymentMethodChildrenContext,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodPrice",key:"payment"}),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(payment){const p2=getAmount({base:"price",type,format,obj:payment});setPrice(p2);const c=getAmount({base:"price",type,format:"cents",obj:payment});setPriceCents(c)}return()=>{setPrice(""),setPriceCents(0)}},[payment]);const parentProps={labelFree,price,priceCents,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:priceCents===0?labelFree:price})}export default PaymentMethodPrice;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodRadioButton(props){const{onChange,...p}=props,{payment,paymentSelected,setPaymentSelected,clickableContainer}=useCustomContext({context:PaymentMethodChildrenContext,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodRadioButton",key:"payment"}),{order}=useContext(OrderContext),{setPaymentMethod,setLoading}=useContext(PaymentMethodContext),orderId=order?.id||"",paymentResource=payment?.payment_source_type,paymentMethodId=payment?.id,name=`payment-${orderId}`,checked=paymentSelected===payment?.id,handleOnChange=async e=>{if(e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer){const{order:order2}=await setPaymentMethod({paymentResource,paymentMethodId});onChange&&onChange({payment,order:order2})}setLoading({loading:!1})},id=payment?.payment_source_type,parentProps={handleOnChange,checked,id,name,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("input",{title:name,type:"radio",id,onChange:e=>{handleOnChange(e)},checked,...p})}export default PaymentMethodRadioButton;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import useCustomContext from"../../utils/hooks/useCustomContext";import{isEmpty}from"../../utils/isEmpty";export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PaymentMethodsContainer",key:"order"}),credentials=useContext(CommerceLayerContext);async function getPayMethods(){order&&await getPaymentMethods({order,dispatch})}useEffect(()=>{include?.includes("available_payment_methods")?includeLoaded?.available_payment_methods||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0,"line_items.line_item_options.sku_option":!0,"line_items.item":!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method","line_items.line_item_options.sku_option","line_items.item"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPayMethods(),order?.payment_source&&dispatch({type:"setPaymentSource",payload:{paymentSource:order?.payment_source}}),order?.payment_source===null&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},[order,credentials,include?.length,Object.keys(includeLoaded??[]).length]);const contextValue=useMemo(()=>({...state,setLoading:({loading})=>{defaultPaymentMethodContext.setLoading({loading,dispatch})},setPaymentRef:({ref})=>{setPaymentRef({ref,dispatch})},setPaymentMethodErrors:errors=>{defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch)},setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod({...args,config:credentials,updateOrder,order,dispatch,setOrderErrors}),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource({...state,...args,config:credentials,dispatch,getOrder,updateOrder,order}),updatePaymentSource:async args=>{await defaultPaymentMethodContext.updatePaymentSource({...args,config:credentials,dispatch})},destroyPaymentSource:async args=>{await defaultPaymentMethodContext.destroyPaymentSource({...args,dispatch,config:credentials,updateOrder,orderId:order?.id})}}),[state]);return _jsx(PaymentMethodContext.Provider,{value:contextValue,children})}export default PaymentMethodsContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{setCustomerOrderParam}from"../../utils/localStorage";import Parent from"../utils/Parent";import getBrowserInfo,{cleanUrlBy}from"../../utils/browserInfo";import PlaceOrderContext from"../../context/PlaceOrderContext";import OrderContext from"../../context/OrderContext";import omit from"../../utils/omit";const threeDSConfiguration={challengeWindowSize:"05"},defaultConfig={};export function AdyenPayment({clientKey,config,templateCustomerSaveToWallet,environment="test",locale="en_US"}){const{cardContainerClassName,threeDSecureContainerClassName,styles}={...defaultConfig,...config},[loadAdyen,setLoadAdyen]=useState(!1),[checkout,setCheckout]=useState(),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{placeOrderButtonRef}=useContext(PlaceOrderContext),ref=useRef(null),handleSubmit=async(e,component)=>{const savePaymentSourceToCustomerWallet=e?.elements?.save_payment_source_to_customer_wallet?.checked;return savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),component?.submit&&component.submit(),!1},handleChange=async(state,_component)=>{if(state.isValid){ref.current&&(ref.current.onsubmit=async()=>await handleSubmit(ref.current,checkout),setPaymentRef({ref}));const browserInfo=getBrowserInfo(),attributes={payment_request_data:{payment_method:state.data.paymentMethod,shopperInteraction:"Ecommerce",recurringProcessingModel:"CardOnFile",origin:window.location.origin,return_url:window.location.href,redirect_from_issuer_method:"GET",browser_info:{acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",...browserInfo}}};paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes})}},handleOnAdditionalDetails=async(state,component)=>{const attributes={payment_request_details:state.data,_details:1};try{const pSource=paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes}),adyenAction=pSource?.payment_response?.action,resultCode=pSource?.payment_response?.resultCode;if(adyenAction&&component)return component.handleAction(adyenAction),!1;if(["Authorised","Pending","Received"].includes(resultCode))return placeOrderButtonRef?.current!=null&&(placeOrderButtonRef.current.disabled&&(placeOrderButtonRef.current.disabled=!1),placeOrderButtonRef.current.click()),!0;if(["Cancelled","Refused"].includes(resultCode)){const message=pSource?.payment_response?.refusalReason;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}]),component&&component.mount("#adyen-dropin")}return!1}catch(error){return console.error("Adyen additional details error:",error),!1}},onSubmit=async(state,component)=>{const browserInfo=getBrowserInfo(),saveCustomer=document.getElementById("save_payment_source_to_customer_wallet"),url=cleanUrlBy();let control=await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments"});if(control?.payment_response?.resultCode==="Authorised")return!0;const paymentDataAvailable=Object.keys(control?.payment_request_data).length>0,paymentMethodSelected=control?.payment_request_data?.payment_method?.type,paymentMethod=saveCustomer?.checked?state.data.paymentMethod:omit(state.data.paymentMethod,["encryptedCardNumber","encryptedExpiryMonth","encryptedExpiryYear","encryptedSecurityCode"]);(!paymentDataAvailable||paymentMethodSelected!==state.data.paymentMethod.type)&&(control=await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes:{payment_request_data:{...state.data,payment_method:paymentMethod,return_url:url,origin:window.location.origin,redirect_from_issuer_method:"GET",browser_info:{acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",...browserInfo}}}}));const attributes={payment_request_data:{...state.data,payment_method:paymentMethod,return_url:url,origin:window.location.origin,redirect_from_issuer_method:"GET",browser_info:{acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",...browserInfo}},_authorize:1};delete attributes.payment_request_data.paymentMethod;try{const res=await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}),action=res?.payment_response?.action;if(component&&action)return component.handleAction(action),!1;const resultCode=res?.payment_response?.resultCode;if(["Authorised","Pending","Received"].includes(resultCode))return placeOrderButtonRef?.current!=null&&(placeOrderButtonRef.current.disabled&&(placeOrderButtonRef.current.disabled=!1),placeOrderButtonRef.current.click()),!0;if(["Cancelled"].includes(resultCode)){const message=res?.payment_response?.refusalReason;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])}if(res?.payment_response?.errorType)if(res?.payment_response?.errorCode==="14_006")onSubmit(state,component);else{const message=res?.payment_response?.message;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])}return!1}catch(error){return setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}};return useEffect(()=>{const paymentMethodsResponse=paymentSource?.payment_methods?.paymentMethods?paymentSource?.payment_methods.paymentMethods:[],[firstPaymentMethod]=paymentMethodsResponse,isOnlyCard=paymentMethodsResponse?.length===1&&firstPaymentMethod.type==="scheme";paymentMethodsResponse.length===0&&console.error("Payment methods are not available. Please, check your Adyen configuration.");const options={locale,environment,clientKey,amount:{currency:order?.currency_code||"",value:order?.total_amount_with_taxes_cents||0},countryCode:order?.country_code||"",paymentMethodsResponse:{paymentMethods:paymentMethodsResponse},showPayButton:!1,paymentMethodsConfiguration:{threeDS2:threeDSConfiguration,paypal:{showPayButton:!0,style:styles?.paypal},card:{styles:styles?.card,holderNameRequired:!1}},onAdditionalDetails:(state,element)=>{handleOnAdditionalDetails(state,element)},onChange:(state,element)=>{handleChange(state,element)},onSubmit:(state,element)=>{onSubmit(state,element)}};return!ref&&clientKey&&setCustomerOrderParam("_save_payment_source_to_customer_wallet","false"),clientKey&&!loadAdyen&&window&&!checkout&&import("@adyen/adyen-web").then(({default:AdyenCheckout})=>{const type=isOnlyCard?"card":"dropin";AdyenCheckout(options).then(adyenCheckout=>{const component=adyenCheckout.create(type,{onSelect:component2=>{const id=component2._id;id.search("scheme")===-1&&ref.current&&(id.search("paypal")===-1?ref.current.onsubmit=async()=>await handleSubmit(ref.current,component2):ref.current.onsubmit=null,setPaymentRef({ref}))}}).mount("#adyen-dropin");component&&(setCheckout(component),setLoadAdyen(!0))})}),()=>{setPaymentRef({ref:{current:null}}),setLoadAdyen(!1)}},[clientKey,ref]),!clientKey&&!loadAdyen&&!checkout?null:_jsxs("form",{ref,onSubmit:e=>{handleSubmit(e,checkout)},children:[_jsx("div",{className:cardContainerClassName,id:"adyen-dropin"}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet}),_jsx("div",{className:threeDSecureContainerClassName,id:"adyen-action"})]})}export default AdyenPayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import isEmpty from"lodash/isEmpty";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import{setCustomerOrderParam}from"../../utils/localStorage";import promisify from"../../utils/promisify";const defaultConfig={styles:{input:{"font-size":"16px",color:"#3A3A3A"},".number":{"font-family":"monospace"},":focus":{color:"blue"},".valid":{color:"green"},".invalid":{color:"red"},"@media screen and (max-width: 700px)":{input:{"font-size":"14px"}}},fields:{number:{label:"Card Number",selector:"#card-number",placeholder:"4111 1111 1111 1111"},cvv:{label:"CVV",selector:"#cvv",placeholder:"123"},expirationDate:{label:"Expiration Date",selector:"#expiration-date",placeholder:"10/2022"}},submitLabel:"Set payment method"};export function BraintreePayment({authorization,config,templateCustomerSaveToWallet}){const{fields,styles,containerClassName,cardContainerClassName,fieldsContainerClassName,expDateContainerClassName,fieldLabelClassName,cvvContainerClassName,inputWrapperClassName,cardDetailsContainerClassName}={...defaultConfig,...config},[loadBraintree,setLoadBraintree]=useState(!1),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),ref=useRef(null),handleSubmitForm=async({event,hostedFieldsInstance,threeDSInstance})=>{const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),hostedFieldsInstance)try{const payload=await promisify(hostedFieldsInstance).then(payload2=>payload2),billingAddress=order?.billing_address,verifyCardOptions={nonce:payload.nonce,bin:payload.details.bin,amount:order?.total_amount_with_taxes_float,email:order?.customer_email??"",billingAddress:{givenName:billingAddress?.first_name??"",surname:billingAddress?.last_name??"",phoneNumber:billingAddress?.phone,streetAddress:billingAddress?.line_1,countryCodeAlpha2:billingAddress?.country_code,postalCode:billingAddress?.zip_code??"",region:billingAddress?.state_code,locality:billingAddress?.city},onLookupComplete:(_data,next)=>{next()}},response=await threeDSInstance.verifyCard(verifyCardOptions);return response.rawCardinalSDKVerificationData.Validated&&paymentSource?(paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"braintree_payments",attributes:{payment_method_nonce:response.nonce,options:{id:response.nonce,card:{last4:response.details.lastFour,exp_year:response.details.expirationYear,exp_month:response.details.expirationMonth,brand:response.details.cardType.toLowerCase()}}}}),!0):!1}catch(error){return console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}return!1};return useEffect(()=>{if(!ref&&authorization&&setCustomerOrderParam("_save_payment_source_to_customer_wallet","false"),authorization&&!loadBraintree&&!isEmpty(window)){const braintreeClient=require("braintree-web/client"),hostedFields=require("braintree-web/hosted-fields"),threeDSecure=require("braintree-web/three-d-secure");braintreeClient.create({authorization},(clientErr,clientInstance)=>{if(clientErr){console.error(clientErr);return}hostedFields.create({client:clientInstance,fields,styles},(hostedFieldsErr,hostedFieldsInstance)=>{if(hostedFieldsErr){console.error(hostedFieldsErr);return}setLoadBraintree(!0),threeDSecure.create({authorization,version:2},(threeDSecureErr,threeDSInstance)=>{threeDSecureErr&&(console.error("3DSecure error",threeDSecureErr),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:threeDSecureErr.message}])),ref.current&&(ref.current.onsubmit=async paymentSource2=>await handleSubmitForm({event:ref.current,hostedFieldsInstance,threeDSInstance,paymentSource:paymentSource2}),setPaymentRef({ref}))})})})}return()=>{setPaymentRef({ref:{current:null}}),setLoadBraintree(!1)}},[authorization,ref]),!authorization&&!loadBraintree?null:_jsx("div",{className:containerClassName,children:_jsxs("form",{ref,id:"braintree-form",onSubmit:handleSubmitForm,className:containerClassName,children:[_jsxs("div",{className:fieldsContainerClassName,children:[_jsxs("div",{className:cardContainerClassName,children:[_jsx("label",{className:fieldLabelClassName,htmlFor:"card-number",children:fields?.number?.label}),_jsx("div",{className:inputWrapperClassName,id:"card-number"})]}),_jsxs("div",{className:cardDetailsContainerClassName,children:[_jsxs("div",{className:expDateContainerClassName,children:[_jsx("label",{className:fieldLabelClassName,htmlFor:"expiration-date",children:fields?.expirationDate?.label}),_jsx("div",{className:inputWrapperClassName,id:"expiration-date"})]}),_jsxs("div",{className:cvvContainerClassName,children:[_jsx("label",{className:fieldLabelClassName,htmlFor:"cvv",children:fields?.cvv?.label}),_jsx("div",{className:inputWrapperClassName,id:"cvv"})]})]})]}),_jsx("div",{className:fieldsContainerClassName,children:templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})})]})})}export default BraintreePayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useRef}from"react";import useExternalScript from"../../utils/hooks/useExternalScript";import PaymentMethodContext from"../../context/PaymentMethodContext";import{Frames,CardNumber,ExpiryDate,Cvv}from"frames-react";import OrderContext from"../../context/OrderContext";import Parent from"../utils/Parent";import{setCustomerOrderParam}from"../../utils/localStorage";const scriptUrl="https://cdn.checkout.com/js/framesv2.min.js",systemLanguages=["DE-DE","EN-GB","ES-ES","FR-FR","IT-IT","KR-KR","NL-NL"],defaultOptions={style:{base:{color:"black",fontSize:"18px"},autofill:{backgroundColor:"yellow"},hover:{color:"blue"},focus:{color:"blue"},valid:{color:"green"},invalid:{color:"red"},placeholder:{base:{color:"gray"},focus:{border:"solid 1px blue"}}}};export function CheckoutComPayment({publicKey,options=defaultOptions,locale="EN-GB",...p}){const ref=useRef(null),loaded=useExternalScript(scriptUrl),{setPaymentRef,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{containerClassName,templateCustomerSaveToWallet,successUrl=window.location.href,failureUrl=window.location.href,show,...divProps}=p,handleSubmit=async()=>{const savePaymentSourceToCustomerWallet=ref?.current?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),window.Frames){window.Frames.cardholder={name:order?.billing_address?.full_name,billingAddress:{addressLine1:order?.billing_address?.line_1,addressLine2:order?.billing_address?.line_2??"",zip:order?.billing_address?.zip_code??"",city:order?.billing_address?.city,state:order?.billing_address?.state_code,country:order?.billing_address?.country_code},phone:order?.billing_address?.phone};try{const data=await window.Frames.submitCard();if(data.token&&paymentSource&&currentPaymentMethodType){const ps=await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{token:data.token,payment_type:"token",success_url:successUrl,failure_url:failureUrl,_authorize:!0}});ps?.redirect_uri&&(window.location.href=ps.redirect_uri)}}catch(error){console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error?.message}])}}return!1},lang=`${locale.toUpperCase()}-${locale.toUpperCase()}`,localization=systemLanguages.includes(lang)?lang:"EN-GB";return loaded&&show?_jsxs("form",{ref,children:[_jsx("div",{className:containerClassName,...divProps,children:_jsxs(Frames,{config:{debug:!0,publicKey,localization,...options},cardValidationChanged:e=>{e.isValid&&ref.current&&(ref.current.onsubmit=async()=>await handleSubmit(),setPaymentRef({ref}))},cardTokenized:data=>data,children:[_jsx(CardNumber,{}),_jsx(ExpiryDate,{}),_jsx(Cvv,{})]})}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]}):null}export default CheckoutComPayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import Parent from"../utils/Parent";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useRef}from"react";export function ExternalPayment(props){const{setPaymentRef}=useContext(PaymentMethodContext),ref=useRef(null);return useEffect(()=>{ref!==null&&(ref.current.onsubmit=async()=>!0,setPaymentRef({ref}))},[ref]),props?.customComponent!=null&&props.show?_jsxs("form",{ref,children:[_jsx(Parent,{children:props.customComponent}),props?.templateCustomerSaveToWallet!=null&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:props.templateCustomerSaveToWallet})]}):null}export default ExternalPayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";import PlaceOrderContext from"../../context/PlaceOrderContext";function typeOfLine(lineItemType){switch(lineItemType){case"percentage_discount_promotions":return"discount";case"shipments":return"shipping_fee";case"skus":return"physical";case"payment_methods":default:return null}}function klarnaOrderLines(lineItems){return lineItems?lineItems?.map(item=>{const type=item.item_type?typeOfLine(item.item_type):null;return{quantity:item.quantity,total_amount:item.total_amount_cents,unit_price:item.unit_amount_cents,type}}):[]}export default function KlarnaPayment({clientToken,placeOrderCallback,locale="EN",...p}){const ref=useRef(null),{paymentSource,currentPaymentMethodType,setPaymentRef,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{setPlaceOrder}=useContext(PlaceOrderContext),loaded=useExternalScript("https://x.klarnacdn.net/kp/lib/v1/api.js"),[klarna,setKlarna]=useState(),{containerClassName,...divProps}=p;useEffect(()=>{loaded&&window?.Klarna!==void 0&&setKlarna(window.Klarna)},[loaded,window.Klarna]),useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&loaded&&klarna&&(ref.current.onsubmit=async()=>{await handleClick(klarna)},setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType,loaded,klarna]);const handleClick=async kl=>{const[first]=paymentSource?.payment_methods||void 0,paymentMethodCategory=first?.identifier,billingAddress={given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:null,organization_name:null,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shippingAddress={given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,email:order?.customer_email,street_address:order?.shipping_address?.line_1,street_address2:null,postal_code:order?.shipping_address?.zip_code,organization_name:null,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code},klarnaData={merchant_data:order?.id,purchase_country:order?.country_code,purchase_currency:order?.currency_code,locale,shipping_address:shippingAddress,billing_address:billingAddress,order_amount:order?.total_amount_cents,order_lines:klarnaOrderLines(order?.line_items)};try{kl.Payments.load({container:"#klarna-payments-container",payment_method_category:paymentMethodCategory},{billing_address:billingAddress,shipping_address:shippingAddress},async function({show_form}){if(show_form)try{await kl.Payments.authorize({payment_method_category:paymentMethodCategory},klarnaData,async function(res){if(res.approved&&paymentSource&&currentPaymentMethodType){const ps=await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{auth_token:res.authorization_token}}),{placed}=setPlaceOrder&&ps&&await setPlaceOrder({paymentSource:ps})||{placed:!1};placed&&placeOrderCallback&&placeOrderCallback({placed})}})}catch(e){console.error("e",e),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:"Authorization error"}])}})}catch(e){console.error("Load Klarna libray",e)}};if(klarna&&clientToken){const[first]=paymentSource?.payment_methods||void 0;klarna.Payments.init({client_token:clientToken}),klarna.Payments.load({container:"#klarna-payments-container",payment_method_category:first?.identifier},{billing_address:{given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:order?.billing_address?.line_2,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shipping_address:{given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,street_address:order?.shipping_address?.line_1,street_address2:order?.shipping_address?.line_2,postal_code:order?.shipping_address?.zip_code,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code}})}return _jsx("form",{ref,children:_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"klarna-payments-container"})})})}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!!expressPayments),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandIcon({src,width=32,children,...p}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,ref=useRef(null),defaultSrc="//data.commercelayer.app/assets/images/icons/credit-cards/color/credit-card.svg",url=src||`//data.commercelayer.app/assets/images/icons/credit-cards/color/${cardBrand??"credit-card"}.svg`,handleError=()=>{ref.current&&(ref.current.src=defaultSrc)},parentProps={brand:cardBrand,defaultSrc,url,width,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("img",{ref,src:url,onError:handleError,width,...p})}export default PaymentSourceBrandIcon;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import capitalize from"lodash/capitalize";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandName({children,label,...props}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,brandName=cardBrand&&capitalize(cardBrand.replace(/_|-/gm," ")),parentProps={brand:brandName,label,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...props,children:label||capitalize(brandName)})}export default PaymentSourceBrandName;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceDetail({type,children,...p}){const card=useContext(PaymentSourceContext),customerCard=useContext(CustomerPaymentSourceContext),cardObj=Object.keys(card).length>0?card:customerCard,text=type in cardObj?cardObj[type]:type==="last4"?"****":"**",parentProps={type,text,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:text})}export default PaymentSourceDetail;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext}from"react";import Parent from"../utils/Parent";export function PaymentSourceEditButton({children,label="Edit",...props}){const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps={showCard,label,handleEditClick,...props};return children?_jsx(Parent,{...parentProps,children}):readonly?null:_jsx("button",{...props,onClick:handleEditClick,children:label})}export default PaymentSourceEditButton;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../../context/PaymentMethodContext";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef}from"react";const defaultMessage="by placing the order, you will be redirected to the PayPal website to sign in and authorize the payment";export function PaypalPayment({infoMessage,...p}){const ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&paymentSource?.approval_url&&(ref.current.onsubmit=async()=>await handleClick(),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType]);const handleClick=async()=>{if(paymentSource&&currentPaymentMethodType)try{return await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{metadata:{card:{id:paymentSource.id,brand:"paypal",last4:""}}}}),!0}catch{return!1}return!1};return _jsx("form",{ref,children:_jsx("div",{...p,children:_jsx("span",{className:infoMessage?.className,children:isFunction(infoMessage?.text)?infoMessage?.text():infoMessage?.text||defaultMessage})})})}export default PaypalPayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{getAvailableExpressPayments,getExpressShippingMethods,setExpressFakeAddress,setExpressPlaceOrder,setExpressShippingMethod,expressRedirectUrl}from"../../utils/expressPaymentHelper";import{isEmpty}from"../../utils/isEmpty";import{PaymentRequestButtonElement,useStripe}from"@stripe/react-stripe-js";import{useContext,useEffect,useState}from"react";export function StripeExpressPayment({clientSecret}){const stripe=useStripe(),[paymentRequest,setPaymentRequest]=useState(null),{accessToken,endpoint}=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{paymentMethods,paymentSource}=useContext(PaymentMethodContext);return useEffect(()=>{if(stripe==null||order==null)return;const pr=stripe.paymentRequest({country:order?.country_code??"US",currency:order?.currency_code?.toLowerCase()??"",total:{label:`#${order?.number??""}`,amount:order?.total_amount_with_taxes_cents??0},requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:!0});pr.canMakePayment().then(result=>{console.log("available payment:",result),result&&setPaymentRequest(pr)}).catch(err=>{console.error("Can make payment:",err)})},[isEmpty(stripe),isEmpty(order)]),paymentRequest!=null&&stripe!=null?(paymentRequest.on("shippingaddresschange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const requiresBillingInfo=order?.requires_billing_info??!1,orderWithShipments=await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:"Fake name",last_name:"Fake lastname",country_code:ev.shippingAddress.country??"",line_1:"Fake street 123",city:ev.shippingAddress.city??"Fake city",zip_code:ev.shippingAddress.postalCode??"12345",state_code:ev.shippingAddress.region??"Fake state",phone:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),shippingOptions=getExpressShippingMethods(orderWithShipments);shippingOptions!=null&&!isEmpty(shippingOptions)?ev.updateWith({status:"success",shippingOptions,total:{label:`#${orderWithShipments?.number??""}`,amount:orderWithShipments?.total_amount_with_taxes_cents??0}}):ev.updateWith({status:"invalid_shipping_address"})}else ev.updateWith({status:"fail"})}),paymentRequest.on("shippingoptionchange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const updatedOrder=await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev.shippingOption.id,params:{include:["shipments.available_shipping_methods"]}});ev.updateWith({status:"success",total:{label:`#${updatedOrder?.number??""}`,amount:updatedOrder?.total_amount_with_taxes_cents??0}})}else ev.updateWith({status:"fail"})}),paymentRequest.on("paymentmethod",async ev=>{if(order?.id==null)throw new Error("Order is null");if(paymentMethods==null)throw new Error("Payment methods are null");const[paymentMethod]=getAvailableExpressPayments(paymentMethods);if(paymentMethod==null)throw new Error("Payment method is null");if(paymentSource==null)throw new Error("Payment source is null");const requiresBillingInfo=order?.requires_billing_info??!1,paymentResource=paymentMethod?.payment_source_type;if(accessToken!=null&&endpoint!=null){const[firstName,lastName]=ev.payerName?.split(" ")??[],[line]=ev.shippingAddress?.addressLine??"",email=ev.payerEmail??"";await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:firstName??"Fake name",last_name:lastName??"Fake lastname",country_code:ev?.shippingAddress?.country??"",line_1:line??"Fake street 123",city:ev?.shippingAddress?.city??"Fake city",zip_code:ev?.shippingAddress?.postalCode??"12345",state_code:ev?.shippingAddress?.region??"Fake state",phone:ev?.payerPhone??"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0},email}),await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev?.shippingOption?.id,params:{include:["shipments.available_shipping_methods"]}});const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};await setExpressPlaceOrder(placeOrderParams);const{paymentIntent,error:confirmError}=await stripe.confirmCardPayment(clientSecret,{payment_method:ev.paymentMethod.id},{handleActions:!1});if(confirmError)ev.complete("fail"),console.error("Confirm card payment:",confirmError);else if(ev.complete("success"),paymentIntent.status==="requires_action"){const{error}=await stripe.confirmCardPayment(clientSecret);if(error)console.error("Confirm card payment:",error);else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=await setExpressPlaceOrder(placeOrderParams2);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=await setExpressPlaceOrder(placeOrderParams2);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}}),_jsx(PaymentRequestButtonElement,{className:"",options:{paymentRequest}})):null}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{Elements,PaymentElement,useElements,useStripe}from"@stripe/react-stripe-js";import Parent from"../utils/Parent";import{setCustomerOrderParam}from"../../utils/localStorage";import OrderContext from"../../context/OrderContext";import{StripeExpressPayment}from"./StripeExpressPayment";const defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet}){const ref=useRef(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),stripe=useStripe(),elements=useElements();useEffect(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=async()=>await onSubmit({event:ref.current,stripe,elements}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=async({event,stripe:stripe2,elements:elements2})=>{if(!stripe2)return!1;const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=order?.customer_email??"",billingDetails={name:billingInfo?.full_name??"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:billingInfo?.line_2??"",postal_code:billingInfo?.zip_code??"",state:billingInfo?.state_code}},{error}=await stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:window.location.href,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1):!0}return!1};return _jsxs("form",{ref,children:[_jsx(PaymentElement,{id:"payment-element",options:{...defaultOptions,...options}}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}export function StripePayment({publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1,...p}){const[isLoaded,setIsLoaded]=useState(!1),[stripe,setStripe]=useState(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance,...divProps}=p;useEffect(()=>(show&&publishableKey&&import("@stripe/stripe-js").then(({loadStripe})=>{(async()=>{const res=await loadStripe(publishableKey,{locale});res!=null&&(setStripe(res),setIsLoaded(!0))})()}),()=>{setIsLoaded(!1)}),[show,publishableKey]);const elementsOptions={clientSecret,appearance:{...defaultAppearance,...appearance},fonts};return isLoaded&&stripe!=null&&clientSecret!=null?_jsx("div",{className:containerClassName,...divProps,children:_jsx(Elements,{stripe,options:elementsOptions,children:expressPayments?_jsx(StripeExpressPayment,{clientSecret}):_jsx(StripePaymentForm,{options,templateCustomerSaveToWallet})})}):null}export default StripePayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useRef}from"react";const defaultMessage="after placing the order, you will need to manually complete the payment with your bank";export function WireTransferPayment({infoMessage,...p}){const{className,"data-testid":dataTestId}=p,ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&(ref.current.onsubmit=async()=>await handleClick(),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType]);const handleClick=async()=>{if(paymentSource&&currentPaymentMethodType)try{return await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{metadata:{card:{id:paymentSource.id,brand:"wire-transfer",last4:""}}}}),!0}catch{return!1}return!1};return _jsx("form",{ref,children:_jsx("div",{className,"data-testid":dataTestId,children:_jsx("span",{className:infoMessage?.className,children:infoMessage?.text??defaultMessage})})})}export default WireTransferPayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import Parent from"../utils/Parent";import PricesContext from"../../context/PricesContext";import{useState,useEffect,useContext}from"react";import{getPricesComponent}from"../../utils/getPrices";import SkuChildrenContext from"../../context/SkuChildrenContext";export function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=useContext(PricesContext),{sku}=useContext(SkuChildrenContext),[skuPrices,setSkuPrices]=useState([]),sCode=pricesSkuCode||skuCode||sku?.code;useEffect(()=>(prices!=null&&`${sCode}`in prices?setSkuPrices(prices[sCode]):sCode&&!skuCodes.includes(sCode)&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes({skuCodes})),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps={loading,loader,prices:skuPrices,...props},pricesComponent=prices==null||skuPrices==null?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,{...parentProps,children}):_jsx(_Fragment,{children:loading||pricesComponent==null?loader:pricesComponent})}export default Price;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useContext,useReducer}from"react";import CommerceLayerContext from"../../context/CommerceLayerContext";import priceReducer,{priceInitialState,getSkusPrice,setSkuCodes}from"../../reducers/PriceReducer";import PricesContext from"../../context/PricesContext";import SkuContext from"../../context/SkuContext";export function PricesContainer(props){const{children,skuCode="",loader="Loading...",perPage=10,filters={}}=props,[state,dispatch]=useReducer(priceReducer,priceInitialState),config=useContext(CommerceLayerContext),{skuCodes}=useContext(SkuContext);!state.skuCodes.includes(skuCode)&&skuCode&&state.skuCodes.push(skuCode);const sCode=skuCodes&&skuCodes?.length>0?"":skuCode??"";useEffect(()=>{state.skuCodes.length===0&&skuCodes!=null&&skuCodes.length>0&&state.setSkuCodes!=null&&state.setSkuCodes({skuCodes,dispatch}),config.accessToken&&(state.skuCodes.length>0||sCode)&&getSkusPrice(sCode&&[sCode]||state.skuCodes,{config,dispatch,perPage,filters})},[config.accessToken,sCode,state.skuCodes.length]);const priceValue={...state,skuCode:sCode,loader,setSkuCodes:params=>{setSkuCodes({...params,dispatch})}};return _jsx(PricesContext.Provider,{value:priceValue,children})}export default PricesContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShipmentContext from"../../context/ShipmentContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import OrderContext from"../../context/OrderContext";export function Shipment({children,loader="Loading...",autoSelectSingleShippingMethod=!1}){const[loading,setLoading]=useState(!0),{shipments,deliveryLeadTimes,setShippingMethod}=useContext(ShipmentContext),{order}=useContext(OrderContext);useEffect(()=>(shipments!=null&&(autoSelectSingleShippingMethod?(async()=>{for(const shipment of shipments){const isSingle=shipment?.available_shipping_methods?.length===1;if(!shipment?.shipping_method&&isSingle){const[shippingMethod]=shipment?.available_shipping_methods||[];if(shippingMethod&&setShippingMethod!=null){const{success,order:order2}=await setShippingMethod(shipment.id,shippingMethod.id);typeof autoSelectSingleShippingMethod=="function"&&success&&autoSelectSingleShippingMethod(order2)}}else setTimeout(()=>{setLoading(!1)},200)}})():setLoading(!1)),()=>{setLoading(!0)}),[shipments!=null,shipments?.length,order?.gift_card_or_coupon_code]);const components=shipments?.map((shipment,k)=>{const lineItems=shipment.stock_line_items?.map(shipmentLineItem=>{const l=shipmentLineItem.line_item;return l&&(l.quantity=shipmentLineItem.quantity),l}),shippingMethods=shipment.available_shipping_methods,currentShippingMethodId=autoSelectSingleShippingMethod&&shippingMethods&&shippingMethods.length===1?shippingMethods[0]?.id:shipment.shipping_method?.id,stockTransfers=shipment.stock_transfers,parcels=shipment.parcels,times=deliveryLeadTimes?.filter(time=>time.stock_location?.id===shipment.stock_location?.id),shipmentProps={parcels,lineItems,shippingMethods,currentShippingMethodId,stockTransfers,deliveryLeadTimes:times,shipment,keyNumber:k+1};return _jsx(ShipmentChildrenContext.Provider,{value:shipmentProps,children},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default Shipment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import get from"lodash/get";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function ShipmentField(props){const{name}=props,{shipment,keyNumber}=useContext(ShipmentChildrenContext),key=name,text=key!=="key_number"?get(shipment,key):keyNumber,parentProps={shipment,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...props,children:text})}export default ShipmentField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import ShipmentContext,{defaultShipmentContext}from"../../context/ShipmentContext";import{useContext,useEffect,useMemo,useReducer}from"react";import shipmentReducer,{shipmentInitialState,setShipmentErrors,getShipments,setShippingMethod}from"../../reducers/ShipmentReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import isEmpty from"lodash/isEmpty";export function ShipmentsContainer(props){const{children}=props,[state,dispatch]=useReducer(shipmentReducer,shipmentInitialState),{order,getOrder,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.stock_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0,"shipments.parcels.parcel_line_items":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.stock_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location","shipments.parcels.parcel_line_items"]})},[include?.length,includeLoaded!=null]),useEffect(()=>{order!=null&&!isEmpty(config)&&order.shipments&&getShipments({order,dispatch,config})},[order!=null,order?.shipments?.length]),useEffect(()=>(order&&(order.shipments&&order.shipments.length>0&&order.shipments.map(shipment=>shipment.available_shipping_methods&&shipment.available_shipping_methods.length>0).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"NO_SHIPPING_METHODS",message:"No shipping methods",resource:"shipments"}],dispatch),order.line_items&&order.line_items.length>0&&order.line_items.filter(({item_type:itemType})=>itemType==="skus").map(lineItem=>!!(lineItem.item?.do_not_ship||lineItem.item?.do_not_track||lineItem.item?.inventory?.quantity>=lineItem?.quantity)).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"OUT_OF_STOCK",message:"No stock available",resource:"line_items"}],dispatch)),()=>{setShipmentErrors([],dispatch)}),[order?.shipments]);const contextValue=useMemo(()=>({...state,setShipmentErrors:errors=>{defaultShipmentContext.setShipmentErrors(errors,dispatch)},setShippingMethod:async(shipmentId,shippingMethodId)=>await setShippingMethod({shippingMethodId,shipmentId,config,getOrder,order})}),[state]);return _jsx(ShipmentContext.Provider,{value:contextValue,children})}export default ShipmentsContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import ShipmentContext from"../../context/ShipmentContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function ShipmentsCount({children,...p}){const{shipments}=useCustomContext({context:ShipmentContext,contextComponentName:"ShipmentsContainer",currentComponentName:"ShipmentsCount",key:"shipments"}),quantity=shipments?.length??0,childrenProps={...p,quantity,shipments};return children?_jsx(Parent,{...childrenProps,children}):_jsx("span",{...p,children:quantity})}export default ShipmentsCount;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import isEmpty from"lodash/isEmpty";export function ShippingMethod(props){const{children,readonly,emptyText="There are not any shipping method available"}=props,{shippingMethods,currentShippingMethodId,deliveryLeadTimes,shipment}=useContext(ShipmentChildrenContext),[items,setItems]=useState([]);useEffect(()=>{const methods=shippingMethods?.filter(s=>readonly?s.id===currentShippingMethodId:!0).map((shippingMethod,k)=>{const[deliveryLeadTimeForShipment]=deliveryLeadTimes?.filter(delivery=>{const deliveryShippingMethodId=delivery.shipping_method?.id;return shippingMethod.id===deliveryShippingMethodId}),shippingProps={shipmentId:shipment?.id,shippingMethod,currentShippingMethodId,deliveryLeadTimeForShipment};return _jsx(ShippingMethodChildrenContext.Provider,{value:shippingProps,children},k)});methods&&setItems(methods)},[currentShippingMethodId,deliveryLeadTimes,shippingMethods]);const components=!isEmpty(items)&&items||emptyText;return _jsx(_Fragment,{children:components})}export default ShippingMethod;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";export function ShippingMethodName(props){const{shippingMethod,deliveryLeadTimeForShipment,shipmentId}=useContext(ShippingMethodChildrenContext),htmlFor=`shipment-${shipmentId??""}-${shippingMethod?.id??""}`||"",labelName=shippingMethod?.name,parentProps={shippingMethod,deliveryLeadTimeForShipment,label:labelName,htmlFor,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("label",{htmlFor,...props,children:labelName})}export default ShippingMethodName;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";export function ShippingMethodPrice(props){const{base="price_amount",type="for_shipment",format="formatted",labelFreeOver="Free",...p}=props,{shippingMethod}=useContext(ShippingMethodChildrenContext),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(shippingMethod){const p2=getAmount({base,type,format,obj:shippingMethod});setPrice(p2);const pCents=getAmount({base:"price_amount",type:"for_shipment",format:"cents",obj:shippingMethod});setPriceCents(pCents)}return()=>{setPrice(""),setPriceCents(0)}},[shippingMethod]);const parentProps={price,...p},finalPrice=priceCents===0?labelFreeOver:price;return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:finalPrice})}export default ShippingMethodPrice;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";import ShipmentContext from"../../context/ShipmentContext";export function ShippingMethodRadioButton(props){const{onChange,...p}=props,[checked,setChecked]=useState(!1),{shippingMethod,currentShippingMethodId,shipmentId}=useContext(ShippingMethodChildrenContext),{setShippingMethod}=useContext(ShipmentContext),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId??""}`,id=`${name}-${shippingMethodId??""}`;useEffect(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId]);const handleOnChange=async()=>{if(shipmentId&&shippingMethodId&&setShippingMethod!=null){setChecked(!0);const{order}=await setShippingMethod(shipmentId,shippingMethodId);shippingMethod&&onChange!=null&&onChange({shippingMethod,shipmentId,order})}},parentProps={shippingMethod,shipmentId,handleOnChange,name,id,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("input",{type:"radio",name,id,onChange:()=>{handleOnChange()},checked,...p})}export default ShippingMethodRadioButton;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useReducer,useEffect,useMemo}from"react";import availabilityReducer,{availabilityInitialState,getAvailability}from"../../reducers/AvailabilityReducer";import AvailabilityContext from"../../context/AvailabilityContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import SkuChildrenContext from"../../context/SkuChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityContainer({children,skuCode,getQuantity}){const{lineItem}=useContext(LineItemChildrenContext),{sku}=useContext(SkuChildrenContext),{accessToken,endpoint}=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"AvailabilityContainer",key:"accessToken"}),[state,dispatch]=useReducer(availabilityReducer,availabilityInitialState),sCode=skuCode||lineItem?.sku_code||sku?.code;useEffect(()=>(accessToken!=null&&accessToken!==""&&sCode&&getAvailability({skuCode:sCode,config:{accessToken,endpoint},dispatch}),()=>{dispatch({type:"setAvailability",payload:{}})}),[accessToken,sCode]),useEffect(()=>{getQuantity!=null&&state?.quantity!=null&&getQuantity(state?.quantity)},[state.quantity]);const memoized=useMemo(()=>({...state,parent:!0}),[state]);return _jsx(AvailabilityContext.Provider,{value:memoized,children})}export default AvailabilityContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import AvailabilityContext from"../../context/AvailabilityContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityTemplate(props){const{timeFormat,showShippingMethodName,showShippingMethodPrice,children,...p}=props,{min,max,shipping_method:shippingMethod,quantity,skuCode}=useCustomContext({context:AvailabilityContext,contextComponentName:"AvailabilityContainer",currentComponentName:"AvailabilityTemplate",key:"parent"}),text=[],mn=min!=null&&timeFormat!=null?min?.[timeFormat]:"",mx=max!=null&&timeFormat!=null?max?.[timeFormat]:"",shippingMethodPrice=showShippingMethodPrice&&shippingMethod?.formatted_price_amount?`(${shippingMethod?.formatted_price_amount})`:"",name=showShippingMethodName&&shippingMethod?`with ${shippingMethod.name}`:"";quantity&&quantity>0?(text.push("Available"),mn&&mx&&timeFormat&&text.push(`in ${mn} - ${mx} ${timeFormat} ${name} ${shippingMethodPrice}`)):quantity===0&&text.push("Out of stock");const parentProps={min,max,shipping_method:shippingMethod,quantity,text:text.join(" "),...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{"data-testid":skuCode?`availability-${skuCode}`:"",...p,children:text.join(" ")})}export default AvailabilityTemplate;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";export function DeliveryLeadTime(props){const{type,...p}=props,[text,setText]=useState(),{deliveryLeadTimeForShipment}=useContext(ShippingMethodChildrenContext);useEffect(()=>(deliveryLeadTimeForShipment?.[type]&&setText(deliveryLeadTimeForShipment[type]),()=>{setText("")}),[deliveryLeadTimeForShipment]);const parentProps={text,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:text})}export default DeliveryLeadTime;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function SkuField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"sku",attribute,tagElement,context:SkuChildrenContext,...p,children})}export default SkuField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{Fragment as _Fragment,jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect}from"react";import SkuListsContext from"../../context/SkuListsContext";export function SkuList(props){const{id,children}=props,{listIds}=useContext(SkuListsContext);return useEffect(()=>{listIds&&!listIds.includes(id)&&listIds.push(id)},[]),_jsx(_Fragment,{children})}export default SkuList;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useReducer,useContext,useEffect}from"react";import SkuListsContext from"../../context/SkuListsContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import skuListsReducer,{skuListsInitialState,getSkuList}from"../../reducers/SkuListsReducer";export function SkuListsContainer(props){const{children}=props,[state,dispatch]=useReducer(skuListsReducer,skuListsInitialState),config=useContext(CommerceLayerContext);return useEffect(()=>{state.listIds&&state.listIds.length>0&&config.accessToken&&getSkuList({listIds:state.listIds,dispatch,config,state})},[config.accessToken]),_jsx(SkuListsContext.Provider,{value:state,children})}export default SkuListsContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import SkuContext from"../../context/SkuContext";import{useContext}from"react";export function Skus({children}){const{skus}=useContext(SkuContext),components=skus?.map((sku,key)=>{const value={sku};return _jsx(SkuChildrenContext.Provider,{value,children},key)});return _jsx(_Fragment,{children:components})}export default Skus;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import SkuContext from"../../context/SkuContext";import skuReducer,{getSku,skuInitialState}from"../../reducers/SkuReducer";import{useContext,useEffect,useMemo,useReducer}from"react";export function SkusContainer(props){const{skus,children,queryParams}=props,[state,dispatch]=useReducer(skuReducer,skuInitialState),config=useContext(CommerceLayerContext),loadSkus=async()=>{await getSku({config,dispatch,skus,queryParams})};useEffect(()=>(config.accessToken&&state?.skus&&state?.skus.length===0&&loadSkus(),()=>{dispatch({type:"setLoading",payload:{loading:!0}})}),[config,skus]);const contextValue=useMemo(()=>state,[state]);return _jsx(SkuContext.Provider,{value:contextValue,children})}export default SkusContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import StockTransferChildrenContext from"../../context/StockTransferChildrenContext";export function StockTransfer(props){const{children}=props,{stockTransfers,lineItems}=useContext(ShipmentChildrenContext),components=stockTransfers?.filter(st=>!!lineItems?.find(l=>l?.sku_code!==st?.sku_code)).map((stockTransfer,k)=>{const stockTransferProps={stockTransfer:stockTransfer.type==="line_items"?stockTransfer:stockTransfer?.line_item};return _jsx(StockTransferChildrenContext.Provider,{value:stockTransferProps,children},k)});return _jsx(_Fragment,{children:components})}export default StockTransfer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import StockTransferChildrenContext from"../../context/StockTransferChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function StockTransferField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"stock_transfers",attribute,tagElement,context:StockTransferChildrenContext,...p,children})}export default StockTransferField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import{useContext}from"react";import AddressChildrenContext from"../../context/AddressChildrenContext";import ShippingAddressContext from"../../context/ShippingAddressContext";export default function AddressCardsTemplate({customerAddresses,children,deselect,countryLock,selected,selectedClassName,className,disabledClassName,handleSelect}){const{setShippingAddress}=useContext(ShippingAddressContext),value={customerAddresses:customerAddresses.map((address,k)=>{const attributes=address,disabled=setShippingAddress&&countryLock&&countryLock!==address.country_code||!1,addressSelectedClass=selected===k?`${className??""} ${(deselect?"":selectedClassName)??""}`:className,finalClassName=disabled?`${className??""} ${disabledClassName??""}`:addressSelectedClass,customerAddressId=address?.reference||"";return{...attributes,className:finalClassName,onClick:async()=>{await handleSelect(k,address.id,customerAddressId,disabled,address)}}}),AddressProvider:AddressChildrenContext.Provider};return _jsx(Parent,{...value,children})}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import{useContext,useEffect,useState}from"react";import Parent from"./Parent";const BaseField=({children,attribute,...p})=>{const{order}=useContext(OrderContext),[field,setField]=useState("");useEffect(()=>(order&&attribute in order&&setField(order[attribute]),()=>{setField("")}),[order]);const parentProps={attribute:field,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:field})};export default BaseField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import React from"react";import Parent from"./Parent";const BaseInput=(props,ref)=>{const{children,...p}=props,input=props.type==="textarea"?_jsx("textarea",{ref,...p}):_jsx("input",{ref,...p});return children?_jsx(Parent,{parentRef:ref,...p,children}):input};export default React.forwardRef(BaseInput);
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import getAmount from"../../utils/getAmount";import Parent from"./Parent";import{useState,useEffect,useContext}from"react";import isEmpty from"lodash/isEmpty";export function BaseOrderPrice(props){const{format="formatted",base,type,children,...p}=props,{order}=useContext(OrderContext),[price,setPrice]=useState(""),[cents,setCents]=useState(0);useEffect(()=>{const p2=getAmount({base,type,format,obj:order||{}}),c=getAmount({base,type,format:"cents",obj:order||{}});return setPrice(p2),setCents(c),()=>{isEmpty(order)&&setPrice("")}},[order]);const parentProps={priceCents:cents,price,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:price})}export default BaseOrderPrice;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import React from"react";import Parent from"./Parent";import{findIndex}from"lodash";const BaseSelect=(props,ref)=>{const{options=[],children,placeholder={label:"Select an option",value:""},value="",...p}=props;findIndex(options,placeholder)===-1?options.unshift(placeholder):options[0]=placeholder;const Options=options.map((o,k)=>{const{label,...option}=o;return _jsx("option",{...option,children:label},k)}),parentProps={options,ref,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("select",{ref,defaultValue:value,...p,children:Options})};export default React.forwardRef(BaseSelect);
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";export class ErrorBoundary extends Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(error,errorInfo){if(process.env.NODE_ENV!=="test")console.error("Uncaught error:",error,errorInfo);else throw error}render(){return this.state.hasError?_jsx("h1",{children:"Sorry.. there was an error, check the console."}):this.props.children}}export default ErrorBoundary;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"./Parent";import{useContext}from"react";import{defaultImgUrl}from"../../utils/placeholderImages";export default function GenericFieldComponent(props){const{children,tagElement,attribute,context,resource,...p}=props,resourceContext=useContext(context);let attributeValue="";const keysContext=Object.keys(resourceContext).filter(key=>key===resource);if(keysContext.length===1){const[keyResource]=keysContext;keyResource&&attribute&&(attributeValue=resourceContext[keyResource][attribute])}const Tag=tagElement||"span";if(Tag==="img"&&!children)return _jsx("img",{alt:"",src:attributeValue||defaultImgUrl,...p});const parentProps={attributeValue,tagElement,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx(Tag,{"data-testid":attributeValue,...p,children:attributeValue},attributeValue)}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";export default function Parent({children,...p}){const Child=children;return Child!==void 0?_jsx(Child,{...p}):null}
@@ -1,14 +1,39 @@
1
1
  import { type PaymentResource } from '../../reducers/PaymentMethodReducer';
2
- import PaymentSourceContext from '../../context/PaymentSourceContext';
2
+ import PaymentSourceContext, { type IconBrand } from '../../context/PaymentSourceContext';
3
3
  import { type ChildrenFunction } from '../../typings/index';
4
4
  import { type CustomerPaymentSource } from '@commercelayer/sdk';
5
5
  interface ChildrenProps extends Pick<Props, 'customerPayments'> {
6
6
  PaymentSourceProvider: typeof PaymentSourceContext.Provider;
7
7
  }
8
+ interface CustomerPayment extends CustomerPaymentSource {
9
+ /**
10
+ * Card details
11
+ */
12
+ card?: {
13
+ /**
14
+ * Card brand
15
+ */
16
+ brand: IconBrand;
17
+ /**
18
+ * Card last 4 digits
19
+ */
20
+ last4: string;
21
+ };
22
+ /**
23
+ * Handle click event
24
+ */
25
+ handleClick?: () => void;
26
+ }
8
27
  export type CustomerCardsTemplateChildren = ChildrenFunction<ChildrenProps>;
9
28
  interface Props {
10
- customerPayments: CustomerPaymentSource[];
29
+ /**
30
+ * Customer payments
31
+ */
32
+ customerPayments: CustomerPayment[];
11
33
  children: CustomerCardsTemplateChildren;
34
+ /**
35
+ * Payment resource
36
+ */
12
37
  paymentResource: PaymentResource;
13
38
  }
14
39
  export default function PaymentCardsTemplate({ customerPayments, children, paymentResource }: Props): JSX.Element;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import{useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import getCardDetails from"../../utils/getCardDetails";export default function PaymentCardsTemplate({customerPayments,children,paymentResource}){const{setPaymentSource}=useContext(PaymentMethodContext),value={customerPayments:customerPayments.map(customerPayment=>{const attributes=customerPayment,card=getCardDetails({customerPayment,paymentType:paymentResource});return{...attributes,card,handleClick:async e=>{e.stopPropagation(),await setPaymentSource({paymentResource,customerPaymentSourceId:customerPayment.id})}}}),PaymentSourceProvider:PaymentSourceContext.Provider};return _jsx(Parent,{...value,children})}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export function PriceTemplate(props){const{showCompare,formattedCompare,compareClassName,className,formattedAmount,skuCode,...p}=props;return _jsxs(_Fragment,{children:[_jsx("span",{"data-testid":`price-${skuCode??""}`,className,...p,children:formattedAmount}),showCompare&&_jsx("span",{"data-testid":`compare-${skuCode??""}`,className:compareClassName||"",...p,children:formattedCompare})]})}export default PriceTemplate;