@commercelayer/react-components 2.53.3 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +3 -3
  3. package/lib/components/AdyenPayment.d.ts +3 -3
  4. package/lib/components/AdyenPayment.js +1 -1
  5. package/lib/components/AvailabilityContainer.d.ts +10 -3
  6. package/lib/components/AvailabilityContainer.js +1 -1
  7. package/lib/components/AvailabilityTemplate.d.ts +13 -4
  8. package/lib/components/AvailabilityTemplate.js +1 -1
  9. package/lib/components/BillingAddressContainer.d.ts +7 -2
  10. package/lib/components/BillingAddressContainer.js +1 -1
  11. package/lib/components/BillingAddressForm.d.ts +8 -3
  12. package/lib/components/BillingAddressForm.js +1 -1
  13. package/lib/components/BraintreePayment.d.ts +3 -3
  14. package/lib/components/BraintreePayment.js +1 -1
  15. package/lib/components/CheckoutComPayment.d.ts +23 -0
  16. package/lib/components/CheckoutComPayment.js +1 -0
  17. package/lib/components/CheckoutLink.d.ts +16 -4
  18. package/lib/components/CheckoutLink.js +1 -1
  19. package/lib/components/DeliveryLeadTime.d.ts +11 -4
  20. package/lib/components/DeliveryLeadTime.js +1 -1
  21. package/lib/components/DiscountAmount.d.ts +16 -2
  22. package/lib/components/DiscountAmount.js +1 -1
  23. package/lib/components/Errors.d.ts +4 -4
  24. package/lib/components/Errors.js +1 -1
  25. package/lib/components/ExternalFunction.d.ts +9 -2
  26. package/lib/components/ExternalFunction.js +1 -1
  27. package/lib/components/GiftCard.d.ts +13 -3
  28. package/lib/components/GiftCard.js +1 -1
  29. package/lib/components/GiftCardContainer.d.ts +9 -3
  30. package/lib/components/GiftCardContainer.js +1 -1
  31. package/lib/components/GiftCardCurrencySelector.d.ts +18 -3
  32. package/lib/components/GiftCardCurrencySelector.js +1 -1
  33. package/lib/components/GiftCardInput.d.ts +12 -3
  34. package/lib/components/GiftCardInput.js +1 -1
  35. package/lib/components/GiftCardOrCouponCode.d.ts +17 -6
  36. package/lib/components/GiftCardOrCouponCode.js +1 -1
  37. package/lib/components/GiftCardOrCouponForm.d.ts +9 -4
  38. package/lib/components/GiftCardOrCouponForm.js +1 -1
  39. package/lib/components/GiftCardOrCouponInput.d.ts +14 -3
  40. package/lib/components/GiftCardOrCouponInput.js +1 -1
  41. package/lib/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
  42. package/lib/components/GiftCardOrCouponRemoveButton.js +1 -1
  43. package/lib/components/GiftCardOrCouponSubmit.d.ts +11 -4
  44. package/lib/components/GiftCardOrCouponSubmit.js +1 -1
  45. package/lib/components/ItemContainer.d.ts +14 -3
  46. package/lib/components/ItemContainer.js +1 -1
  47. package/lib/components/KlarnaPayment.d.ts +10 -0
  48. package/lib/components/KlarnaPayment.js +1 -0
  49. package/lib/components/LineItem.d.ts +10 -3
  50. package/lib/components/LineItem.js +1 -1
  51. package/lib/components/LineItemAmount.d.ts +16 -3
  52. package/lib/components/LineItemAmount.js +1 -1
  53. package/lib/components/LineItemCode.d.ts +10 -4
  54. package/lib/components/LineItemCode.js +1 -1
  55. package/lib/components/LineItemImage.d.ts +11 -4
  56. package/lib/components/LineItemImage.js +1 -1
  57. package/lib/components/LineItemName.d.ts +11 -5
  58. package/lib/components/LineItemName.js +1 -1
  59. package/lib/components/LineItemOption.d.ts +15 -4
  60. package/lib/components/LineItemOption.js +1 -1
  61. package/lib/components/LineItemOptions.d.ts +8 -3
  62. package/lib/components/LineItemOptions.js +1 -1
  63. package/lib/components/LineItemQuantity.d.ts +16 -4
  64. package/lib/components/LineItemQuantity.js +1 -1
  65. package/lib/components/LineItemRemoveLink.d.ts +15 -5
  66. package/lib/components/LineItemRemoveLink.js +1 -1
  67. package/lib/components/LineItemsContainer.d.ts +15 -3
  68. package/lib/components/LineItemsContainer.js +1 -1
  69. package/lib/components/LineItemsCount.d.ts +14 -4
  70. package/lib/components/LineItemsCount.js +1 -1
  71. package/lib/components/LineItemsEmpty.d.ts +13 -2
  72. package/lib/components/LineItemsEmpty.js +1 -1
  73. package/lib/components/MetadataInput.d.ts +13 -3
  74. package/lib/components/MetadataInput.js +1 -1
  75. package/lib/components/PaymentGateway.d.ts +4 -4
  76. package/lib/components/PaymentGateway.js +1 -1
  77. package/lib/components/PaymentMethod.d.ts +9 -3
  78. package/lib/components/PaymentMethod.js +1 -1
  79. package/lib/components/PaymentMethodAmount.d.ts +16 -2
  80. package/lib/components/PaymentMethodAmount.js +1 -1
  81. package/lib/components/PaymentMethodName.d.ts +10 -4
  82. package/lib/components/PaymentMethodName.js +1 -1
  83. package/lib/components/PaymentMethodPrice.d.ts +15 -4
  84. package/lib/components/PaymentMethodPrice.js +1 -1
  85. package/lib/components/PaymentMethodRadioButton.d.ts +11 -4
  86. package/lib/components/PaymentMethodRadioButton.js +1 -1
  87. package/lib/components/PaymentMethodsContainer.d.ts +9 -3
  88. package/lib/components/PaymentMethodsContainer.js +1 -1
  89. package/lib/components/PaymentSource.d.ts +9 -2
  90. package/lib/components/PaymentSource.js +1 -1
  91. package/lib/components/PaymentSourceBrandIcon.d.ts +14 -4
  92. package/lib/components/PaymentSourceBrandIcon.js +1 -1
  93. package/lib/components/PaymentSourceBrandName.d.ts +11 -4
  94. package/lib/components/PaymentSourceBrandName.js +1 -1
  95. package/lib/components/PaymentSourceDetail.d.ts +8 -2
  96. package/lib/components/PaymentSourceDetail.js +1 -1
  97. package/lib/components/PaymentSourceEditButton.d.ts +9 -2
  98. package/lib/components/PaymentSourceEditButton.js +1 -1
  99. package/lib/components/PaypalPayment.d.ts +2 -2
  100. package/lib/components/PaypalPayment.js +1 -1
  101. package/lib/components/Price.d.ts +15 -3
  102. package/lib/components/Price.js +1 -1
  103. package/lib/components/PricesContainer.d.ts +19 -3
  104. package/lib/components/PricesContainer.js +1 -1
  105. package/lib/components/QuantitySelector.d.ts +19 -5
  106. package/lib/components/QuantitySelector.js +1 -1
  107. package/lib/components/SaveAddressesButton.d.ts +18 -5
  108. package/lib/components/SaveAddressesButton.js +1 -1
  109. package/lib/components/SaveCustomerButton.d.ts +16 -5
  110. package/lib/components/SaveCustomerButton.js +1 -1
  111. package/lib/components/Shipment.d.ts +9 -2
  112. package/lib/components/Shipment.js +1 -1
  113. package/lib/components/ShipmentField.d.ts +11 -4
  114. package/lib/components/ShipmentField.js +1 -1
  115. package/lib/components/ShipmentsContainer.d.ts +9 -3
  116. package/lib/components/ShipmentsContainer.js +1 -1
  117. package/lib/components/ShippingAddressContainer.d.ts +7 -2
  118. package/lib/components/ShippingAddressContainer.js +1 -1
  119. package/lib/components/ShippingAddressForm.d.ts +8 -3
  120. package/lib/components/ShippingAddressForm.js +1 -1
  121. package/lib/components/ShippingAmount.d.ts +13 -2
  122. package/lib/components/ShippingAmount.js +1 -1
  123. package/lib/components/ShippingMethod.d.ts +10 -3
  124. package/lib/components/ShippingMethod.js +1 -1
  125. package/lib/components/ShippingMethodName.d.ts +11 -5
  126. package/lib/components/ShippingMethodName.js +1 -1
  127. package/lib/components/ShippingMethodPrice.d.ts +15 -3
  128. package/lib/components/ShippingMethodPrice.js +1 -1
  129. package/lib/components/ShippingMethodRadioButton.d.ts +11 -5
  130. package/lib/components/ShippingMethodRadioButton.js +1 -1
  131. package/lib/components/StockTransfer.d.ts +9 -3
  132. package/lib/components/StockTransfer.js +1 -1
  133. package/lib/components/StockTransferField.d.ts +9 -8
  134. package/lib/components/StockTransferField.js +1 -1
  135. package/lib/components/StripePayment.d.ts +3 -3
  136. package/lib/components/StripePayment.js +1 -1
  137. package/lib/components/SubmitButton.d.ts +15 -5
  138. package/lib/components/SubmitButton.js +1 -1
  139. package/lib/components/VariantSelector.d.ts +28 -5
  140. package/lib/components/VariantSelector.js +1 -1
  141. package/lib/components/VariantsContainer.d.ts +15 -3
  142. package/lib/components/VariantsContainer.js +1 -1
  143. package/lib/components/WireTransferPayment.d.ts +2 -2
  144. package/lib/components/WireTransferPayment.js +1 -1
  145. package/lib/components/addresses/Address.d.ts +18 -0
  146. package/lib/components/addresses/Address.js +1 -0
  147. package/lib/components/addresses/AddressCountrySelector.d.ts +26 -0
  148. package/lib/components/addresses/AddressCountrySelector.js +1 -0
  149. package/lib/components/addresses/AddressField.d.ts +43 -0
  150. package/lib/components/addresses/AddressField.js +1 -0
  151. package/lib/components/addresses/AddressInput.d.ts +19 -0
  152. package/lib/components/addresses/AddressInput.js +1 -0
  153. package/lib/components/addresses/AddressStateSelector.d.ts +27 -0
  154. package/lib/components/addresses/AddressStateSelector.js +1 -0
  155. package/lib/components/addresses/AddressesContainer.d.ts +15 -0
  156. package/lib/components/addresses/AddressesContainer.js +1 -0
  157. package/lib/components/auth/CommerceLayer.d.ts +15 -0
  158. package/lib/components/auth/CommerceLayer.js +1 -0
  159. package/lib/components/customers/CustomerAddressForm.d.ts +13 -0
  160. package/lib/components/customers/CustomerAddressForm.js +1 -0
  161. package/lib/components/customers/CustomerContainer.d.ts +17 -0
  162. package/lib/components/customers/CustomerContainer.js +1 -0
  163. package/lib/components/customers/CustomerField.d.ts +10 -0
  164. package/lib/components/customers/CustomerField.js +1 -0
  165. package/lib/components/customers/CustomerInput.d.ts +23 -0
  166. package/lib/components/customers/CustomerInput.js +1 -0
  167. package/lib/components/gateways/AdyenGateway.d.ts +2 -2
  168. package/lib/components/gateways/AdyenGateway.js +1 -1
  169. package/lib/components/gateways/BraintreeGateway.d.ts +2 -2
  170. package/lib/components/gateways/BraintreeGateway.js +1 -1
  171. package/lib/components/gateways/CheckoutComGateway.d.ts +5 -0
  172. package/lib/components/gateways/CheckoutComGateway.js +1 -0
  173. package/lib/components/gateways/KlarnaGateway.d.ts +5 -0
  174. package/lib/components/gateways/KlarnaGateway.js +1 -0
  175. package/lib/components/gateways/PaypalGateway.d.ts +3 -3
  176. package/lib/components/gateways/PaypalGateway.js +1 -1
  177. package/lib/components/gateways/StripeGateway.d.ts +2 -2
  178. package/lib/components/gateways/StripeGateway.js +1 -1
  179. package/lib/components/gateways/WireTransferGateway.d.ts +2 -2
  180. package/lib/components/gateways/WireTransferGateway.js +1 -1
  181. package/lib/components/orders/AddToCartButton.d.ts +34 -0
  182. package/lib/components/orders/AddToCartButton.js +1 -0
  183. package/lib/components/orders/AdjustmentAmount.d.ts +18 -0
  184. package/lib/components/orders/AdjustmentAmount.js +1 -0
  185. package/lib/components/orders/CartLink.d.ts +12 -0
  186. package/lib/components/orders/CartLink.js +1 -0
  187. package/lib/components/orders/GiftCardAmount.d.ts +15 -0
  188. package/lib/components/orders/GiftCardAmount.js +1 -0
  189. package/lib/components/orders/OrderContainer.d.ts +26 -0
  190. package/lib/components/orders/OrderContainer.js +1 -0
  191. package/lib/components/orders/OrderList.d.ts +61 -0
  192. package/lib/components/orders/OrderList.js +1 -0
  193. package/lib/components/orders/OrderListRow.d.ts +30 -0
  194. package/lib/components/orders/OrderListRow.js +1 -0
  195. package/lib/components/orders/OrderNumber.d.ts +11 -0
  196. package/lib/components/orders/OrderNumber.js +1 -0
  197. package/lib/components/orders/OrderStorage.d.ts +16 -0
  198. package/lib/components/orders/OrderStorage.js +1 -0
  199. package/lib/components/orders/PlaceOrderButton.d.ts +24 -0
  200. package/lib/components/orders/PlaceOrderButton.js +1 -0
  201. package/lib/components/orders/PlaceOrderContainer.d.ts +14 -0
  202. package/lib/components/orders/PlaceOrderContainer.js +1 -0
  203. package/lib/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
  204. package/lib/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  205. package/lib/components/orders/SubTotalAmount.d.ts +18 -0
  206. package/lib/components/orders/SubTotalAmount.js +1 -0
  207. package/lib/components/orders/TaxesAmount.d.ts +18 -0
  208. package/lib/components/orders/TaxesAmount.js +1 -0
  209. package/lib/components/orders/TotalAmount.d.ts +18 -0
  210. package/lib/components/orders/TotalAmount.js +1 -0
  211. package/lib/components/skus/SkuField.d.ts +14 -0
  212. package/lib/components/skus/SkuField.js +1 -0
  213. package/lib/components/skus/SkuList.d.ts +14 -0
  214. package/lib/components/skus/SkuList.js +1 -0
  215. package/lib/components/skus/SkuListsContainer.d.ts +12 -0
  216. package/lib/components/skus/SkuListsContainer.js +1 -0
  217. package/lib/components/skus/SkuOption.d.ts +14 -0
  218. package/lib/components/skus/SkuOption.js +1 -0
  219. package/lib/components/skus/SkuOptionInput.d.ts +15 -0
  220. package/lib/components/skus/SkuOptionInput.js +1 -0
  221. package/lib/components/skus/SkuOptionsContainer.d.ts +14 -0
  222. package/lib/components/skus/SkuOptionsContainer.js +1 -0
  223. package/lib/components/skus/Skus.d.ts +11 -0
  224. package/lib/components/skus/Skus.js +1 -0
  225. package/lib/components/skus/SkusContainer.d.ts +23 -0
  226. package/lib/components/skus/SkusContainer.js +1 -0
  227. package/lib/components/utils/AddressCardsTemplate.d.ts +1 -1
  228. package/lib/components/utils/AddressCardsTemplate.js +1 -1
  229. package/lib/components/utils/BaseField.js +1 -1
  230. package/lib/components/utils/BaseInput.d.ts +1 -1
  231. package/lib/components/utils/BaseInput.js +1 -1
  232. package/lib/components/utils/BaseOrderPrice.js +1 -1
  233. package/lib/components/utils/BaseSelect.js +1 -1
  234. package/lib/components/utils/GenericFieldComponent.d.ts +42 -0
  235. package/lib/components/utils/GenericFieldComponent.js +1 -0
  236. package/lib/components/utils/Parent.d.ts +3 -5
  237. package/lib/components/utils/Parent.js +1 -1
  238. package/lib/components/utils/PaymentCardsTemplate.d.ts +2 -2
  239. package/lib/components/utils/PaymentCardsTemplate.js +1 -1
  240. package/lib/components/utils/PriceTemplate.d.ts +2 -2
  241. package/lib/components/utils/PriceTemplate.js +1 -1
  242. package/lib/components/utils/VariantTemplate.js +1 -1
  243. package/lib/components/utils/getAllErrors.js +1 -1
  244. package/lib/config/components.d.ts +77 -35
  245. package/lib/config/components.js +1 -1
  246. package/lib/context/AddressChildrenContext.d.ts +1 -1
  247. package/lib/context/AddressChildrenContext.js +1 -1
  248. package/lib/context/AddressContext.d.ts +1 -1
  249. package/lib/context/BillingAddressContext.d.ts +2 -4
  250. package/lib/context/BillingAddressContext.js +1 -1
  251. package/lib/context/BillingAddressFormContext.d.ts +17 -10
  252. package/lib/context/CouponAndGiftCardFormContext.d.ts +2 -0
  253. package/lib/context/CustomerAddressFormContext.d.ts +20 -0
  254. package/lib/context/CustomerAddressFormContext.js +1 -0
  255. package/lib/context/CustomerContext.d.ts +17 -11
  256. package/lib/context/CustomerContext.js +1 -1
  257. package/lib/context/OrderContext.d.ts +8 -4
  258. package/lib/context/OrderContext.js +1 -1
  259. package/lib/context/OrderListChildrenContext.d.ts +60 -0
  260. package/lib/context/OrderListChildrenContext.js +1 -0
  261. package/lib/context/PaymentSourceContext.d.ts +4 -4
  262. package/lib/context/PlaceOrderContext.d.ts +4 -2
  263. package/lib/context/ShippingAddressContext.d.ts +1 -1
  264. package/lib/context/SkuChildrenContext.d.ts +9 -0
  265. package/lib/context/SkuChildrenContext.js +1 -0
  266. package/lib/context/SkuContext.d.ts +9 -0
  267. package/lib/context/SkuContext.js +1 -0
  268. package/lib/index.d.ts +101 -90
  269. package/lib/index.js +1 -1
  270. package/lib/reducers/AddressReducer.d.ts +4 -2
  271. package/lib/reducers/AddressReducer.js +1 -1
  272. package/lib/reducers/AvailabilityReducer.d.ts +8 -0
  273. package/lib/reducers/AvailabilityReducer.js +1 -1
  274. package/lib/reducers/BillingAddressReducer.js +1 -1
  275. package/lib/reducers/CustomerReducer.d.ts +98 -17
  276. package/lib/reducers/CustomerReducer.js +1 -1
  277. package/lib/reducers/GiftCardReducer.js +1 -1
  278. package/lib/reducers/LineItemReducer.js +1 -1
  279. package/lib/reducers/OrderReducer.d.ts +24 -8
  280. package/lib/reducers/OrderReducer.js +1 -1
  281. package/lib/reducers/PaymentMethodReducer.d.ts +51 -5
  282. package/lib/reducers/PaymentMethodReducer.js +1 -1
  283. package/lib/reducers/PlaceOrderReducer.d.ts +9 -2
  284. package/lib/reducers/PlaceOrderReducer.js +1 -1
  285. package/lib/reducers/ShipmentReducer.js +1 -1
  286. package/lib/reducers/ShippingAddressReducer.js +1 -1
  287. package/lib/reducers/SkuReducer.d.ts +21 -0
  288. package/lib/reducers/SkuReducer.js +1 -0
  289. package/lib/reducers/VariantReducer.d.ts +1 -0
  290. package/lib/reducers/VariantReducer.js +1 -1
  291. package/lib/typings/errors.d.ts +13 -4
  292. package/lib/typings/errors.js +1 -1
  293. package/lib/typings/index.d.ts +17 -6
  294. package/lib/utils/addressesManager.d.ts +1 -1
  295. package/lib/utils/addressesManager.js +1 -1
  296. package/lib/utils/checkIncludeResource.d.ts +8 -0
  297. package/lib/utils/checkIncludeResource.js +1 -0
  298. package/lib/utils/childrenTypes.d.ts +1 -1
  299. package/lib/utils/childrenTypes.js +1 -1
  300. package/lib/utils/compareObjAttribute.d.ts +7 -0
  301. package/lib/utils/compareObjAttribute.js +1 -0
  302. package/lib/utils/customMessages.d.ts +1 -7
  303. package/lib/utils/customMessages.js +1 -1
  304. package/lib/utils/getCardDetails.d.ts +15 -0
  305. package/lib/utils/getCardDetails.js +1 -0
  306. package/lib/utils/getCartLink.d.ts +7 -0
  307. package/lib/utils/getCartLink.js +1 -0
  308. package/lib/utils/getCurrentItemKey.js +1 -1
  309. package/lib/utils/getErrors.d.ts +1 -1
  310. package/lib/utils/getErrors.js +1 -1
  311. package/lib/utils/getLineItemsCount.d.ts +8 -10
  312. package/lib/utils/getLineItemsCount.js +1 -1
  313. package/lib/utils/getLoaderComponent.js +1 -1
  314. package/lib/utils/getPrices.js +1 -1
  315. package/lib/utils/getSkus.js +1 -1
  316. package/lib/utils/hooks/useExternalScript.d.ts +1 -0
  317. package/lib/utils/hooks/useExternalScript.js +1 -0
  318. package/lib/utils/icons.d.ts +3 -0
  319. package/lib/utils/icons.js +1 -0
  320. package/lib/utils/isDate.d.ts +1 -0
  321. package/lib/utils/isDate.js +1 -0
  322. package/lib/utils/jwt.d.ts +1 -1
  323. package/lib/utils/placeholderImages.d.ts +2 -0
  324. package/lib/utils/placeholderImages.js +1 -0
  325. package/lib/utils/promisify.js +1 -1
  326. package/lib/utils/scrollbarWidth.d.ts +1 -0
  327. package/lib/utils/scrollbarWidth.js +1 -0
  328. package/lib/utils/shipments.d.ts +2 -1
  329. package/lib/utils/shipments.js +1 -1
  330. package/lib/utils/validateFormFields.d.ts +2 -0
  331. package/lib/utils/validateFormFields.js +1 -1
  332. package/package.json +96 -93
  333. package/lib/components/AddToCartButton.d.ts +0 -20
  334. package/lib/components/AddToCartButton.js +0 -1
  335. package/lib/components/Address.d.ts +0 -13
  336. package/lib/components/Address.js +0 -1
  337. package/lib/components/AddressCountrySelector.d.ts +0 -9
  338. package/lib/components/AddressCountrySelector.js +0 -1
  339. package/lib/components/AddressField.d.ts +0 -15
  340. package/lib/components/AddressField.js +0 -1
  341. package/lib/components/AddressInput.d.ts +0 -7
  342. package/lib/components/AddressInput.js +0 -1
  343. package/lib/components/AddressStateSelector.d.ts +0 -11
  344. package/lib/components/AddressStateSelector.js +0 -1
  345. package/lib/components/AddressesContainer.d.ts +0 -7
  346. package/lib/components/AddressesContainer.js +0 -1
  347. package/lib/components/AdjustmentAmount.d.ts +0 -4
  348. package/lib/components/AdjustmentAmount.js +0 -1
  349. package/lib/components/CommerceLayer.d.ts +0 -8
  350. package/lib/components/CommerceLayer.js +0 -1
  351. package/lib/components/CustomerContainer.d.ts +0 -7
  352. package/lib/components/CustomerContainer.js +0 -1
  353. package/lib/components/CustomerInput.d.ts +0 -11
  354. package/lib/components/CustomerInput.js +0 -1
  355. package/lib/components/GiftCardAmount.d.ts +0 -4
  356. package/lib/components/GiftCardAmount.js +0 -1
  357. package/lib/components/OrderContainer.d.ts +0 -11
  358. package/lib/components/OrderContainer.js +0 -1
  359. package/lib/components/OrderNumber.d.ts +0 -5
  360. package/lib/components/OrderNumber.js +0 -1
  361. package/lib/components/OrderStorage.d.ts +0 -8
  362. package/lib/components/OrderStorage.js +0 -1
  363. package/lib/components/PlaceOrderButton.d.ts +0 -12
  364. package/lib/components/PlaceOrderButton.js +0 -1
  365. package/lib/components/PlaceOrderContainer.d.ts +0 -8
  366. package/lib/components/PlaceOrderContainer.js +0 -1
  367. package/lib/components/PrivacyAndTermsCheckbox.d.ts +0 -4
  368. package/lib/components/PrivacyAndTermsCheckbox.js +0 -1
  369. package/lib/components/SkuList.d.ts +0 -7
  370. package/lib/components/SkuList.js +0 -1
  371. package/lib/components/SkuListsContainer.d.ts +0 -6
  372. package/lib/components/SkuListsContainer.js +0 -1
  373. package/lib/components/SkuOption.d.ts +0 -7
  374. package/lib/components/SkuOption.js +0 -1
  375. package/lib/components/SkuOptionInput.d.ts +0 -5
  376. package/lib/components/SkuOptionInput.js +0 -1
  377. package/lib/components/SkuOptionsContainer.d.ts +0 -7
  378. package/lib/components/SkuOptionsContainer.js +0 -1
  379. package/lib/components/SubTotalAmount.d.ts +0 -4
  380. package/lib/components/SubTotalAmount.js +0 -1
  381. package/lib/components/TaxesAmount.d.ts +0 -4
  382. package/lib/components/TaxesAmount.js +0 -1
  383. package/lib/components/TotalAmount.d.ts +0 -4
  384. package/lib/components/TotalAmount.js +0 -1
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../reducers/LineItemReducer";import OrderContext from"../context/OrderContext";import LineItemContext from"../context/LineItemContext";import CommerceLayerContext from"../context/CommerceLayerContext";import{isEmpty}from"lodash";import components from"../config/components";const propTypes=components.LineItemsContainer.propTypes,defaultProps=components.LineItemsContainer.defaultProps,displayName=components.LineItemsContainer.displayName,LineItemsContainer=props=>{const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>((include==null?void 0:include.includes("line_items.line_item_options.sku_option"))?(includeLoaded==null?void 0:includeLoaded["line_items.line_item_options.sku_option"])||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:"line_items.line_item_options.sku_option"}),!isEmpty(order)&&(order==null?void 0:order.line_items)&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}}),()=>{isEmpty(order)&&dispatch({type:"setLineItems",payload:{lineItems:[]}})}),[order,include,includeLoaded]);const lineItemValue=Object.assign(Object.assign({},state),{loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})});return _jsx(LineItemContext.Provider,Object.assign({value:lineItemValue},{children:state.loading?loader:children}),void 0)};LineItemsContainer.propTypes=propTypes,LineItemsContainer.defaultProps=defaultProps,LineItemsContainer.displayName=displayName;export default LineItemsContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../reducers/LineItemReducer";import OrderContext from"../context/OrderContext";import LineItemContext from"../context/LineItemContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";const propTypes=components.LineItemsContainer.propTypes,defaultProps=components.LineItemsContainer.defaultProps,displayName=components.LineItemsContainer.displayName;export function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),useEffect(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue=Object.assign(Object.assign({},state),{loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})});return _jsx(LineItemContext.Provider,Object.assign({value:lineItemValue},{children:state.loading?loader:children}))}LineItemsContainer.propTypes=propTypes,LineItemsContainer.defaultProps=defaultProps,LineItemsContainer.displayName=displayName;export default LineItemsContainer;
@@ -1,12 +1,22 @@
1
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import { TypeAccepted } from '../utils/getLineItemsCount';
3
3
  import { FunctionChildren } from '../typings/index';
4
- declare type LineItemsCountChildrenProps = FunctionChildren<Omit<LineItemsCountProps, 'children'> & {
4
+ declare type LineItemsCountChildrenProps = FunctionChildren<Omit<Props, 'children'> & {
5
5
  quantity: number;
6
6
  }>;
7
- declare type LineItemsCountProps = {
7
+ declare type Props = {
8
8
  children?: LineItemsCountChildrenProps;
9
9
  typeAccepted?: TypeAccepted[];
10
10
  } & JSX.IntrinsicElements['span'];
11
- declare const LineItemsCount: FunctionComponent<LineItemsCountProps>;
11
+ export declare function LineItemsCount(props: Props): JSX.Element;
12
+ export declare namespace LineItemsCount {
13
+ var propTypes: {
14
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
15
+ id: import("prop-types").Requireable<string>;
16
+ className: import("prop-types").Requireable<string>;
17
+ name: import("prop-types").Requireable<string>;
18
+ style: import("prop-types").Requireable<object>;
19
+ };
20
+ var displayName: string;
21
+ }
12
22
  export default LineItemsCount;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import{isEmpty}from"lodash";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsCount.propTypes,displayName=components.LineItemsCount.displayName,LineItemsCount=props=>{const{children,typeAccepted}=props,p=__rest(props,["children","typeAccepted"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0);useEffect(()=>{if(!isEmpty(lineItems)){const qty=getLineItemsCount({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps=Object.assign({quantity,typeAccepted},p);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):_jsx("span",Object.assign({},p,{children:quantity}),void 0)};LineItemsCount.propTypes=propTypes,LineItemsCount.displayName=displayName;export default LineItemsCount;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsCount.propTypes,displayName=components.LineItemsCount.displayName;export function LineItemsCount(props){const{children,typeAccepted}=props,p=__rest(props,["children","typeAccepted"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0);useEffect(()=>{if(lineItems&&lineItems.length>0){const qty=getLineItemsCount({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps=Object.assign({quantity,typeAccepted},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},p,{children:quantity}))}LineItemsCount.propTypes=propTypes,LineItemsCount.displayName=displayName;export default LineItemsCount;
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import { FunctionChildren } from '../typings/index';
3
3
  export declare type LineItemsCountType = FunctionChildren<Omit<LineItemsCountProps, 'children'> & {
4
4
  quantity: number;
@@ -8,5 +8,16 @@ declare type LineItemsCountProps = {
8
8
  children?: LineItemsCountType;
9
9
  text?: string;
10
10
  } & JSX.IntrinsicElements['span'];
11
- declare const LineItemsEmpty: FunctionComponent<LineItemsCountProps>;
11
+ export declare function LineItemsEmpty(props: LineItemsCountProps): JSX.Element | null;
12
+ export declare namespace LineItemsEmpty {
13
+ var propTypes: {
14
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
15
+ id: import("prop-types").Requireable<string>;
16
+ className: import("prop-types").Requireable<string>;
17
+ name: import("prop-types").Requireable<string>;
18
+ style: import("prop-types").Requireable<object>;
19
+ text: import("prop-types").Requireable<string>;
20
+ };
21
+ var displayName: string;
22
+ }
12
23
  export default LineItemsEmpty;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import{isEmpty}from"lodash";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsEmpty.propTypes,displayName=components.LineItemsEmpty.displayName,LineItemsEmpty=props=>{const{children,text="Your shopping bag is empty"}=props,p=__rest(props,["children","text"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0),emptyText=quantity===0?_jsx("span",Object.assign({},p,{children:text}),void 0):null;useEffect(()=>{if(!isEmpty(lineItems)){const qty=getLineItemsCount({lineItems:lineItems||[]});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems]);const parentProps=Object.assign({quantity,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):emptyText};LineItemsEmpty.propTypes=propTypes,LineItemsEmpty.displayName=displayName;export default LineItemsEmpty;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsEmpty.propTypes,displayName=components.LineItemsEmpty.displayName;export function LineItemsEmpty(props){const{children,text="Your shopping bag is empty"}=props,p=__rest(props,["children","text"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(),emptyText=quantity===0?_jsx("span",Object.assign({},p,{children:text})):null;useEffect(()=>{if(lineItems)if(lineItems.length>0){const qty=getLineItemsCount({lineItems:lineItems||[]});setQuantity(qty)}else setQuantity(0);return()=>{setQuantity(void 0)}},[lineItems]);const parentProps=Object.assign({quantity,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):emptyText}LineItemsEmpty.propTypes=propTypes,LineItemsEmpty.displayName=displayName;export default LineItemsEmpty;
@@ -1,5 +1,15 @@
1
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import { BaseInputComponentProps } from '../typings/index';
3
- export declare type MetadataInputProps = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
4
- declare const MetadataInput: FunctionComponent<MetadataInputProps>;
3
+ declare type Props = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
4
+ export declare function MetadataInput(props: Props): JSX.Element;
5
+ export declare namespace MetadataInput {
6
+ var propTypes: {
7
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
8
+ name: import("prop-types").Validator<string>;
9
+ type: import("prop-types").Validator<import("../typings/index").BaseInputType>;
10
+ onChange: import("prop-types").Requireable<(...args: any[]) => any>;
11
+ placeholder: import("prop-types").Requireable<string>;
12
+ };
13
+ var displayName: string;
14
+ }
5
15
  export default MetadataInput;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";import components from"../config/components";const propTypes=components.MetadataInput.propTypes,displayName=components.MetadataInput.displayName,MetadataInput=props=>_jsx(BaseInput,Object.assign({"data-metadata":!0},props),void 0);MetadataInput.propTypes=propTypes,MetadataInput.displayName=displayName;export default MetadataInput;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";import components from"../config/components";const propTypes=components.MetadataInput.propTypes,displayName=components.MetadataInput.displayName;export function MetadataInput(props){return _jsx(BaseInput,Object.assign({"data-metadata":!0},props))}MetadataInput.propTypes=propTypes,MetadataInput.displayName=displayName;export default MetadataInput;
@@ -1,16 +1,16 @@
1
+ /// <reference types="react" />
1
2
  import { LoaderType } from '../typings/index';
2
- import { FunctionComponent } from 'react';
3
3
  import { PaymentSourceProps } from './PaymentSource';
4
- export declare type GatewayBaseType = PaymentGatewayProps & {
4
+ export declare type GatewayBaseType = Props & {
5
5
  show: boolean;
6
6
  loading: boolean;
7
7
  loaderComponent: JSX.Element;
8
8
  };
9
- export declare type PaymentGatewayProps = PaymentSourceProps & {
9
+ declare type Props = PaymentSourceProps & {
10
10
  showCard: boolean;
11
11
  handleEditClick: (e: MouseEvent) => void;
12
12
  show: boolean;
13
13
  loader?: LoaderType;
14
14
  };
15
- declare const PaymentGateway: FunctionComponent<PaymentGatewayProps>;
15
+ export declare function PaymentGateway({ readonly, showCard, handleEditClick, children, templateCustomerCards, templateCustomerSaveToWallet, onClickCustomerCards, show, loader, ...p }: Props): JSX.Element | null;
16
16
  export default PaymentGateway;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../context/OrderContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../context/PaymentMethodContext";import getPaypalConfig from"../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../utils/getLoaderComponent";import AdyenGateway from"./gateways/AdyenGateway";import StripeGateway from"./gateways/StripeGateway";import BraintreeGateway from"./gateways/BraintreeGateway";import PaypalGateway from"./gateways/PaypalGateway";import WireTransferGateway from"./gateways/WireTransferGateway";import CustomerContext from"../context/CustomerContext";const PaymentGateway=_a=>{var _b,{readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading..."}=_a,p=__rest(_a,["readonly","showCard","handleEditClick","children","templateCustomerCards","templateCustomerSaveToWallet","onClickCustomerCards","show","loader"]);const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource,currentPaymentMethodType,setPaymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment==null?void 0:payment.payment_source_type;useEffect(()=>{var _a2;if((payment==null?void 0:payment.id)===currentPaymentMethodId&&paymentResource&&((_a2=order==null?void 0:order.payment_method)===null||_a2===void 0?void 0:_a2.payment_source_type)===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{};(!paymentSource||paymentSource.type!==paymentResource)&&(setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()),setLoading(!1)}return()=>{setLoading(!0)}},[(_b=order==null?void 0:order.payment_method)===null||_b===void 0?void 0:_b.payment_source_type,show,paymentSource]);const gatewayConfig=Object.assign({readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet},p);switch(paymentResource){case"stripe_payments":return _jsx(StripeGateway,Object.assign({},gatewayConfig,{children}),void 0);case"adyen_payments":return _jsx(AdyenGateway,Object.assign({},gatewayConfig,{children}),void 0);case"braintree_payments":return _jsx(BraintreeGateway,Object.assign({},gatewayConfig,{children}),void 0);case"wire_transfers":return _jsx(WireTransferGateway,Object.assign({},gatewayConfig,{children}),void 0);case"paypal_payments":return _jsx(PaypalGateway,Object.assign({},gatewayConfig,{children}),void 0);default:return null}};export default PaymentGateway;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../context/OrderContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../context/PaymentMethodContext";import getPaypalConfig from"../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../utils/getLoaderComponent";import CustomerContext from"../context/CustomerContext";export function PaymentGateway(_a){var _b,{readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading..."}=_a,p=__rest(_a,["readonly","showCard","handleEditClick","children","templateCustomerCards","templateCustomerSaveToWallet","onClickCustomerCards","show","loader"]);const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{var _a2;if(payment?.id===currentPaymentMethodId&&paymentResource&&((_a2=order?.payment_method)===null||_a2===void 0?void 0:_a2.payment_source_type)===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{},setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[(_b=order?.payment_method)===null||_b===void 0?void 0:_b.id,show,paymentSource]);const gatewayConfig=Object.assign({readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet},p);switch(paymentResource){case"stripe_payments":return _jsx(StripeGateway,Object.assign({},gatewayConfig,{children}));case"klarna_payments":return _jsx(KlarnaGateway,Object.assign({},gatewayConfig,{children}));case"adyen_payments":return _jsx(AdyenGateway,Object.assign({},gatewayConfig,{children}));case"braintree_payments":return _jsx(BraintreeGateway,Object.assign({},gatewayConfig,{children}));case"wire_transfers":return _jsx(WireTransferGateway,Object.assign({},gatewayConfig,{children}));case"paypal_payments":return _jsx(PaypalGateway,Object.assign({},gatewayConfig,{children}));case"checkout_com_payments":return _jsx(CheckoutComGateway,Object.assign({},gatewayConfig,{children}));default:return null}}export default PaymentGateway;
@@ -1,7 +1,7 @@
1
- import { FunctionComponent, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { LoaderType } from '../typings/index';
3
3
  import { PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
4
- declare type PaymentMethodProps = {
4
+ declare type Props = {
5
5
  children: ReactNode;
6
6
  activeClass?: string;
7
7
  loader?: LoaderType;
@@ -12,5 +12,11 @@ declare type PaymentMethodProps = {
12
12
  clickableContainer?: never;
13
13
  onClick?: never;
14
14
  });
15
- declare const PaymentMethod: FunctionComponent<PaymentMethodProps>;
15
+ export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, onClick, ...p }: Props): JSX.Element;
16
+ export declare namespace PaymentMethod {
17
+ var propTypes: {
18
+ children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
19
+ };
20
+ var displayName: string;
21
+ }
16
22
  export default PaymentMethod;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import getLoaderComponent from"../utils/getLoaderComponent";const propTypes=components.PaymentMethod.propTypes,displayName=components.PaymentMethod.displayName,PaymentMethod=_a=>{var{children,className,activeClass,loader="Loading...",clickableContainer,onClick}=_a,p=__rest(_a,["children","className","activeClass","loader","clickableContainer","onClick"]);const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useContext(PaymentMethodContext);useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components2=paymentMethods&&paymentMethods.map((payment,k)=>{const isActive=currentPaymentMethodId===(payment==null?void 0:payment.id),paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentResource=payment==null?void 0:payment.payment_source_type,paymentMethodId=payment==null?void 0:payment.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",Object.assign({className:`${className} ${isActive?activeClass:""}`,onClick:onClickable},p,{children:_jsx(PaymentMethodChildrenContext.Provider,Object.assign({value:paymentMethodProps},{children}),void 0)}),k)});return loading?getLoaderComponent(loader):_jsx(Fragment,{children:components2},void 0)};PaymentMethod.propTypes=propTypes,PaymentMethod.displayName=displayName;export default PaymentMethod;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import getLoaderComponent from"../utils/getLoaderComponent";const propTypes=components.PaymentMethod.propTypes,displayName=components.PaymentMethod.displayName;export function PaymentMethod(_a){var{children,className,activeClass,loader="Loading...",clickableContainer,onClick}=_a,p=__rest(_a,["children","className","activeClass","loader","clickableContainer","onClick"]);const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useContext(PaymentMethodContext);useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components2=paymentMethods&&paymentMethods.map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",Object.assign({"data-test-id":paymentResource,className:`${className} ${isActive?activeClass:""}`,onClick:onClickable},p,{children:_jsx(PaymentMethodChildrenContext.Provider,Object.assign({value:paymentMethodProps},{children}))}),k)});return loading?getLoaderComponent(loader):_jsx(Fragment,{children:components2})}PaymentMethod.propTypes=propTypes,PaymentMethod.displayName=displayName;export default PaymentMethod;
@@ -1,4 +1,18 @@
1
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import { BaseAmountComponent } from '../typings/index';
3
- declare const PaymentMethodAmount: FunctionComponent<BaseAmountComponent>;
3
+ export declare function PaymentMethodAmount(props: BaseAmountComponent): JSX.Element;
4
+ export declare namespace PaymentMethodAmount {
5
+ var propTypes: {
6
+ id: import("prop-types").Requireable<string>;
7
+ className: import("prop-types").Requireable<string>;
8
+ style: import("prop-types").Requireable<object>;
9
+ name: import("prop-types").Requireable<string>;
10
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
11
+ format: import("prop-types").Requireable<import("../typings/index").BaseFormatPrice>;
12
+ };
13
+ var defaultProps: {
14
+ format: import("../typings/index").BaseFormatPrice;
15
+ };
16
+ var displayName: string;
17
+ }
4
18
  export default PaymentMethodAmount;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"./utils/BaseOrderPrice";import components from"../config/components";const propTypes=components.PaymentMethodAmount.propTypes,defaultProps=components.PaymentMethodAmount.defaultProps,displayName=components.PaymentMethodAmount.displayName,PaymentMethodAmount=props=>_jsx(BaseOrderPrice,Object.assign({base:"amount",type:"payment_method"},props),void 0);PaymentMethodAmount.propTypes=propTypes,PaymentMethodAmount.defaultProps=defaultProps,PaymentMethodAmount.displayName=displayName;export default PaymentMethodAmount;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"./utils/BaseOrderPrice";import components from"../config/components";const propTypes=components.PaymentMethodAmount.propTypes,defaultProps=components.PaymentMethodAmount.defaultProps,displayName=components.PaymentMethodAmount.displayName;export function PaymentMethodAmount(props){return _jsx(BaseOrderPrice,Object.assign({base:"amount",type:"payment_method"},props))}PaymentMethodAmount.propTypes=propTypes,PaymentMethodAmount.defaultProps=defaultProps,PaymentMethodAmount.displayName=displayName;export default PaymentMethodAmount;
@@ -1,9 +1,15 @@
1
- import { FunctionComponent, ReactNode } from 'react';
2
- declare type PaymentMethodNameChildrenProps = Omit<PaymentMethodNameProps, 'children'> & {
1
+ import { ReactNode } from 'react';
2
+ declare type PaymentMethodNameChildrenProps = Omit<Props, 'children'> & {
3
3
  labelName: string;
4
4
  };
5
- declare type PaymentMethodNameProps = {
5
+ declare type Props = {
6
6
  children?: (props: PaymentMethodNameChildrenProps) => ReactNode;
7
7
  } & JSX.IntrinsicElements['label'];
8
- declare const PaymentMethodName: FunctionComponent<PaymentMethodNameProps>;
8
+ export declare function PaymentMethodName(props: Props): JSX.Element;
9
+ export declare namespace PaymentMethodName {
10
+ var propTypes: {
11
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
12
+ };
13
+ var displayName: string;
14
+ }
9
15
  export default PaymentMethodName;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodName.propTypes,displayName=components.PaymentMethodName.displayName,PaymentMethodName=props=>{const{payment}=useContext(PaymentMethodChildrenContext),labelName=payment==null?void 0:payment.name,htmlFor=payment==null?void 0:payment.payment_source_type,parentProps=Object.assign({htmlFor,labelName},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children}),void 0):_jsx("label",Object.assign({htmlFor},props,{children:labelName}),void 0)};PaymentMethodName.propTypes=propTypes,PaymentMethodName.displayName=displayName;export default PaymentMethodName;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodName.propTypes,displayName=components.PaymentMethodName.displayName;export function PaymentMethodName(props){const{payment}=useContext(PaymentMethodChildrenContext),labelName=payment?.name,htmlFor=payment?.payment_source_type,parentProps=Object.assign({htmlFor,labelName},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("label",Object.assign({htmlFor},props,{children:labelName}))}PaymentMethodName.propTypes=propTypes,PaymentMethodName.displayName=displayName;export default PaymentMethodName;
@@ -1,9 +1,20 @@
1
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import { BaseAmountComponent } from '../typings/index';
3
3
  declare type Props = {
4
4
  type?: 'amount';
5
5
  labelFree?: string;
6
- };
7
- export declare type PaymentMethodPriceProps = BaseAmountComponent & Props;
8
- declare const PaymentMethodPrice: FunctionComponent<PaymentMethodPriceProps>;
6
+ } & BaseAmountComponent;
7
+ export declare function PaymentMethodPrice(props: Props): JSX.Element;
8
+ export declare namespace PaymentMethodPrice {
9
+ var propTypes: {
10
+ type: import("prop-types").Requireable<"amount">;
11
+ id: import("prop-types").Requireable<string>;
12
+ className: import("prop-types").Requireable<string>;
13
+ style: import("prop-types").Requireable<object>;
14
+ name: import("prop-types").Requireable<string>;
15
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
16
+ format: import("prop-types").Requireable<import("../typings/index").BaseFormatPrice>;
17
+ };
18
+ var displayName: string;
19
+ }
9
20
  export default PaymentMethodPrice;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../utils/getAmount";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodPrice.propTypes,displayName=components.PaymentMethodPrice.displayName,PaymentMethodPrice=props=>{const{format="formatted",type="amount",labelFree="Free"}=props,p=__rest(props,["format","type","labelFree"]),{payment}=useContext(PaymentMethodChildrenContext),[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=Object.assign({labelFree,price,priceCents},p);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children}),void 0):_jsx("span",Object.assign({},p,{children:priceCents===0?labelFree:price}),void 0)};PaymentMethodPrice.propTypes=propTypes,PaymentMethodPrice.displayName=displayName;export default PaymentMethodPrice;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../utils/getAmount";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodPrice.propTypes,displayName=components.PaymentMethodPrice.displayName;export function PaymentMethodPrice(props){const{format="formatted",type="amount",labelFree="Free"}=props,p=__rest(props,["format","type","labelFree"]),{payment}=useContext(PaymentMethodChildrenContext),[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=Object.assign({labelFree,price,priceCents},p);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("span",Object.assign({},p,{children:priceCents===0?labelFree:price}))}PaymentMethodPrice.propTypes=propTypes,PaymentMethodPrice.displayName=displayName;export default PaymentMethodPrice;
@@ -1,11 +1,18 @@
1
- import { FunctionComponent, ReactNode } from 'react';
1
+ import { ReactNode, ChangeEvent } from 'react';
2
2
  import { PaymentMethod } from '@commercelayer/sdk';
3
- declare type ShippingMethodRadioButtonChildrenProps = Omit<ShippingMethodRadioButtonProps, 'children'> & {
3
+ declare type ShippingMethodRadioButtonChildrenProps = Omit<Props, 'children'> & {
4
4
  checked: boolean;
5
+ handleOnChange: (event: ChangeEvent<HTMLInputElement>) => Promise<void>;
5
6
  };
6
- declare type ShippingMethodRadioButtonProps = {
7
+ declare type Props = {
7
8
  children?: (props: ShippingMethodRadioButtonChildrenProps) => ReactNode;
8
9
  onChange?: (payment?: PaymentMethod | Record<string, any>) => void;
9
10
  } & JSX.IntrinsicElements['input'];
10
- declare const PaymentMethodRadioButton: FunctionComponent<ShippingMethodRadioButtonProps>;
11
+ export declare function PaymentMethodRadioButton(props: Props): JSX.Element;
12
+ export declare namespace PaymentMethodRadioButton {
13
+ var propTypes: {
14
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
15
+ };
16
+ var displayName: string;
17
+ }
11
18
  export default PaymentMethodRadioButton;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentMethodRadioButton.propTypes,displayName=components.PaymentMethodRadioButton.displayName,PaymentMethodRadioButton=props=>{const{onChange}=props,p=__rest(props,["onChange"]),{payment,paymentSelected,setPaymentSelected,clickableContainer}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{setPaymentMethod,setLoading}=useContext(PaymentMethodContext),orderId=(order==null?void 0:order.id)||"",paymentResource=payment==null?void 0:payment.payment_source_type,paymentMethodId=payment==null?void 0:payment.id,name=`payment-${orderId}`,checked=paymentSelected===(payment==null?void 0:payment.id),handleOnChange=async e=>{e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer&&await setPaymentMethod({paymentResource,paymentMethodId}),onChange&&onChange(payment),setLoading({loading:!1})},id=payment==null?void 0:payment.payment_source_type,parentProps=Object.assign({handleOnChange,checked,id,name},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children}),void 0):_jsx("input",Object.assign({type:"radio",id,onChange:handleOnChange,checked},p),void 0)};PaymentMethodRadioButton.propTypes=propTypes,PaymentMethodRadioButton.displayName=displayName;export default PaymentMethodRadioButton;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentMethodRadioButton.propTypes,displayName=components.PaymentMethodRadioButton.displayName;export function PaymentMethodRadioButton(props){const{onChange}=props,p=__rest(props,["onChange"]),{payment,paymentSelected,setPaymentSelected,clickableContainer}=useContext(PaymentMethodChildrenContext),{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=>{e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer&&await setPaymentMethod({paymentResource,paymentMethodId}),onChange&&onChange(payment),setLoading({loading:!1})},id=payment?.payment_source_type,parentProps=Object.assign({handleOnChange,checked,id,name},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("input",Object.assign({title:name,type:"radio",id,onChange:handleOnChange,checked},p))}PaymentMethodRadioButton.propTypes=propTypes,PaymentMethodRadioButton.displayName=displayName;export default PaymentMethodRadioButton;
@@ -1,8 +1,14 @@
1
- import { FunctionComponent, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { PaymentMethodConfig } from '../reducers/PaymentMethodReducer';
3
- declare type PaymentMethodsContainerProps = {
3
+ declare type Props = {
4
4
  children: ReactNode;
5
5
  config?: PaymentMethodConfig;
6
6
  };
7
- declare const PaymentMethodsContainer: FunctionComponent<PaymentMethodsContainerProps>;
7
+ export declare function PaymentMethodsContainer(props: Props): JSX.Element;
8
+ export declare namespace PaymentMethodsContainer {
9
+ var propTypes: {
10
+ children: import("prop-types").Validator<boolean | import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal | (() => ReactNode)>;
11
+ };
12
+ var displayName: string;
13
+ }
8
14
  export default PaymentMethodsContainer;
@@ -1 +1 @@
1
- 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}from"../reducers/PaymentMethodReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";import{setPaymentRef}from"../reducers/PaymentMethodReducer";const propTypes=components.PaymentMethodsContainer.propTypes,displayName=components.PaymentMethodsContainer.displayName,PaymentMethodsContainer=props=>{const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useContext(OrderContext),credentials=useContext(CommerceLayerContext);useEffect(()=>{(include==null?void 0:include.includes("available_payment_methods"))?(includeLoaded==null?void 0:includeLoaded.available_payment_methods)||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPaymentMethods({order,dispatch}),credentials&&(order==null?void 0:order.payment_source)&&dispatch({type:"setPaymentSource",payload:{paymentSource:order==null?void 0:order.payment_source}})},[order,credentials,include,includeLoaded]);const contextValue=useMemo(()=>Object.assign(Object.assign({},state),{setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod(Object.assign(Object.assign({},args),{config:credentials,updateOrder,order,dispatch,setOrderErrors})),setPaymentSource:async args=>defaultPaymentMethodContext.setPaymentSource(Object.assign(Object.assign(Object.assign({},state),args),{config:credentials,dispatch,getOrder,updateOrder,order})),updatePaymentSource:async args=>defaultPaymentMethodContext.updatePaymentSource(Object.assign(Object.assign({},args),{config:credentials,dispatch})),destroyPaymentSource:async args=>defaultPaymentMethodContext.destroyPaymentSource(Object.assign(Object.assign({},args),{dispatch,config:credentials}))}),[state]);return _jsx(PaymentMethodContext.Provider,Object.assign({value:contextValue},{children}),void 0)};PaymentMethodsContainer.propTypes=propTypes,PaymentMethodsContainer.displayName=displayName;export default PaymentMethodsContainer;
1
+ 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}from"../reducers/PaymentMethodReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";import{setPaymentRef}from"../reducers/PaymentMethodReducer";const propTypes=components.PaymentMethodsContainer.propTypes,displayName=components.PaymentMethodsContainer.displayName;export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useContext(OrderContext),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,includeLoaded]);const contextValue=useMemo(()=>Object.assign(Object.assign({},state),{setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod(Object.assign(Object.assign({},args),{config:credentials,updateOrder,order,dispatch,setOrderErrors})),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource(Object.assign(Object.assign(Object.assign({},state),args),{config:credentials,dispatch,getOrder,updateOrder,order})),updatePaymentSource:async args=>await defaultPaymentMethodContext.updatePaymentSource(Object.assign(Object.assign({},args),{config:credentials,dispatch})),destroyPaymentSource:async args=>await defaultPaymentMethodContext.destroyPaymentSource(Object.assign(Object.assign({},args),{dispatch,config:credentials,updateOrder,orderId:order?.id}))}),[state]);return _jsx(PaymentMethodContext.Provider,Object.assign({value:contextValue},{children}))}PaymentMethodsContainer.propTypes=propTypes,PaymentMethodsContainer.displayName=displayName;export default PaymentMethodsContainer;
@@ -1,4 +1,4 @@
1
- import { FunctionComponent, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { LoaderType } from '../typings/index';
3
3
  import { CustomerCardsTemplateChildren } from './utils/PaymentCardsTemplate';
4
4
  export declare type CustomerCardsProps = {
@@ -15,5 +15,12 @@ export declare type PaymentSourceProps = {
15
15
  templateCustomerSaveToWallet?: (props: CustomerSaveToWalletProps) => ReactNode;
16
16
  loader?: LoaderType;
17
17
  } & JSX.IntrinsicElements['div'];
18
- declare const PaymentSource: FunctionComponent<PaymentSourceProps>;
18
+ export declare function PaymentSource(props: PaymentSourceProps): JSX.Element;
19
+ export declare namespace PaymentSource {
20
+ var propTypes: {
21
+ children: import("prop-types").Requireable<ReactNode | (() => ReactNode)>;
22
+ readonly: import("prop-types").Requireable<boolean>;
23
+ };
24
+ var displayName: string;
25
+ }
19
26
  export default PaymentSource;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import isEmpty from"lodash/isEmpty";import CustomerContext from"../context/CustomerContext";import PaymentGateway from"./PaymentGateway";const propTypes=components.PaymentSource.propTypes,displayName=components.PaymentSource.displayName,PaymentSource=props=>{const{readonly}=props,{payment}=useContext(PaymentMethodChildrenContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>{var _a,_b,_c,_d,_e,_f,_g,_h;if(readonly)setShow(!0),setShowCard(!0);else if((payment==null?void 0:payment.id)===currentPaymentMethodId){setShow(!0);const card=((_a=paymentSource==null?void 0:paymentSource.options)===null||_a===void 0?void 0:_a.card)||((_b=paymentSource==null?void 0:paymentSource.payment_method)===null||_b===void 0?void 0:_b.card)||((_c=paymentSource==null?void 0:paymentSource.metadata)===null||_c===void 0?void 0:_c.card)||((_e=(_d=paymentSource==null?void 0:paymentSource.paymentRequestData)===null||_d===void 0?void 0:_d.paymentMethod)===null||_e===void 0?void 0:_e.brand)&&((_f=paymentSource==null?void 0:paymentSource.paymentResponse)===null||_f===void 0?void 0:_f.resultCode)==="Authorised"&&{brand:(_h=(_g=paymentSource==null?void 0:paymentSource.paymentRequestData)===null||_g===void 0?void 0:_g.paymentMethod)===null||_h===void 0?void 0:_h.brand};isEmpty(card)||setShowCard(!0)}else setShow(!1);return()=>{setShow(!1),setShowCard(!1)}},[currentPaymentMethodId,paymentSource,payments,payment,readonly]);const handleEditClick=e=>{e.stopPropagation(),paymentSource&&destroyPaymentSource({paymentSourceId:paymentSource==null?void 0:paymentSource.id,paymentResource:payment==null?void 0:payment.payment_source_type}),setShowCard(!showCard),setShow(!0)},gatewayProps=Object.assign(Object.assign({},props),{show,showCard,handleEditClick,readonly});return _jsx(PaymentGateway,Object.assign({},gatewayProps),void 0)};PaymentSource.propTypes=propTypes,PaymentSource.displayName=displayName;export default PaymentSource;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import CustomerContext from"../context/CustomerContext";import PaymentGateway from"./PaymentGateway";import getCardDetails from"../utils/getCardDetails";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentSource.propTypes,displayName=components.PaymentSource.displayName;export function PaymentSource(props){const{readonly}=props,{payment}=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(!1),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const handleEditClick=async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},gatewayProps=Object.assign(Object.assign({},props),{show,showCard,handleEditClick,readonly});return _jsx(PaymentGateway,Object.assign({},gatewayProps))}PaymentSource.propTypes=propTypes,PaymentSource.displayName=displayName;export default PaymentSource;
@@ -1,8 +1,8 @@
1
- import { iconBrand } from '../context/PaymentSourceContext';
2
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
+ import { IconBrand } from '../context/PaymentSourceContext';
3
3
  import { FunctionChildren } from '../typings/index';
4
4
  declare type CustomComponent = FunctionChildren<Omit<Props & {
5
- brand: iconBrand;
5
+ brand: IconBrand;
6
6
  defaultSrc: string;
7
7
  url: string;
8
8
  }, 'children'>>;
@@ -11,5 +11,15 @@ declare type Props = {
11
11
  width?: number;
12
12
  height?: number;
13
13
  } & JSX.IntrinsicElements['img'];
14
- declare const PaymentSourceBrandIcon: FunctionComponent<Props>;
14
+ export declare function PaymentSourceBrandIcon({ src, width, children, ...p }: Props): JSX.Element;
15
+ export declare namespace PaymentSourceBrandIcon {
16
+ var propTypes: {
17
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
18
+ width: import("prop-types").Requireable<number>;
19
+ height: import("prop-types").Requireable<number>;
20
+ src: import("prop-types").Requireable<string>;
21
+ className: import("prop-types").Requireable<string>;
22
+ };
23
+ var displayName: string;
24
+ }
15
25
  export default PaymentSourceBrandIcon;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandIcon.propTypes,displayName=components.PaymentSourceBrandIcon.displayName,PaymentSourceBrandIcon=_a=>{var{src,width=32,children}=_a,p=__rest(_a,["src","width","children"]);const{brand}=useContext(PaymentSourceContext),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/${brand}.svg`,handleError=()=>{ref.current&&(ref.current.src=defaultSrc)},parentProps=Object.assign({brand,defaultSrc,url,width},p);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):_jsx("img",Object.assign({ref,src:url,onError:handleError,width},p),void 0)};PaymentSourceBrandIcon.propTypes=propTypes,PaymentSourceBrandIcon.displayName=displayName;export default PaymentSourceBrandIcon;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandIcon.propTypes,displayName=components.PaymentSourceBrandIcon.displayName;export function PaymentSourceBrandIcon(_a){var{src,width=32,children}=_a,p=__rest(_a,["src","width","children"]);const{brand}=useContext(PaymentSourceContext),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/${brand}.svg`,handleError=()=>{ref.current&&(ref.current.src=defaultSrc)},parentProps=Object.assign({brand,defaultSrc,url,width},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("img",Object.assign({ref,src:url,onError:handleError,width},p))}PaymentSourceBrandIcon.propTypes=propTypes,PaymentSourceBrandIcon.displayName=displayName;export default PaymentSourceBrandIcon;
@@ -1,12 +1,19 @@
1
- import { iconBrand } from '../context/PaymentSourceContext';
2
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
+ import { IconBrand } from '../context/PaymentSourceContext';
3
3
  import { FunctionChildren } from '../typings/index';
4
4
  declare type CustomComponent = FunctionChildren<Omit<Props & {
5
- brand: iconBrand;
5
+ brand: IconBrand;
6
6
  }, 'children'>>;
7
7
  declare type Props = {
8
8
  children?: CustomComponent;
9
9
  label?: string;
10
10
  } & JSX.IntrinsicElements['span'];
11
- declare const PaymentSourceBrandName: FunctionComponent<Props>;
11
+ export declare function PaymentSourceBrandName({ children, label, ...props }: Props): JSX.Element;
12
+ export declare namespace PaymentSourceBrandName {
13
+ var propTypes: {
14
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
15
+ label: import("prop-types").Requireable<string>;
16
+ };
17
+ var displayName: string;
18
+ }
12
19
  export default PaymentSourceBrandName;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{capitalize}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandName.propTypes,displayName=components.PaymentSourceBrandName.displayName,PaymentSourceBrandName=_a=>{var{children,label}=_a,props=__rest(_a,["children","label"]);const{brand}=useContext(PaymentSourceContext),brandName=brand&&capitalize(brand.replace("-"," ")),parentProps=Object.assign({brand:brandName,label},props);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):_jsx("span",Object.assign({},props,{children:label||capitalize(brandName)}),void 0)};PaymentSourceBrandName.propTypes=propTypes,PaymentSourceBrandName.displayName=displayName;export default PaymentSourceBrandName;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{capitalize}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandName.propTypes,displayName=components.PaymentSourceBrandName.displayName;export function PaymentSourceBrandName(_a){var{children,label}=_a,props=__rest(_a,["children","label"]);const{brand}=useContext(PaymentSourceContext),brandName=brand&&capitalize(brand.replace("-"," ")),parentProps=Object.assign({brand:brandName,label},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},props,{children:label||capitalize(brandName)}))}PaymentSourceBrandName.propTypes=propTypes,PaymentSourceBrandName.displayName=displayName;export default PaymentSourceBrandName;
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import { FunctionChildren } from '../typings/index';
3
3
  export declare type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
4
4
  declare type CustomComponent = FunctionChildren<Omit<Props & {
@@ -8,5 +8,11 @@ declare type Props = {
8
8
  children?: CustomComponent;
9
9
  type: PaymentSourceDetailType;
10
10
  } & JSX.IntrinsicElements['span'];
11
- declare const PaymentSourceDetail: FunctionComponent<Props>;
11
+ export declare function PaymentSourceDetail({ type, children, ...p }: Props): JSX.Element;
12
+ export declare namespace PaymentSourceDetail {
13
+ var propTypes: {
14
+ type: import("prop-types").Validator<PaymentSourceDetailType>;
15
+ };
16
+ var displayName: string;
17
+ }
12
18
  export default PaymentSourceDetail;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import PaymentSourceContext from"../context/PaymentSourceContext";import{has}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";const propTypes=components.PaymentSourceDetail.propTypes,displayName=components.PaymentSourceDetail.displayName,PaymentSourceDetail=_a=>{var{type,children}=_a,p=__rest(_a,["type","children"]);const card=useContext(PaymentSourceContext),text=has(card,type)?card[type]:type==="last4"?"****":"**",parentProps=Object.assign({type,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):_jsx("span",Object.assign({},p,{children:text}),void 0)};PaymentSourceDetail.propTypes=propTypes,PaymentSourceDetail.displayName=displayName;export default PaymentSourceDetail;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import PaymentSourceContext from"../context/PaymentSourceContext";import{has}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";const propTypes=components.PaymentSourceDetail.propTypes,displayName=components.PaymentSourceDetail.displayName;export function PaymentSourceDetail(_a){var{type,children}=_a,p=__rest(_a,["type","children"]);const card=useContext(PaymentSourceContext),text=has(card,type)?card[type]:type==="last4"?"****":"**",parentProps=Object.assign({type,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},p,{children:text}))}PaymentSourceDetail.propTypes=propTypes,PaymentSourceDetail.displayName=displayName;export default PaymentSourceDetail;
@@ -1,9 +1,16 @@
1
- import { FunctionComponent, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { FunctionChildren } from '../typings/index';
3
3
  declare type CustomComponent = FunctionChildren<Omit<Props, 'children'>>;
4
4
  declare type Props = {
5
5
  children?: CustomComponent;
6
6
  label?: string | ReactNode;
7
7
  } & Omit<JSX.IntrinsicElements['button'], 'onClick'>;
8
- declare const PaymentSourceEditButton: FunctionComponent<Props>;
8
+ export declare function PaymentSourceEditButton({ children, label, ...props }: Props): JSX.Element | null;
9
+ export declare namespace PaymentSourceEditButton {
10
+ var propTypes: {
11
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
12
+ label: import("prop-types").Requireable<string | import("prop-types").ReactElementLike>;
13
+ };
14
+ var displayName: string;
15
+ }
9
16
  export default PaymentSourceEditButton;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const displayName=components.PaymentSourceEditButton.displayName,propTypes=components.PaymentSourceEditButton.propTypes,PaymentSourceEditButton=_a=>{var{children,label="Edit"}=_a,props=__rest(_a,["children","label"]);const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps=Object.assign({showCard,label,handleEditClick},props);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):readonly?null:_jsx("button",Object.assign({},props,{onClick:handleEditClick},{children:label}),void 0)};PaymentSourceEditButton.propTypes=propTypes,PaymentSourceEditButton.displayName=displayName;export default PaymentSourceEditButton;
1
+ import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const displayName=components.PaymentSourceEditButton.displayName,propTypes=components.PaymentSourceEditButton.propTypes;export function PaymentSourceEditButton(_a){var{children,label="Edit"}=_a,props=__rest(_a,["children","label"]);const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps=Object.assign({showCard,label,handleEditClick},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):readonly?null:_jsx("button",Object.assign({},props,{onClick:handleEditClick},{children:label}))}PaymentSourceEditButton.propTypes=propTypes,PaymentSourceEditButton.displayName=displayName;export default PaymentSourceEditButton;
@@ -1,4 +1,4 @@
1
- import { FunctionComponent, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  export declare type PaypalConfig = {
3
3
  return_url: string;
4
4
  cancel_url: string;
@@ -8,5 +8,5 @@ export declare type PaypalConfig = {
8
8
  };
9
9
  };
10
10
  declare type Props = Omit<PaypalConfig, 'return_url' | 'cancel_url'> & JSX.IntrinsicElements['div'];
11
- declare const PaypalPayment: FunctionComponent<Props>;
11
+ export declare function PaypalPayment({ infoMessage, ...p }: Props): JSX.Element;
12
12
  export default PaypalPayment;
@@ -1 +1 @@
1
- import{__rest}from"tslib";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",PaypalPayment=_a=>{var{infoMessage}=_a,p=__rest(_a,["infoMessage"]);const ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&(paymentSource==null?void 0:paymentSource.approval_url)&&(ref.current.onsubmit=()=>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",Object.assign({ref},{children:_jsx("div",Object.assign({},p,{children:_jsx("span",Object.assign({className:infoMessage==null?void 0:infoMessage.className},{children:isFunction(infoMessage==null?void 0:infoMessage.text)?infoMessage==null?void 0:infoMessage.text():(infoMessage==null?void 0:infoMessage.text)||defaultMessage}),void 0)}),void 0)}),void 0)};export default PaypalPayment;
1
+ import{__rest}from"tslib";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(_a){var{infoMessage}=_a,p=__rest(_a,["infoMessage"]);const ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&paymentSource?.approval_url&&(ref.current.onsubmit=()=>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",Object.assign({ref},{children:_jsx("div",Object.assign({},p,{children:_jsx("span",Object.assign({className:infoMessage?.className},{children:isFunction(infoMessage?.text)?infoMessage?.text():infoMessage?.text||defaultMessage}))}))}))}export default PaypalPayment;
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from 'react';
1
+ /// <reference types="react" />
2
2
  import { Price as PriceType } from '@commercelayer/sdk';
3
3
  import { FunctionChildren, LoaderType } from '../typings/index';
4
4
  declare type PriceChildrenProps = FunctionChildren<{
@@ -6,11 +6,23 @@ declare type PriceChildrenProps = FunctionChildren<{
6
6
  loader: LoaderType;
7
7
  prices: PriceType[];
8
8
  } & Omit<PriceProps, 'children'>>;
9
- export interface PriceProps extends Partial<JSX.IntrinsicElements['span']> {
9
+ export declare type PriceProps = Partial<JSX.IntrinsicElements['span']> & {
10
10
  children?: PriceChildrenProps;
11
11
  compareClassName?: string;
12
12
  showCompare?: boolean;
13
13
  skuCode?: string;
14
+ };
15
+ export declare function Price(props: PriceProps): JSX.Element;
16
+ export declare namespace Price {
17
+ var propTypes: {
18
+ children: import("prop-types").Requireable<(...args: any[]) => any>;
19
+ compareClassName: import("prop-types").Requireable<string>;
20
+ skuCode: import("prop-types").Requireable<string>;
21
+ showCompare: import("prop-types").Requireable<boolean>;
22
+ };
23
+ var defaultProps: {
24
+ skuCode: string;
25
+ };
26
+ var displayName: string;
14
27
  }
15
- declare const Price: FunctionComponent<PriceProps>;
16
28
  export default Price;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useState,useEffect,useContext}from"react";import{isEmpty,has,indexOf}from"lodash";import Parent from"./utils/Parent";import PricesContext from"../context/PricesContext";import{getPricesComponent}from"../utils/getPrices";import components from"../config/components";const propTypes=components.Price.propTypes,defaultProps=components.Price.defaultProps,displayName=components.Price.displayName,Price=props=>{const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=useContext(PricesContext),[skuPrices,setSkuPrices]=useState([]),sCode=pricesSkuCode||skuCode;useEffect(()=>(!isEmpty(prices)&&has(prices,`${sCode}`)?setSkuPrices(prices[sCode]):sCode&&indexOf(skuCodes,sCode)===-1&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes(skuCodes)),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps=Object.assign({loading,loader,prices:skuPrices},props),pricesComponent=isEmpty(prices)||isEmpty(skuPrices)?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,Object.assign({},parentProps,{children}),void 0):_jsx(Fragment,{children:loading||isEmpty(pricesComponent)?loader:pricesComponent},void 0)};Price.propTypes=propTypes,Price.defaultProps=defaultProps,Price.displayName=displayName;export default Price;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useState,useEffect,useContext}from"react";import{isEmpty,has,indexOf}from"lodash";import Parent from"./utils/Parent";import PricesContext from"../context/PricesContext";import{getPricesComponent}from"../utils/getPrices";import components from"../config/components";import SkuChildrenContext from"../context/SkuChildrenContext";const propTypes=components.Price.propTypes,defaultProps=components.Price.defaultProps,displayName=components.Price.displayName;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(()=>(!isEmpty(prices)&&has(prices,`${sCode}`)?setSkuPrices(prices[sCode]):sCode&&indexOf(skuCodes,sCode)===-1&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes(skuCodes)),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps=Object.assign({loading,loader,prices:skuPrices},props),pricesComponent=isEmpty(prices)||isEmpty(skuPrices)?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx(Fragment,{children:loading||isEmpty(pricesComponent)?loader:pricesComponent})}Price.propTypes=propTypes,Price.defaultProps=defaultProps,Price.displayName=displayName;export default Price;