@commercelayer/react-components 2.53.2 → 3.0.0-alpha.2

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 (807) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +3 -3
  3. package/lib/cjs/components/AdjustmentAmount.js +1 -1
  4. package/lib/cjs/components/AdyenPayment.d.ts +3 -3
  5. package/lib/cjs/components/AdyenPayment.js +1 -1
  6. package/lib/cjs/components/AvailabilityContainer.d.ts +10 -3
  7. package/lib/cjs/components/AvailabilityContainer.js +1 -1
  8. package/lib/cjs/components/AvailabilityTemplate.d.ts +13 -4
  9. package/lib/cjs/components/AvailabilityTemplate.js +1 -1
  10. package/lib/cjs/components/BillingAddressContainer.d.ts +7 -2
  11. package/lib/cjs/components/BillingAddressContainer.js +1 -1
  12. package/lib/cjs/components/BillingAddressForm.d.ts +8 -3
  13. package/lib/cjs/components/BillingAddressForm.js +1 -1
  14. package/lib/cjs/components/BraintreePayment.d.ts +3 -3
  15. package/lib/cjs/components/BraintreePayment.js +1 -1
  16. package/lib/cjs/components/CartLink.d.ts +12 -0
  17. package/lib/cjs/components/CartLink.js +1 -0
  18. package/lib/cjs/components/CheckoutComPayment.d.ts +23 -0
  19. package/lib/cjs/components/CheckoutComPayment.js +1 -0
  20. package/lib/cjs/components/CheckoutLink.d.ts +16 -4
  21. package/lib/cjs/components/CheckoutLink.js +1 -1
  22. package/lib/cjs/components/DeliveryLeadTime.d.ts +11 -4
  23. package/lib/cjs/components/DeliveryLeadTime.js +1 -1
  24. package/lib/cjs/components/DiscountAmount.d.ts +16 -2
  25. package/lib/cjs/components/DiscountAmount.js +1 -1
  26. package/lib/cjs/components/Errors.d.ts +4 -4
  27. package/lib/cjs/components/Errors.js +1 -1
  28. package/lib/cjs/components/ExternalFunction.d.ts +9 -2
  29. package/lib/cjs/components/ExternalFunction.js +1 -1
  30. package/lib/cjs/components/GiftCard.d.ts +13 -3
  31. package/lib/cjs/components/GiftCard.js +1 -1
  32. package/lib/cjs/components/GiftCardContainer.d.ts +9 -3
  33. package/lib/cjs/components/GiftCardContainer.js +1 -1
  34. package/lib/cjs/components/GiftCardCurrencySelector.d.ts +18 -3
  35. package/lib/cjs/components/GiftCardCurrencySelector.js +1 -1
  36. package/lib/cjs/components/GiftCardInput.d.ts +12 -3
  37. package/lib/cjs/components/GiftCardInput.js +1 -1
  38. package/lib/cjs/components/GiftCardOrCouponCode.d.ts +17 -6
  39. package/lib/cjs/components/GiftCardOrCouponCode.js +1 -1
  40. package/lib/cjs/components/GiftCardOrCouponForm.d.ts +9 -4
  41. package/lib/cjs/components/GiftCardOrCouponForm.js +1 -1
  42. package/lib/cjs/components/GiftCardOrCouponInput.d.ts +14 -3
  43. package/lib/cjs/components/GiftCardOrCouponInput.js +1 -1
  44. package/lib/cjs/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
  45. package/lib/cjs/components/GiftCardOrCouponRemoveButton.js +1 -1
  46. package/lib/cjs/components/GiftCardOrCouponSubmit.d.ts +11 -4
  47. package/lib/cjs/components/GiftCardOrCouponSubmit.js +1 -1
  48. package/lib/cjs/components/ItemContainer.d.ts +14 -3
  49. package/lib/cjs/components/ItemContainer.js +1 -1
  50. package/lib/cjs/components/KlarnaPayment.d.ts +10 -0
  51. package/lib/cjs/components/KlarnaPayment.js +1 -0
  52. package/lib/cjs/components/LineItem.d.ts +10 -3
  53. package/lib/cjs/components/LineItem.js +1 -1
  54. package/lib/cjs/components/LineItemAmount.d.ts +16 -3
  55. package/lib/cjs/components/LineItemAmount.js +1 -1
  56. package/lib/cjs/components/LineItemCode.d.ts +10 -4
  57. package/lib/cjs/components/LineItemCode.js +1 -1
  58. package/lib/cjs/components/LineItemImage.d.ts +11 -4
  59. package/lib/cjs/components/LineItemImage.js +1 -1
  60. package/lib/cjs/components/LineItemName.d.ts +11 -5
  61. package/lib/cjs/components/LineItemName.js +1 -1
  62. package/lib/cjs/components/LineItemOption.d.ts +15 -4
  63. package/lib/cjs/components/LineItemOption.js +1 -1
  64. package/lib/cjs/components/LineItemOptions.d.ts +8 -3
  65. package/lib/cjs/components/LineItemOptions.js +1 -1
  66. package/lib/cjs/components/LineItemQuantity.d.ts +16 -4
  67. package/lib/cjs/components/LineItemQuantity.js +1 -1
  68. package/lib/cjs/components/LineItemRemoveLink.d.ts +15 -5
  69. package/lib/cjs/components/LineItemRemoveLink.js +1 -1
  70. package/lib/cjs/components/LineItemsContainer.d.ts +15 -3
  71. package/lib/cjs/components/LineItemsContainer.js +1 -1
  72. package/lib/cjs/components/LineItemsCount.d.ts +14 -4
  73. package/lib/cjs/components/LineItemsCount.js +1 -1
  74. package/lib/cjs/components/LineItemsEmpty.d.ts +13 -2
  75. package/lib/cjs/components/LineItemsEmpty.js +1 -1
  76. package/lib/cjs/components/MetadataInput.d.ts +13 -3
  77. package/lib/cjs/components/MetadataInput.js +1 -1
  78. package/lib/cjs/components/PaymentGateway.d.ts +4 -4
  79. package/lib/cjs/components/PaymentGateway.js +1 -1
  80. package/lib/cjs/components/PaymentMethod.d.ts +9 -3
  81. package/lib/cjs/components/PaymentMethod.js +1 -1
  82. package/lib/cjs/components/PaymentMethodAmount.d.ts +16 -2
  83. package/lib/cjs/components/PaymentMethodAmount.js +1 -1
  84. package/lib/cjs/components/PaymentMethodName.d.ts +10 -4
  85. package/lib/cjs/components/PaymentMethodName.js +1 -1
  86. package/lib/cjs/components/PaymentMethodPrice.d.ts +15 -4
  87. package/lib/cjs/components/PaymentMethodPrice.js +1 -1
  88. package/lib/cjs/components/PaymentMethodRadioButton.d.ts +11 -4
  89. package/lib/cjs/components/PaymentMethodRadioButton.js +1 -1
  90. package/lib/cjs/components/PaymentMethodsContainer.d.ts +9 -3
  91. package/lib/cjs/components/PaymentMethodsContainer.js +1 -1
  92. package/lib/cjs/components/PaymentSource.d.ts +9 -2
  93. package/lib/cjs/components/PaymentSource.js +1 -1
  94. package/lib/cjs/components/PaymentSourceBrandIcon.d.ts +14 -4
  95. package/lib/cjs/components/PaymentSourceBrandIcon.js +1 -1
  96. package/lib/cjs/components/PaymentSourceBrandName.d.ts +11 -4
  97. package/lib/cjs/components/PaymentSourceBrandName.js +1 -1
  98. package/lib/cjs/components/PaymentSourceDetail.d.ts +8 -2
  99. package/lib/cjs/components/PaymentSourceDetail.js +1 -1
  100. package/lib/cjs/components/PaymentSourceEditButton.d.ts +9 -2
  101. package/lib/cjs/components/PaymentSourceEditButton.js +1 -1
  102. package/lib/cjs/components/PaypalPayment.d.ts +2 -2
  103. package/lib/cjs/components/PaypalPayment.js +1 -1
  104. package/lib/cjs/components/Price.d.ts +15 -3
  105. package/lib/cjs/components/Price.js +1 -1
  106. package/lib/cjs/components/PricesContainer.d.ts +19 -3
  107. package/lib/cjs/components/PricesContainer.js +1 -1
  108. package/lib/cjs/components/QuantitySelector.d.ts +19 -5
  109. package/lib/cjs/components/QuantitySelector.js +1 -1
  110. package/lib/cjs/components/SaveAddressesButton.d.ts +18 -5
  111. package/lib/cjs/components/SaveAddressesButton.js +1 -1
  112. package/lib/cjs/components/SaveCustomerButton.d.ts +16 -5
  113. package/lib/cjs/components/SaveCustomerButton.js +1 -1
  114. package/lib/cjs/components/ShippingAddressContainer.d.ts +7 -2
  115. package/lib/cjs/components/ShippingAddressContainer.js +1 -1
  116. package/lib/cjs/components/ShippingAddressForm.d.ts +8 -3
  117. package/lib/cjs/components/ShippingAddressForm.js +1 -1
  118. package/lib/cjs/components/ShippingAmount.d.ts +13 -2
  119. package/lib/cjs/components/ShippingAmount.js +1 -1
  120. package/lib/cjs/components/ShippingMethod.d.ts +10 -3
  121. package/lib/cjs/components/ShippingMethod.js +1 -1
  122. package/lib/cjs/components/ShippingMethodName.d.ts +11 -5
  123. package/lib/cjs/components/ShippingMethodName.js +1 -1
  124. package/lib/cjs/components/ShippingMethodPrice.d.ts +15 -3
  125. package/lib/cjs/components/ShippingMethodPrice.js +1 -1
  126. package/lib/cjs/components/ShippingMethodRadioButton.d.ts +11 -5
  127. package/lib/cjs/components/ShippingMethodRadioButton.js +1 -1
  128. package/lib/cjs/components/SkuField.d.ts +10 -0
  129. package/lib/cjs/components/SkuField.js +1 -0
  130. package/lib/cjs/components/Skus.d.ts +11 -0
  131. package/lib/cjs/components/Skus.js +1 -0
  132. package/lib/cjs/components/SkusContainer.d.ts +14 -0
  133. package/lib/cjs/components/SkusContainer.js +1 -0
  134. package/lib/cjs/components/StockTransfer.d.ts +9 -3
  135. package/lib/cjs/components/StockTransfer.js +1 -1
  136. package/lib/cjs/components/StockTransferField.d.ts +9 -8
  137. package/lib/cjs/components/StockTransferField.js +1 -1
  138. package/lib/cjs/components/StripePayment.d.ts +3 -3
  139. package/lib/cjs/components/StripePayment.js +1 -1
  140. package/lib/cjs/components/SubmitButton.d.ts +15 -5
  141. package/lib/cjs/components/SubmitButton.js +1 -1
  142. package/lib/cjs/components/VariantSelector.d.ts +28 -5
  143. package/lib/cjs/components/VariantSelector.js +1 -1
  144. package/lib/cjs/components/VariantsContainer.d.ts +15 -3
  145. package/lib/cjs/components/VariantsContainer.js +1 -1
  146. package/lib/cjs/components/WireTransferPayment.d.ts +2 -2
  147. package/lib/cjs/components/WireTransferPayment.js +1 -1
  148. package/lib/cjs/components/addresses/Address.d.ts +18 -0
  149. package/lib/cjs/components/addresses/Address.js +1 -0
  150. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +26 -0
  151. package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -0
  152. package/lib/cjs/components/addresses/AddressField.d.ts +43 -0
  153. package/lib/cjs/components/addresses/AddressField.js +1 -0
  154. package/lib/cjs/components/addresses/AddressInput.d.ts +19 -0
  155. package/lib/cjs/components/addresses/AddressInput.js +1 -0
  156. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +27 -0
  157. package/lib/cjs/components/addresses/AddressStateSelector.js +1 -0
  158. package/lib/cjs/components/addresses/AddressesContainer.d.ts +15 -0
  159. package/lib/cjs/components/addresses/AddressesContainer.js +1 -0
  160. package/lib/cjs/components/auth/CommerceLayer.d.ts +15 -0
  161. package/lib/cjs/components/auth/CommerceLayer.js +1 -0
  162. package/lib/cjs/components/customers/CustomerAddressForm.d.ts +13 -0
  163. package/lib/cjs/components/customers/CustomerAddressForm.js +1 -0
  164. package/lib/cjs/components/customers/CustomerContainer.d.ts +17 -0
  165. package/lib/cjs/components/customers/CustomerContainer.js +1 -0
  166. package/lib/cjs/components/customers/CustomerField.d.ts +10 -0
  167. package/lib/cjs/components/customers/CustomerField.js +1 -0
  168. package/lib/cjs/components/customers/CustomerInput.d.ts +23 -0
  169. package/lib/cjs/components/customers/CustomerInput.js +1 -0
  170. package/lib/cjs/components/gateways/AdyenGateway.d.ts +2 -2
  171. package/lib/cjs/components/gateways/AdyenGateway.js +1 -1
  172. package/lib/cjs/components/gateways/BraintreeGateway.d.ts +2 -2
  173. package/lib/cjs/components/gateways/BraintreeGateway.js +1 -1
  174. package/lib/cjs/components/gateways/CheckoutComGateway.d.ts +5 -0
  175. package/lib/cjs/components/gateways/CheckoutComGateway.js +1 -0
  176. package/lib/cjs/components/gateways/KlarnaGateway.d.ts +5 -0
  177. package/lib/cjs/components/gateways/KlarnaGateway.js +1 -0
  178. package/lib/cjs/components/gateways/PaypalGateway.d.ts +3 -3
  179. package/lib/cjs/components/gateways/PaypalGateway.js +1 -1
  180. package/lib/cjs/components/gateways/StripeGateway.d.ts +2 -2
  181. package/lib/cjs/components/gateways/StripeGateway.js +1 -1
  182. package/lib/cjs/components/gateways/WireTransferGateway.d.ts +2 -2
  183. package/lib/cjs/components/gateways/WireTransferGateway.js +1 -1
  184. package/lib/cjs/components/orders/AddToCartButton.d.ts +34 -0
  185. package/lib/cjs/components/orders/AddToCartButton.js +1 -0
  186. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +18 -0
  187. package/lib/cjs/components/orders/AdjustmentAmount.js +1 -0
  188. package/lib/cjs/components/orders/CartLink.d.ts +12 -0
  189. package/lib/cjs/components/orders/CartLink.js +1 -0
  190. package/lib/cjs/components/orders/GiftCardAmount.d.ts +15 -0
  191. package/lib/cjs/components/orders/GiftCardAmount.js +1 -0
  192. package/lib/cjs/components/orders/OrderContainer.d.ts +26 -0
  193. package/lib/cjs/components/orders/OrderContainer.js +1 -0
  194. package/lib/cjs/components/orders/OrderList.d.ts +61 -0
  195. package/lib/cjs/components/orders/OrderList.js +1 -0
  196. package/lib/cjs/components/orders/OrderListRow.d.ts +30 -0
  197. package/lib/cjs/components/orders/OrderListRow.js +1 -0
  198. package/lib/cjs/components/orders/OrderNumber.d.ts +11 -0
  199. package/lib/cjs/components/orders/OrderNumber.js +1 -0
  200. package/lib/cjs/components/orders/OrderStorage.d.ts +16 -0
  201. package/lib/cjs/components/orders/OrderStorage.js +1 -0
  202. package/lib/cjs/components/orders/PlaceOrderButton.d.ts +24 -0
  203. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -0
  204. package/lib/cjs/components/orders/PlaceOrderContainer.d.ts +14 -0
  205. package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -0
  206. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
  207. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  208. package/lib/cjs/components/orders/SubTotalAmount.d.ts +18 -0
  209. package/lib/cjs/components/orders/SubTotalAmount.js +1 -0
  210. package/lib/cjs/components/orders/TaxesAmount.d.ts +18 -0
  211. package/lib/cjs/components/orders/TaxesAmount.js +1 -0
  212. package/lib/cjs/components/orders/TotalAmount.d.ts +18 -0
  213. package/lib/cjs/components/orders/TotalAmount.js +1 -0
  214. package/lib/cjs/components/shipments/Shipment.d.ts +15 -0
  215. package/lib/cjs/components/shipments/Shipment.js +1 -0
  216. package/lib/cjs/components/shipments/ShipmentField.d.ts +19 -0
  217. package/lib/cjs/components/shipments/ShipmentField.js +1 -0
  218. package/lib/cjs/components/shipments/ShipmentsContainer.d.ts +12 -0
  219. package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -0
  220. package/lib/cjs/components/skus/SkuField.d.ts +14 -0
  221. package/lib/cjs/components/skus/SkuField.js +1 -0
  222. package/lib/cjs/components/skus/SkuList.d.ts +14 -0
  223. package/lib/cjs/components/skus/SkuList.js +1 -0
  224. package/lib/cjs/components/skus/SkuListsContainer.d.ts +12 -0
  225. package/lib/cjs/components/skus/SkuListsContainer.js +1 -0
  226. package/lib/cjs/components/skus/SkuOption.d.ts +14 -0
  227. package/lib/cjs/components/skus/SkuOption.js +1 -0
  228. package/lib/cjs/components/skus/SkuOptionInput.d.ts +15 -0
  229. package/lib/cjs/components/skus/SkuOptionInput.js +1 -0
  230. package/lib/cjs/components/skus/SkuOptionsContainer.d.ts +14 -0
  231. package/lib/cjs/components/skus/SkuOptionsContainer.js +1 -0
  232. package/lib/cjs/components/skus/Skus.d.ts +11 -0
  233. package/lib/cjs/components/skus/Skus.js +1 -0
  234. package/lib/cjs/components/skus/SkusContainer.d.ts +23 -0
  235. package/lib/cjs/components/skus/SkusContainer.js +1 -0
  236. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -1
  237. package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -1
  238. package/lib/cjs/components/utils/BaseField.js +1 -1
  239. package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
  240. package/lib/cjs/components/utils/BaseInput.js +1 -1
  241. package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
  242. package/lib/cjs/components/utils/BaseSelect.js +1 -1
  243. package/lib/cjs/components/utils/GenericFieldComponent.d.ts +42 -0
  244. package/lib/cjs/components/utils/GenericFieldComponent.js +1 -0
  245. package/lib/cjs/components/utils/Parent.d.ts +3 -5
  246. package/lib/cjs/components/utils/Parent.js +1 -1
  247. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +2 -2
  248. package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -1
  249. package/lib/cjs/components/utils/PriceTemplate.d.ts +2 -2
  250. package/lib/cjs/components/utils/PriceTemplate.js +1 -1
  251. package/lib/cjs/components/utils/VariantTemplate.js +1 -1
  252. package/lib/cjs/components/utils/getAllErrors.js +1 -1
  253. package/lib/cjs/config/components.d.ts +78 -36
  254. package/lib/cjs/config/components.js +1 -1
  255. package/lib/cjs/context/AddressChildrenContext.d.ts +1 -1
  256. package/lib/cjs/context/AddressChildrenContext.js +1 -1
  257. package/lib/cjs/context/AddressContext.d.ts +1 -1
  258. package/lib/cjs/context/BillingAddressContext.d.ts +2 -4
  259. package/lib/cjs/context/BillingAddressContext.js +1 -1
  260. package/lib/cjs/context/BillingAddressFormContext.d.ts +18 -11
  261. package/lib/cjs/context/CouponAndGiftCardFormContext.d.ts +4 -2
  262. package/lib/cjs/context/CustomerAddressFormContext.d.ts +20 -0
  263. package/lib/cjs/context/CustomerAddressFormContext.js +1 -0
  264. package/lib/cjs/context/CustomerContext.d.ts +17 -11
  265. package/lib/cjs/context/CustomerContext.js +1 -1
  266. package/lib/cjs/context/ExternalFunctionContext.js +1 -1
  267. package/lib/cjs/context/OrderContext.d.ts +8 -4
  268. package/lib/cjs/context/OrderContext.js +1 -1
  269. package/lib/cjs/context/OrderListChildrenContext.d.ts +60 -0
  270. package/lib/cjs/context/OrderListChildrenContext.js +1 -0
  271. package/lib/cjs/context/PaymentSourceContext.d.ts +4 -4
  272. package/lib/cjs/context/PlaceOrderContext.d.ts +4 -2
  273. package/lib/cjs/context/ShippingAddressContext.d.ts +1 -1
  274. package/lib/cjs/context/SkuChildrenContext.d.ts +9 -0
  275. package/lib/cjs/context/SkuChildrenContext.js +1 -0
  276. package/lib/cjs/context/SkuContext.d.ts +9 -0
  277. package/lib/cjs/context/SkuContext.js +1 -0
  278. package/lib/cjs/index.d.ts +101 -90
  279. package/lib/cjs/index.js +1 -1
  280. package/lib/cjs/reducers/AddressReducer.d.ts +4 -2
  281. package/lib/cjs/reducers/AddressReducer.js +1 -1
  282. package/lib/cjs/reducers/AvailabilityReducer.d.ts +8 -0
  283. package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
  284. package/lib/cjs/reducers/BillingAddressReducer.js +1 -1
  285. package/lib/cjs/reducers/CustomerReducer.d.ts +98 -17
  286. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  287. package/lib/cjs/reducers/GiftCardReducer.js +1 -1
  288. package/lib/cjs/reducers/ItemReducer.js +1 -1
  289. package/lib/cjs/reducers/LineItemReducer.js +1 -1
  290. package/lib/cjs/reducers/OrderReducer.d.ts +24 -8
  291. package/lib/cjs/reducers/OrderReducer.js +1 -1
  292. package/lib/cjs/reducers/PaymentMethodReducer.d.ts +51 -5
  293. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
  294. package/lib/cjs/reducers/PlaceOrderReducer.d.ts +9 -2
  295. package/lib/cjs/reducers/PlaceOrderReducer.js +1 -1
  296. package/lib/cjs/reducers/PriceReducer.js +1 -1
  297. package/lib/cjs/reducers/ShipmentReducer.js +1 -1
  298. package/lib/cjs/reducers/ShippingAddressReducer.js +1 -1
  299. package/lib/cjs/reducers/SkuListsReducer.js +1 -1
  300. package/lib/cjs/reducers/SkuOptionsReducer.js +1 -1
  301. package/lib/cjs/reducers/SkuReducer.d.ts +21 -0
  302. package/lib/cjs/reducers/SkuReducer.js +1 -0
  303. package/lib/cjs/reducers/VariantReducer.d.ts +1 -0
  304. package/lib/cjs/reducers/VariantReducer.js +1 -1
  305. package/lib/cjs/typings/errors.d.ts +13 -4
  306. package/lib/cjs/typings/errors.js +1 -1
  307. package/lib/cjs/typings/index.d.ts +18 -7
  308. package/lib/cjs/typings/index.js +1 -1
  309. package/lib/cjs/utils/addressesManager.d.ts +1 -1
  310. package/lib/cjs/utils/addressesManager.js +1 -1
  311. package/lib/cjs/utils/baseReducer.js +1 -1
  312. package/lib/cjs/utils/checkIncludeResource.d.ts +8 -0
  313. package/lib/cjs/utils/checkIncludeResource.js +1 -0
  314. package/lib/cjs/utils/childrenTypes.d.ts +1 -1
  315. package/lib/cjs/utils/childrenTypes.js +1 -1
  316. package/lib/cjs/utils/compareObjAttribute.d.ts +7 -0
  317. package/lib/cjs/utils/compareObjAttribute.js +1 -0
  318. package/lib/cjs/utils/customMessages.d.ts +1 -7
  319. package/lib/cjs/utils/customMessages.js +1 -1
  320. package/lib/cjs/utils/getCardDetails.d.ts +15 -0
  321. package/lib/cjs/utils/getCardDetails.js +1 -0
  322. package/lib/cjs/utils/getCartLink.d.ts +7 -0
  323. package/lib/cjs/utils/getCartLink.js +1 -0
  324. package/lib/cjs/utils/getCurrentItemKey.js +1 -1
  325. package/lib/cjs/utils/getErrors.d.ts +1 -1
  326. package/lib/cjs/utils/getErrors.js +1 -1
  327. package/lib/cjs/utils/getLineItemsCount.d.ts +8 -10
  328. package/lib/cjs/utils/getLineItemsCount.js +1 -1
  329. package/lib/cjs/utils/getLoaderComponent.js +1 -1
  330. package/lib/cjs/utils/getPrices.js +1 -1
  331. package/lib/cjs/utils/getSdk.js +1 -1
  332. package/lib/cjs/utils/getSkus.js +1 -1
  333. package/lib/cjs/utils/hooks/useExternalScript.d.ts +1 -0
  334. package/lib/cjs/utils/hooks/useExternalScript.js +1 -0
  335. package/lib/cjs/utils/icons.d.ts +3 -0
  336. package/lib/cjs/utils/icons.js +1 -0
  337. package/lib/cjs/utils/isDate.d.ts +1 -0
  338. package/lib/cjs/utils/isDate.js +1 -0
  339. package/lib/cjs/utils/jwt.d.ts +1 -1
  340. package/lib/cjs/utils/jwt.js +1 -1
  341. package/lib/cjs/utils/paypalPayment.js +1 -1
  342. package/lib/cjs/utils/placeholderImages.d.ts +2 -0
  343. package/lib/cjs/utils/placeholderImages.js +1 -0
  344. package/lib/cjs/utils/promisify.js +1 -1
  345. package/lib/cjs/utils/scrollbarWidth.d.ts +1 -0
  346. package/lib/cjs/utils/scrollbarWidth.js +1 -0
  347. package/lib/cjs/utils/shipments.d.ts +2 -1
  348. package/lib/cjs/utils/shipments.js +1 -1
  349. package/lib/cjs/utils/validateFormFields.d.ts +2 -0
  350. package/lib/cjs/utils/validateFormFields.js +1 -1
  351. package/lib/esm/components/AdjustmentAmount.js +1 -1
  352. package/lib/esm/components/AdyenPayment.d.ts +3 -3
  353. package/lib/esm/components/AdyenPayment.js +1 -1
  354. package/lib/esm/components/AvailabilityContainer.d.ts +10 -3
  355. package/lib/esm/components/AvailabilityContainer.js +1 -1
  356. package/lib/esm/components/AvailabilityTemplate.d.ts +13 -4
  357. package/lib/esm/components/AvailabilityTemplate.js +1 -1
  358. package/lib/esm/components/BillingAddressContainer.d.ts +7 -2
  359. package/lib/esm/components/BillingAddressContainer.js +1 -1
  360. package/lib/esm/components/BillingAddressForm.d.ts +8 -3
  361. package/lib/esm/components/BillingAddressForm.js +1 -1
  362. package/lib/esm/components/BraintreePayment.d.ts +3 -3
  363. package/lib/esm/components/BraintreePayment.js +1 -1
  364. package/lib/esm/components/CartLink.d.ts +12 -0
  365. package/lib/esm/components/CartLink.js +1 -0
  366. package/lib/esm/components/CheckoutComPayment.d.ts +23 -0
  367. package/lib/esm/components/CheckoutComPayment.js +1 -0
  368. package/lib/esm/components/CheckoutLink.d.ts +16 -4
  369. package/lib/esm/components/CheckoutLink.js +1 -1
  370. package/lib/esm/components/DeliveryLeadTime.d.ts +11 -4
  371. package/lib/esm/components/DeliveryLeadTime.js +1 -1
  372. package/lib/esm/components/DiscountAmount.d.ts +16 -2
  373. package/lib/esm/components/DiscountAmount.js +1 -1
  374. package/lib/esm/components/Errors.d.ts +4 -4
  375. package/lib/esm/components/Errors.js +1 -1
  376. package/lib/esm/components/ExternalFunction.d.ts +9 -2
  377. package/lib/esm/components/ExternalFunction.js +1 -1
  378. package/lib/esm/components/GiftCard.d.ts +13 -3
  379. package/lib/esm/components/GiftCard.js +1 -1
  380. package/lib/esm/components/GiftCardContainer.d.ts +9 -3
  381. package/lib/esm/components/GiftCardContainer.js +1 -1
  382. package/lib/esm/components/GiftCardCurrencySelector.d.ts +18 -3
  383. package/lib/esm/components/GiftCardCurrencySelector.js +1 -1
  384. package/lib/esm/components/GiftCardInput.d.ts +12 -3
  385. package/lib/esm/components/GiftCardInput.js +1 -1
  386. package/lib/esm/components/GiftCardOrCouponCode.d.ts +17 -6
  387. package/lib/esm/components/GiftCardOrCouponCode.js +1 -1
  388. package/lib/esm/components/GiftCardOrCouponForm.d.ts +9 -4
  389. package/lib/esm/components/GiftCardOrCouponForm.js +1 -1
  390. package/lib/esm/components/GiftCardOrCouponInput.d.ts +14 -3
  391. package/lib/esm/components/GiftCardOrCouponInput.js +1 -1
  392. package/lib/esm/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
  393. package/lib/esm/components/GiftCardOrCouponRemoveButton.js +1 -1
  394. package/lib/esm/components/GiftCardOrCouponSubmit.d.ts +11 -4
  395. package/lib/esm/components/GiftCardOrCouponSubmit.js +1 -1
  396. package/lib/esm/components/ItemContainer.d.ts +14 -3
  397. package/lib/esm/components/ItemContainer.js +1 -1
  398. package/lib/esm/components/KlarnaPayment.d.ts +10 -0
  399. package/lib/esm/components/KlarnaPayment.js +1 -0
  400. package/lib/esm/components/LineItem.d.ts +10 -3
  401. package/lib/esm/components/LineItem.js +1 -1
  402. package/lib/esm/components/LineItemAmount.d.ts +16 -3
  403. package/lib/esm/components/LineItemAmount.js +1 -1
  404. package/lib/esm/components/LineItemCode.d.ts +10 -4
  405. package/lib/esm/components/LineItemCode.js +1 -1
  406. package/lib/esm/components/LineItemImage.d.ts +11 -4
  407. package/lib/esm/components/LineItemImage.js +1 -1
  408. package/lib/esm/components/LineItemName.d.ts +11 -5
  409. package/lib/esm/components/LineItemName.js +1 -1
  410. package/lib/esm/components/LineItemOption.d.ts +15 -4
  411. package/lib/esm/components/LineItemOption.js +1 -1
  412. package/lib/esm/components/LineItemOptions.d.ts +8 -3
  413. package/lib/esm/components/LineItemOptions.js +1 -1
  414. package/lib/esm/components/LineItemQuantity.d.ts +16 -4
  415. package/lib/esm/components/LineItemQuantity.js +1 -1
  416. package/lib/esm/components/LineItemRemoveLink.d.ts +15 -5
  417. package/lib/esm/components/LineItemRemoveLink.js +1 -1
  418. package/lib/esm/components/LineItemsContainer.d.ts +15 -3
  419. package/lib/esm/components/LineItemsContainer.js +1 -1
  420. package/lib/esm/components/LineItemsCount.d.ts +14 -4
  421. package/lib/esm/components/LineItemsCount.js +1 -1
  422. package/lib/esm/components/LineItemsEmpty.d.ts +13 -2
  423. package/lib/esm/components/LineItemsEmpty.js +1 -1
  424. package/lib/esm/components/MetadataInput.d.ts +13 -3
  425. package/lib/esm/components/MetadataInput.js +1 -1
  426. package/lib/esm/components/PaymentGateway.d.ts +4 -4
  427. package/lib/esm/components/PaymentGateway.js +1 -1
  428. package/lib/esm/components/PaymentMethod.d.ts +9 -3
  429. package/lib/esm/components/PaymentMethod.js +1 -1
  430. package/lib/esm/components/PaymentMethodAmount.d.ts +16 -2
  431. package/lib/esm/components/PaymentMethodAmount.js +1 -1
  432. package/lib/esm/components/PaymentMethodName.d.ts +10 -4
  433. package/lib/esm/components/PaymentMethodName.js +1 -1
  434. package/lib/esm/components/PaymentMethodPrice.d.ts +15 -4
  435. package/lib/esm/components/PaymentMethodPrice.js +1 -1
  436. package/lib/esm/components/PaymentMethodRadioButton.d.ts +11 -4
  437. package/lib/esm/components/PaymentMethodRadioButton.js +1 -1
  438. package/lib/esm/components/PaymentMethodsContainer.d.ts +9 -3
  439. package/lib/esm/components/PaymentMethodsContainer.js +1 -1
  440. package/lib/esm/components/PaymentSource.d.ts +9 -2
  441. package/lib/esm/components/PaymentSource.js +1 -1
  442. package/lib/esm/components/PaymentSourceBrandIcon.d.ts +14 -4
  443. package/lib/esm/components/PaymentSourceBrandIcon.js +1 -1
  444. package/lib/esm/components/PaymentSourceBrandName.d.ts +11 -4
  445. package/lib/esm/components/PaymentSourceBrandName.js +1 -1
  446. package/lib/esm/components/PaymentSourceDetail.d.ts +8 -2
  447. package/lib/esm/components/PaymentSourceDetail.js +1 -1
  448. package/lib/esm/components/PaymentSourceEditButton.d.ts +9 -2
  449. package/lib/esm/components/PaymentSourceEditButton.js +1 -1
  450. package/lib/esm/components/PaypalPayment.d.ts +2 -2
  451. package/lib/esm/components/PaypalPayment.js +1 -1
  452. package/lib/esm/components/Price.d.ts +15 -3
  453. package/lib/esm/components/Price.js +1 -1
  454. package/lib/esm/components/PricesContainer.d.ts +19 -3
  455. package/lib/esm/components/PricesContainer.js +1 -1
  456. package/lib/esm/components/QuantitySelector.d.ts +19 -5
  457. package/lib/esm/components/QuantitySelector.js +1 -1
  458. package/lib/esm/components/SaveAddressesButton.d.ts +18 -5
  459. package/lib/esm/components/SaveAddressesButton.js +1 -1
  460. package/lib/esm/components/SaveCustomerButton.d.ts +16 -5
  461. package/lib/esm/components/SaveCustomerButton.js +1 -1
  462. package/lib/esm/components/ShippingAddressContainer.d.ts +7 -2
  463. package/lib/esm/components/ShippingAddressContainer.js +1 -1
  464. package/lib/esm/components/ShippingAddressForm.d.ts +8 -3
  465. package/lib/esm/components/ShippingAddressForm.js +1 -1
  466. package/lib/esm/components/ShippingAmount.d.ts +13 -2
  467. package/lib/esm/components/ShippingAmount.js +1 -1
  468. package/lib/esm/components/ShippingMethod.d.ts +10 -3
  469. package/lib/esm/components/ShippingMethod.js +1 -1
  470. package/lib/esm/components/ShippingMethodName.d.ts +11 -5
  471. package/lib/esm/components/ShippingMethodName.js +1 -1
  472. package/lib/esm/components/ShippingMethodPrice.d.ts +15 -3
  473. package/lib/esm/components/ShippingMethodPrice.js +1 -1
  474. package/lib/esm/components/ShippingMethodRadioButton.d.ts +11 -5
  475. package/lib/esm/components/ShippingMethodRadioButton.js +1 -1
  476. package/lib/esm/components/SkuField.d.ts +10 -0
  477. package/lib/esm/components/SkuField.js +1 -0
  478. package/lib/esm/components/Skus.d.ts +11 -0
  479. package/lib/esm/components/Skus.js +1 -0
  480. package/lib/esm/components/SkusContainer.d.ts +14 -0
  481. package/lib/esm/components/SkusContainer.js +1 -0
  482. package/lib/esm/components/StockTransfer.d.ts +9 -3
  483. package/lib/esm/components/StockTransfer.js +1 -1
  484. package/lib/esm/components/StockTransferField.d.ts +9 -8
  485. package/lib/esm/components/StockTransferField.js +1 -1
  486. package/lib/esm/components/StripePayment.d.ts +3 -3
  487. package/lib/esm/components/StripePayment.js +1 -1
  488. package/lib/esm/components/SubmitButton.d.ts +15 -5
  489. package/lib/esm/components/SubmitButton.js +1 -1
  490. package/lib/esm/components/VariantSelector.d.ts +28 -5
  491. package/lib/esm/components/VariantSelector.js +1 -1
  492. package/lib/esm/components/VariantsContainer.d.ts +15 -3
  493. package/lib/esm/components/VariantsContainer.js +1 -1
  494. package/lib/esm/components/WireTransferPayment.d.ts +2 -2
  495. package/lib/esm/components/WireTransferPayment.js +1 -1
  496. package/lib/esm/components/addresses/Address.d.ts +18 -0
  497. package/lib/esm/components/addresses/Address.js +1 -0
  498. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +26 -0
  499. package/lib/esm/components/addresses/AddressCountrySelector.js +1 -0
  500. package/lib/esm/components/addresses/AddressField.d.ts +43 -0
  501. package/lib/esm/components/addresses/AddressField.js +1 -0
  502. package/lib/esm/components/addresses/AddressInput.d.ts +19 -0
  503. package/lib/esm/components/addresses/AddressInput.js +1 -0
  504. package/lib/esm/components/addresses/AddressStateSelector.d.ts +27 -0
  505. package/lib/esm/components/addresses/AddressStateSelector.js +1 -0
  506. package/lib/esm/components/addresses/AddressesContainer.d.ts +15 -0
  507. package/lib/esm/components/addresses/AddressesContainer.js +1 -0
  508. package/lib/esm/components/auth/CommerceLayer.d.ts +15 -0
  509. package/lib/esm/components/auth/CommerceLayer.js +1 -0
  510. package/lib/esm/components/customers/CustomerAddressForm.d.ts +13 -0
  511. package/lib/esm/components/customers/CustomerAddressForm.js +1 -0
  512. package/lib/esm/components/customers/CustomerContainer.d.ts +17 -0
  513. package/lib/esm/components/customers/CustomerContainer.js +1 -0
  514. package/lib/esm/components/customers/CustomerField.d.ts +10 -0
  515. package/lib/esm/components/customers/CustomerField.js +1 -0
  516. package/lib/esm/components/customers/CustomerInput.d.ts +23 -0
  517. package/lib/esm/components/customers/CustomerInput.js +1 -0
  518. package/lib/esm/components/gateways/AdyenGateway.d.ts +2 -2
  519. package/lib/esm/components/gateways/AdyenGateway.js +1 -1
  520. package/lib/esm/components/gateways/BraintreeGateway.d.ts +2 -2
  521. package/lib/esm/components/gateways/BraintreeGateway.js +1 -1
  522. package/lib/esm/components/gateways/CheckoutComGateway.d.ts +5 -0
  523. package/lib/esm/components/gateways/CheckoutComGateway.js +1 -0
  524. package/lib/esm/components/gateways/KlarnaGateway.d.ts +5 -0
  525. package/lib/esm/components/gateways/KlarnaGateway.js +1 -0
  526. package/lib/esm/components/gateways/PaypalGateway.d.ts +3 -3
  527. package/lib/esm/components/gateways/PaypalGateway.js +1 -1
  528. package/lib/esm/components/gateways/StripeGateway.d.ts +2 -2
  529. package/lib/esm/components/gateways/StripeGateway.js +1 -1
  530. package/lib/esm/components/gateways/WireTransferGateway.d.ts +2 -2
  531. package/lib/esm/components/gateways/WireTransferGateway.js +1 -1
  532. package/lib/esm/components/orders/AddToCartButton.d.ts +34 -0
  533. package/lib/esm/components/orders/AddToCartButton.js +1 -0
  534. package/lib/esm/components/orders/AdjustmentAmount.d.ts +18 -0
  535. package/lib/esm/components/orders/AdjustmentAmount.js +1 -0
  536. package/lib/esm/components/orders/CartLink.d.ts +12 -0
  537. package/lib/esm/components/orders/CartLink.js +1 -0
  538. package/lib/esm/components/orders/GiftCardAmount.d.ts +15 -0
  539. package/lib/esm/components/orders/GiftCardAmount.js +1 -0
  540. package/lib/esm/components/orders/OrderContainer.d.ts +26 -0
  541. package/lib/esm/components/orders/OrderContainer.js +1 -0
  542. package/lib/esm/components/orders/OrderList.d.ts +61 -0
  543. package/lib/esm/components/orders/OrderList.js +1 -0
  544. package/lib/esm/components/orders/OrderListRow.d.ts +30 -0
  545. package/lib/esm/components/orders/OrderListRow.js +1 -0
  546. package/lib/esm/components/orders/OrderNumber.d.ts +11 -0
  547. package/lib/esm/components/orders/OrderNumber.js +1 -0
  548. package/lib/esm/components/orders/OrderStorage.d.ts +16 -0
  549. package/lib/esm/components/orders/OrderStorage.js +1 -0
  550. package/lib/esm/components/orders/PlaceOrderButton.d.ts +24 -0
  551. package/lib/esm/components/orders/PlaceOrderButton.js +1 -0
  552. package/lib/esm/components/orders/PlaceOrderContainer.d.ts +14 -0
  553. package/lib/esm/components/orders/PlaceOrderContainer.js +1 -0
  554. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
  555. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  556. package/lib/esm/components/orders/SubTotalAmount.d.ts +18 -0
  557. package/lib/esm/components/orders/SubTotalAmount.js +1 -0
  558. package/lib/esm/components/orders/TaxesAmount.d.ts +18 -0
  559. package/lib/esm/components/orders/TaxesAmount.js +1 -0
  560. package/lib/esm/components/orders/TotalAmount.d.ts +18 -0
  561. package/lib/esm/components/orders/TotalAmount.js +1 -0
  562. package/lib/esm/components/shipments/Shipment.d.ts +15 -0
  563. package/lib/esm/components/shipments/Shipment.js +1 -0
  564. package/lib/esm/components/shipments/ShipmentField.d.ts +19 -0
  565. package/lib/esm/components/shipments/ShipmentField.js +1 -0
  566. package/lib/esm/components/shipments/ShipmentsContainer.d.ts +12 -0
  567. package/lib/esm/components/shipments/ShipmentsContainer.js +1 -0
  568. package/lib/esm/components/skus/SkuField.d.ts +14 -0
  569. package/lib/esm/components/skus/SkuField.js +1 -0
  570. package/lib/esm/components/skus/SkuList.d.ts +14 -0
  571. package/lib/esm/components/skus/SkuList.js +1 -0
  572. package/lib/esm/components/skus/SkuListsContainer.d.ts +12 -0
  573. package/lib/esm/components/skus/SkuListsContainer.js +1 -0
  574. package/lib/esm/components/skus/SkuOption.d.ts +14 -0
  575. package/lib/esm/components/skus/SkuOption.js +1 -0
  576. package/lib/esm/components/skus/SkuOptionInput.d.ts +15 -0
  577. package/lib/esm/components/skus/SkuOptionInput.js +1 -0
  578. package/lib/esm/components/skus/SkuOptionsContainer.d.ts +14 -0
  579. package/lib/esm/components/skus/SkuOptionsContainer.js +1 -0
  580. package/lib/esm/components/skus/Skus.d.ts +11 -0
  581. package/lib/esm/components/skus/Skus.js +1 -0
  582. package/lib/esm/components/skus/SkusContainer.d.ts +23 -0
  583. package/lib/esm/components/skus/SkusContainer.js +1 -0
  584. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -1
  585. package/lib/esm/components/utils/AddressCardsTemplate.js +1 -1
  586. package/lib/esm/components/utils/BaseField.js +1 -1
  587. package/lib/esm/components/utils/BaseInput.d.ts +1 -1
  588. package/lib/esm/components/utils/BaseInput.js +1 -1
  589. package/lib/esm/components/utils/BaseOrderPrice.js +1 -1
  590. package/lib/esm/components/utils/BaseSelect.js +1 -1
  591. package/lib/esm/components/utils/GenericFieldComponent.d.ts +42 -0
  592. package/lib/esm/components/utils/GenericFieldComponent.js +1 -0
  593. package/lib/esm/components/utils/Parent.d.ts +3 -5
  594. package/lib/esm/components/utils/Parent.js +1 -1
  595. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +2 -2
  596. package/lib/esm/components/utils/PaymentCardsTemplate.js +1 -1
  597. package/lib/esm/components/utils/PriceTemplate.d.ts +2 -2
  598. package/lib/esm/components/utils/PriceTemplate.js +1 -1
  599. package/lib/esm/components/utils/VariantTemplate.js +1 -1
  600. package/lib/esm/components/utils/getAllErrors.js +1 -1
  601. package/lib/esm/config/components.d.ts +78 -36
  602. package/lib/esm/config/components.js +1 -1
  603. package/lib/esm/context/AddressChildrenContext.d.ts +1 -1
  604. package/lib/esm/context/AddressChildrenContext.js +1 -1
  605. package/lib/esm/context/AddressContext.d.ts +1 -1
  606. package/lib/esm/context/BillingAddressContext.d.ts +2 -4
  607. package/lib/esm/context/BillingAddressContext.js +1 -1
  608. package/lib/esm/context/BillingAddressFormContext.d.ts +18 -11
  609. package/lib/esm/context/CouponAndGiftCardFormContext.d.ts +4 -2
  610. package/lib/esm/context/CustomerAddressFormContext.d.ts +20 -0
  611. package/lib/esm/context/CustomerAddressFormContext.js +1 -0
  612. package/lib/esm/context/CustomerContext.d.ts +17 -11
  613. package/lib/esm/context/CustomerContext.js +1 -1
  614. package/lib/esm/context/OrderContext.d.ts +8 -4
  615. package/lib/esm/context/OrderContext.js +1 -1
  616. package/lib/esm/context/OrderListChildrenContext.d.ts +60 -0
  617. package/lib/esm/context/OrderListChildrenContext.js +1 -0
  618. package/lib/esm/context/PaymentSourceContext.d.ts +4 -4
  619. package/lib/esm/context/PlaceOrderContext.d.ts +4 -2
  620. package/lib/esm/context/ShippingAddressContext.d.ts +1 -1
  621. package/lib/esm/context/SkuChildrenContext.d.ts +9 -0
  622. package/lib/esm/context/SkuChildrenContext.js +1 -0
  623. package/lib/esm/context/SkuContext.d.ts +9 -0
  624. package/lib/esm/context/SkuContext.js +1 -0
  625. package/lib/esm/index.d.ts +101 -90
  626. package/lib/esm/index.js +1 -1
  627. package/lib/esm/reducers/AddressReducer.d.ts +4 -2
  628. package/lib/esm/reducers/AddressReducer.js +1 -1
  629. package/lib/esm/reducers/AvailabilityReducer.d.ts +8 -0
  630. package/lib/esm/reducers/AvailabilityReducer.js +1 -1
  631. package/lib/esm/reducers/BillingAddressReducer.js +1 -1
  632. package/lib/esm/reducers/CustomerReducer.d.ts +98 -17
  633. package/lib/esm/reducers/CustomerReducer.js +1 -1
  634. package/lib/esm/reducers/GiftCardReducer.js +1 -1
  635. package/lib/esm/reducers/LineItemReducer.js +1 -1
  636. package/lib/esm/reducers/OrderReducer.d.ts +24 -8
  637. package/lib/esm/reducers/OrderReducer.js +1 -1
  638. package/lib/esm/reducers/PaymentMethodReducer.d.ts +51 -5
  639. package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
  640. package/lib/esm/reducers/PlaceOrderReducer.d.ts +9 -2
  641. package/lib/esm/reducers/PlaceOrderReducer.js +1 -1
  642. package/lib/esm/reducers/PriceReducer.js +1 -1
  643. package/lib/esm/reducers/ShipmentReducer.js +1 -1
  644. package/lib/esm/reducers/ShippingAddressReducer.js +1 -1
  645. package/lib/esm/reducers/SkuReducer.d.ts +21 -0
  646. package/lib/esm/reducers/SkuReducer.js +1 -0
  647. package/lib/esm/reducers/VariantReducer.d.ts +1 -0
  648. package/lib/esm/reducers/VariantReducer.js +1 -1
  649. package/lib/esm/typings/errors.d.ts +13 -4
  650. package/lib/esm/typings/errors.js +1 -1
  651. package/lib/esm/typings/index.d.ts +18 -7
  652. package/lib/esm/typings/index.js +1 -1
  653. package/lib/esm/utils/addressesManager.d.ts +1 -1
  654. package/lib/esm/utils/addressesManager.js +1 -1
  655. package/lib/esm/utils/baseReducer.js +1 -1
  656. package/lib/esm/utils/checkIncludeResource.d.ts +8 -0
  657. package/lib/esm/utils/checkIncludeResource.js +1 -0
  658. package/lib/esm/utils/childrenTypes.d.ts +1 -1
  659. package/lib/esm/utils/childrenTypes.js +1 -1
  660. package/lib/esm/utils/compareObjAttribute.d.ts +7 -0
  661. package/lib/esm/utils/compareObjAttribute.js +1 -0
  662. package/lib/esm/utils/customMessages.d.ts +1 -7
  663. package/lib/esm/utils/customMessages.js +1 -1
  664. package/lib/esm/utils/getCardDetails.d.ts +15 -0
  665. package/lib/esm/utils/getCardDetails.js +1 -0
  666. package/lib/esm/utils/getCartLink.d.ts +7 -0
  667. package/lib/esm/utils/getCartLink.js +1 -0
  668. package/lib/esm/utils/getCurrentItemKey.js +1 -1
  669. package/lib/esm/utils/getErrors.d.ts +1 -1
  670. package/lib/esm/utils/getErrors.js +1 -1
  671. package/lib/esm/utils/getLineItemsCount.d.ts +8 -10
  672. package/lib/esm/utils/getLineItemsCount.js +1 -1
  673. package/lib/esm/utils/getLoaderComponent.js +1 -1
  674. package/lib/esm/utils/getPrices.js +1 -1
  675. package/lib/esm/utils/getSdk.js +1 -1
  676. package/lib/esm/utils/getSkus.js +1 -1
  677. package/lib/esm/utils/hooks/useExternalScript.d.ts +1 -0
  678. package/lib/esm/utils/hooks/useExternalScript.js +1 -0
  679. package/lib/esm/utils/icons.d.ts +3 -0
  680. package/lib/esm/utils/icons.js +1 -0
  681. package/lib/esm/utils/isDate.d.ts +1 -0
  682. package/lib/esm/utils/isDate.js +1 -0
  683. package/lib/esm/utils/jwt.d.ts +1 -1
  684. package/lib/esm/utils/placeholderImages.d.ts +2 -0
  685. package/lib/esm/utils/placeholderImages.js +1 -0
  686. package/lib/esm/utils/promisify.js +1 -1
  687. package/lib/esm/utils/scrollbarWidth.d.ts +1 -0
  688. package/lib/esm/utils/scrollbarWidth.js +1 -0
  689. package/lib/esm/utils/shipments.d.ts +2 -1
  690. package/lib/esm/utils/shipments.js +1 -1
  691. package/lib/esm/utils/validateFormFields.d.ts +2 -0
  692. package/lib/esm/utils/validateFormFields.js +1 -1
  693. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  694. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  695. package/package.json +118 -93
  696. package/lib/cjs/components/AddToCartButton.d.ts +0 -20
  697. package/lib/cjs/components/AddToCartButton.js +0 -1
  698. package/lib/cjs/components/Address.d.ts +0 -13
  699. package/lib/cjs/components/Address.js +0 -1
  700. package/lib/cjs/components/AddressCountrySelector.d.ts +0 -9
  701. package/lib/cjs/components/AddressCountrySelector.js +0 -1
  702. package/lib/cjs/components/AddressField.d.ts +0 -15
  703. package/lib/cjs/components/AddressField.js +0 -1
  704. package/lib/cjs/components/AddressInput.d.ts +0 -7
  705. package/lib/cjs/components/AddressInput.js +0 -1
  706. package/lib/cjs/components/AddressStateSelector.d.ts +0 -11
  707. package/lib/cjs/components/AddressStateSelector.js +0 -1
  708. package/lib/cjs/components/AddressesContainer.d.ts +0 -7
  709. package/lib/cjs/components/AddressesContainer.js +0 -1
  710. package/lib/cjs/components/CommerceLayer.d.ts +0 -8
  711. package/lib/cjs/components/CommerceLayer.js +0 -1
  712. package/lib/cjs/components/CustomerContainer.d.ts +0 -7
  713. package/lib/cjs/components/CustomerContainer.js +0 -1
  714. package/lib/cjs/components/CustomerInput.d.ts +0 -11
  715. package/lib/cjs/components/CustomerInput.js +0 -1
  716. package/lib/cjs/components/GiftCardAmount.d.ts +0 -4
  717. package/lib/cjs/components/GiftCardAmount.js +0 -1
  718. package/lib/cjs/components/OrderContainer.d.ts +0 -11
  719. package/lib/cjs/components/OrderContainer.js +0 -1
  720. package/lib/cjs/components/OrderNumber.d.ts +0 -5
  721. package/lib/cjs/components/OrderNumber.js +0 -1
  722. package/lib/cjs/components/OrderStorage.d.ts +0 -8
  723. package/lib/cjs/components/OrderStorage.js +0 -1
  724. package/lib/cjs/components/PlaceOrderButton.d.ts +0 -12
  725. package/lib/cjs/components/PlaceOrderButton.js +0 -1
  726. package/lib/cjs/components/PlaceOrderContainer.d.ts +0 -8
  727. package/lib/cjs/components/PlaceOrderContainer.js +0 -1
  728. package/lib/cjs/components/PrivacyAndTermsCheckbox.d.ts +0 -4
  729. package/lib/cjs/components/PrivacyAndTermsCheckbox.js +0 -1
  730. package/lib/cjs/components/Shipment.d.ts +0 -8
  731. package/lib/cjs/components/Shipment.js +0 -1
  732. package/lib/cjs/components/ShipmentField.d.ts +0 -12
  733. package/lib/cjs/components/ShipmentField.js +0 -1
  734. package/lib/cjs/components/ShipmentsContainer.d.ts +0 -6
  735. package/lib/cjs/components/ShipmentsContainer.js +0 -1
  736. package/lib/cjs/components/SkuList.d.ts +0 -7
  737. package/lib/cjs/components/SkuList.js +0 -1
  738. package/lib/cjs/components/SkuListsContainer.d.ts +0 -6
  739. package/lib/cjs/components/SkuListsContainer.js +0 -1
  740. package/lib/cjs/components/SkuOption.d.ts +0 -7
  741. package/lib/cjs/components/SkuOption.js +0 -1
  742. package/lib/cjs/components/SkuOptionInput.d.ts +0 -5
  743. package/lib/cjs/components/SkuOptionInput.js +0 -1
  744. package/lib/cjs/components/SkuOptionsContainer.d.ts +0 -7
  745. package/lib/cjs/components/SkuOptionsContainer.js +0 -1
  746. package/lib/cjs/components/SubTotalAmount.d.ts +0 -4
  747. package/lib/cjs/components/SubTotalAmount.js +0 -1
  748. package/lib/cjs/components/TaxesAmount.d.ts +0 -4
  749. package/lib/cjs/components/TaxesAmount.js +0 -1
  750. package/lib/cjs/components/TotalAmount.d.ts +0 -4
  751. package/lib/cjs/components/TotalAmount.js +0 -1
  752. package/lib/esm/components/AddToCartButton.d.ts +0 -20
  753. package/lib/esm/components/AddToCartButton.js +0 -1
  754. package/lib/esm/components/Address.d.ts +0 -13
  755. package/lib/esm/components/Address.js +0 -1
  756. package/lib/esm/components/AddressCountrySelector.d.ts +0 -9
  757. package/lib/esm/components/AddressCountrySelector.js +0 -1
  758. package/lib/esm/components/AddressField.d.ts +0 -15
  759. package/lib/esm/components/AddressField.js +0 -1
  760. package/lib/esm/components/AddressInput.d.ts +0 -7
  761. package/lib/esm/components/AddressInput.js +0 -1
  762. package/lib/esm/components/AddressStateSelector.d.ts +0 -11
  763. package/lib/esm/components/AddressStateSelector.js +0 -1
  764. package/lib/esm/components/AddressesContainer.d.ts +0 -7
  765. package/lib/esm/components/AddressesContainer.js +0 -1
  766. package/lib/esm/components/CommerceLayer.d.ts +0 -8
  767. package/lib/esm/components/CommerceLayer.js +0 -1
  768. package/lib/esm/components/CustomerContainer.d.ts +0 -7
  769. package/lib/esm/components/CustomerContainer.js +0 -1
  770. package/lib/esm/components/CustomerInput.d.ts +0 -11
  771. package/lib/esm/components/CustomerInput.js +0 -1
  772. package/lib/esm/components/GiftCardAmount.d.ts +0 -4
  773. package/lib/esm/components/GiftCardAmount.js +0 -1
  774. package/lib/esm/components/OrderContainer.d.ts +0 -11
  775. package/lib/esm/components/OrderContainer.js +0 -1
  776. package/lib/esm/components/OrderNumber.d.ts +0 -5
  777. package/lib/esm/components/OrderNumber.js +0 -1
  778. package/lib/esm/components/OrderStorage.d.ts +0 -8
  779. package/lib/esm/components/OrderStorage.js +0 -1
  780. package/lib/esm/components/PlaceOrderButton.d.ts +0 -12
  781. package/lib/esm/components/PlaceOrderButton.js +0 -1
  782. package/lib/esm/components/PlaceOrderContainer.d.ts +0 -8
  783. package/lib/esm/components/PlaceOrderContainer.js +0 -1
  784. package/lib/esm/components/PrivacyAndTermsCheckbox.d.ts +0 -4
  785. package/lib/esm/components/PrivacyAndTermsCheckbox.js +0 -1
  786. package/lib/esm/components/Shipment.d.ts +0 -8
  787. package/lib/esm/components/Shipment.js +0 -1
  788. package/lib/esm/components/ShipmentField.d.ts +0 -12
  789. package/lib/esm/components/ShipmentField.js +0 -1
  790. package/lib/esm/components/ShipmentsContainer.d.ts +0 -6
  791. package/lib/esm/components/ShipmentsContainer.js +0 -1
  792. package/lib/esm/components/SkuList.d.ts +0 -7
  793. package/lib/esm/components/SkuList.js +0 -1
  794. package/lib/esm/components/SkuListsContainer.d.ts +0 -6
  795. package/lib/esm/components/SkuListsContainer.js +0 -1
  796. package/lib/esm/components/SkuOption.d.ts +0 -7
  797. package/lib/esm/components/SkuOption.js +0 -1
  798. package/lib/esm/components/SkuOptionInput.d.ts +0 -5
  799. package/lib/esm/components/SkuOptionInput.js +0 -1
  800. package/lib/esm/components/SkuOptionsContainer.d.ts +0 -7
  801. package/lib/esm/components/SkuOptionsContainer.js +0 -1
  802. package/lib/esm/components/SubTotalAmount.d.ts +0 -4
  803. package/lib/esm/components/SubTotalAmount.js +0 -1
  804. package/lib/esm/components/TaxesAmount.d.ts +0 -4
  805. package/lib/esm/components/TaxesAmount.js +0 -1
  806. package/lib/esm/components/TotalAmount.d.ts +0 -4
  807. package/lib/esm/components/TotalAmount.js +0 -1
@@ -1 +1 @@
1
- import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import{isEmpty,size,map}from"lodash";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export const createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state==null?void 0:state.orderId)return state.orderId;const sdk=getSdk(config);try{const o=await(sdk==null?void 0:sdk.orders.create(Object.assign({metadata},orderAttributes)));return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o==null?void 0:o.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors(error,"orders");console.error("Create order",errors),dispatch&&setErrors({currentErrors:state==null?void 0:state.errors,newErrors:errors,dispatch})}}return""},getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=getSdk(config);try{const options={};(state==null?void 0:state.include)&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.status==="placed"||order.status==="approved"||order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors(error,"orders");console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state==null?void 0:state.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include}){const sdk=getSdk(config);try{const resource=Object.assign(Object.assign({},attributes),{id}),order=await sdk.orders.update(resource,{include});dispatch&&dispatch({type:"setOrder",payload:{order}})}catch(error){const errors=getErrors(error,"orders");dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}}))}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};newResource?payload.include=[...resourcesIncluded,...typeof newResource=="string"?[newResource]:newResource]:delete payload.include,payload.includeLoaded=Object.assign(Object.assign({},resourceIncludedLoaded),newResourceLoaded),dispatch&&dispatch({type:"setIncludesResource",payload})}export const addToCart=async params=>{const{skuCode,bundleCode,skuId,quantity,option,config,dispatch,lineItem,state,errors=[]}=params;try{const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem==null?void 0:lineItem.name,imageUrl=lineItem==null?void 0:lineItem.imageUrl,attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity||1,_update_quantity:!0,bundle_code:bundleCode};skuId&&(attrs.item=sdk.skus.relationship(skuId));const newLineItem=await sdk.line_items.create(attrs);if(isEmpty(option))await getApiOrder(Object.assign(Object.assign({id},params),{state}));else{let c=0;map(option,async opt=>{const{options,skuOptionId}=opt,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),c+=1,c===size(option)&&await getApiOrder(Object.assign({id},params))})}return!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0}}return{success:!1}}catch(error){const errors2=getErrors(error,"orders");return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state==null?void 0:state.errors,newErrors:errors2,dispatch}),{success:!1}}},unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})},setGiftCardOrCouponCode=async({code,dispatch,config,order})=>{try{if(config&&order&&code&&dispatch){const sdk=getSdk(config),attributes={id:order.id,gift_card_or_coupon_code:code},orderUpdated=await sdk.orders.update(attributes);return dispatch({type:"setErrors",payload:{errors:[],order:orderUpdated}}),{success:!0}}return{success:!1}}catch(error){const errors=getErrors(error,"gift_card_or_coupon_code");return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},removeGiftCardOrCouponCode=async({codeType,dispatch,config,order})=>{try{if(config&&order&&dispatch){const sdk=getSdk(config),attributes={id:order.id,[codeType]:""},orderUpdated=await sdk.orders.update(attributes);return dispatch({type:"setErrors",payload:{errors:[],order:orderUpdated}}),{success:!0}}return{success:!1}}catch(error){const errors=getErrors(error,"gift_card_or_coupon_code");return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},orderInitialState={loading:!1,orderId:"",order:void 0,errors:[]};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
1
+ import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import size from"lodash/size";import map from"lodash/map";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";import getOrganizationSlug from"../utils/organization";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export const createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=getSdk(config);try{const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors(error,"orders");console.error("Create order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""},getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=getSdk(config);try{const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.status==="placed"||order.status==="approved"||order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors(error,"orders");console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=getSdk(config);try{const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await getApiOrder({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0}}catch(error){const errors=getErrors(error,"orders");return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...resourcesIncluded,...resources],resources.forEach(resource=>{payload.includeLoaded={...payload.includeLoaded,[resource]:!0}})}else delete payload.include;payload.includeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded},dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}export const addToCart=async params=>{const{skuCode,bundleCode,skuId,quantity,option,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl}=params;try{if(!config)throw{errors:[{code:"INVALID_RESOURCE",resource:"orders",title:"Markup error",message:"You are trying to place an order outside the OrderContainer component"}]};const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});line_items&&line_items?.length>0&&await Promise.all(line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity||1,_update_quantity:!0,bundle_code:bundleCode};skuId&&(attrs.item=sdk.skus.relationship(skuId));const newLineItem=await sdk.line_items.create(attrs);if(isEmpty(option))await getApiOrder({id,...params,state});else{let c=0;map(option,async opt=>{const{options,skuOptionId}=opt,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),c+=1,c===size(option)&&await getApiOrder({id,...params})})}if(!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=getOrganizationSlug(config.endpoint),params2=`${id}?accessToken=${config.accessToken}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}return{success:!1,orderId:void 0}}catch(error){const errors2=getErrors(error,"orders");return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1,orderId:void 0}}},unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})},setGiftCardOrCouponCode=async({code,codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success}}return{success:!1}}catch(error){const errors=getErrors(error,"orders",codeType);return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},removeGiftCardOrCouponCode=async({codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&dispatch){const attributes={[codeType]:""};return await updateOrder({id:order.id,attributes,config,include,dispatch,state}),dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0}}return{success:!1}}catch(error){const errors=getErrors(error,"orders",codeType);return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
@@ -6,9 +6,51 @@ import { WireTransferConfig } from '../components/WireTransferPayment';
6
6
  import { CommerceLayerConfig } from '../context/CommerceLayerContext';
7
7
  import { getOrderContext, updateOrder } from './OrderReducer';
8
8
  import { BaseError } from '../typings/errors';
9
- import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, BraintreePayment, CheckoutComPayment, ExternalPayment, PaypalPayment } from '@commercelayer/sdk';
9
+ import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, BraintreePayment, CheckoutComPayment, ExternalPayment, PaypalPayment, KlarnaPayment } from '@commercelayer/sdk';
10
10
  import { Dispatch, MutableRefObject } from 'react';
11
+ import { CheckoutComConfig } from '../components/CheckoutComPayment';
11
12
  export declare type PaymentSourceType = AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
13
+ declare type Card = {
14
+ brand: string;
15
+ last4: string;
16
+ exp_year: number;
17
+ exp_month: number;
18
+ };
19
+ export declare type PaymentSourceObject = {
20
+ adyen_payments: AdyenPayment & {
21
+ payment_request_data?: {
22
+ payment_method?: Card;
23
+ };
24
+ payment_response?: {
25
+ resultCode?: 'Authorised';
26
+ };
27
+ };
28
+ braintree_payments: BraintreePayment & {
29
+ options?: {
30
+ card: Card;
31
+ };
32
+ };
33
+ external_payments: ExternalPayment & {
34
+ payment_source_token?: string;
35
+ };
36
+ paypal_payments: PaypalPayment;
37
+ stripe_payments: StripePayment & {
38
+ options?: {
39
+ card: Card;
40
+ };
41
+ };
42
+ wire_transfers: WireTransfer;
43
+ checkout_com_payments: CheckoutComPayment & {
44
+ payment_response: {
45
+ source?: Pick<Card, 'last4'> & {
46
+ scheme: string;
47
+ expiry_year: number;
48
+ expiry_month: number;
49
+ };
50
+ };
51
+ };
52
+ klarna_payments: KlarnaPayment;
53
+ };
12
54
  export declare type PaymentMethodActionType = 'setErrors' | 'setPaymentMethods' | 'setPaymentMethodConfig' | 'setPaymentSource' | 'setPaymentRef' | 'setLoading';
13
55
  export declare type PaymentRef = MutableRefObject<null | HTMLFormElement>;
14
56
  export interface PaymentMethodActionPayload {
@@ -45,9 +87,9 @@ declare type GetPaymentMethods = (args: {
45
87
  dispatch: Dispatch<PaymentMethodAction>;
46
88
  }) => Promise<void>;
47
89
  export declare const getPaymentMethods: GetPaymentMethods;
48
- export declare type PaymentResource = 'adyen_payments' | 'braintree_payments' | 'external_payments' | 'paypal_payments' | 'stripe_payments' | 'wire_transfers';
49
- export declare type PaymentResourceKey = 'braintreePayment' | 'stripePayment' | 'wireTransfer' | 'paypalPayment' | 'adyenPayment';
50
- export declare type SDKPaymentResource = 'AdyenPayment' | 'BraintreePayment' | 'ExternalPayment' | 'PaypalPayment' | 'StripePayment' | 'WireTransfer';
90
+ export declare type PaymentResource = keyof PaymentSourceObject;
91
+ export declare type PaymentResourceKey = 'braintreePayment' | 'stripePayment' | 'klarnaPayment' | 'wireTransfer' | 'paypalPayment' | 'adyenPayment' | 'checkoutComPayment';
92
+ export declare type SDKPaymentResource = 'AdyenPayment' | 'BraintreePayment' | 'ExternalPayment' | 'PaypalPayment' | 'StripePayment' | 'WireTransfer' | 'CheckoutComPayment';
51
93
  export declare type SetPaymentMethod = (args: {
52
94
  config?: CommerceLayerConfig;
53
95
  dispatch?: Dispatch<PaymentMethodAction>;
@@ -69,7 +111,7 @@ export declare type SetPaymentSource = (args: {
69
111
  config?: CommerceLayerConfig;
70
112
  dispatch?: Dispatch<PaymentMethodAction>;
71
113
  getOrder?: getOrderContext;
72
- attributes?: Record<string, string | Record<string, string | number | undefined | Record<string, string>>>;
114
+ attributes?: Record<string, unknown>;
73
115
  order?: Order;
74
116
  paymentResource: PaymentResource;
75
117
  paymentSourceId?: string;
@@ -89,6 +131,8 @@ export declare type DestroyPaymentSource = (args: {
89
131
  paymentSourceId: string;
90
132
  paymentResource: PaymentResource;
91
133
  dispatch?: Dispatch<PaymentMethodAction>;
134
+ updateOrder?: typeof updateOrder;
135
+ orderId?: string;
92
136
  }) => Promise<void>;
93
137
  export declare const destroyPaymentSource: DestroyPaymentSource;
94
138
  export declare type PaymentMethodConfig = {
@@ -97,6 +141,8 @@ export declare type PaymentMethodConfig = {
97
141
  wireTransfer?: Partial<WireTransferConfig>;
98
142
  paypalPayment?: PaypalConfig;
99
143
  adyenPayment?: AdyenPaymentConfig;
144
+ checkoutComPayment?: CheckoutComConfig;
145
+ klarnaPayment?: Pick<AdyenPaymentConfig, 'placeOrderCallback'> & Pick<StripeConfig, 'containerClassName'>;
100
146
  };
101
147
  declare type SetPaymentMethodConfig = (config: PaymentMethodConfig, dispatch: Dispatch<PaymentMethodAction>) => void;
102
148
  export declare const setPaymentMethodConfig: SetPaymentMethodConfig;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import has from"lodash/has";import isEmpty from"lodash/isEmpty";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[]},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod==null?void 0:paymentMethod.id,currentPaymentMethodType:paymentMethod==null?void 0:paymentMethod.payment_source_type,paymentSource}})},setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:getSdk(config).payment_methods.relationship(paymentMethodId)};dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),updateOrder&&await updateOrder({id:order.id,attributes}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=getErrors(error,"orders");console.error("Set payment method",errors)}},setPaymentSource=async({config,dispatch,getOrder,attributes={},order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=getSdk(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs=Object.assign({id:paymentSourceId},attributes);paymentSource=await sdk[paymentResource].update(attrs)}else{const attrs=Object.assign(Object.assign({},attributes),{order:sdk.orders.relationship(order.id)});paymentSource=await sdk[paymentResource].create(attrs)}return dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),getOrder&&await getOrder(order.id),paymentSource}}}catch(error){const errors=getErrors(error,"payment_methods");console.error("Set payment source:",errors),dispatch&&setErrors({currentErrors,newErrors:errors,dispatch})}},updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await getSdk(config)[paymentResource].update(Object.assign({id},attributes));dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}},destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};export function getPaymentConfig(paymentResource,config){const resource=camelCase(paymentResource).replace("Payments","Payment").replace("Transfers","Transfer");return!isEmpty(config)&&has(config,resource)?config[resource]:void 0}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>baseReducer(state,reducer,type);export default paymentMethodReducer;
1
+ import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import has from"lodash/has";import isEmpty from"lodash/isEmpty";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[]},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})},setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:getSdk(config).payment_methods.relationship(paymentMethodId)};updateOrder&&await updateOrder({id:order.id,attributes}),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=getErrors(error,"orders",paymentResource);console.error("Set payment method",errors)}},setPaymentSource=async({config,dispatch,getOrder,attributes={},order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=getSdk(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=await sdk[paymentResource].update(attrs)}else{const attrs={...attributes,order:sdk.orders.relationship(order.id)};paymentSource=await sdk[paymentResource].create(attrs)}return getOrder&&await getOrder(order.id),dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),paymentSource}}}catch(error){const errors=getErrors(error,"payment_methods",paymentResource);console.error("Set payment source:",errors),dispatch&&setErrors({currentErrors,newErrors:errors,dispatch})}},updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await getSdk(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}},destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};export function getPaymentConfig(paymentResource,config){const resource=camelCase(paymentResource).replace("Payments","Payment").replace("Transfers","Transfer");return!isEmpty(config)&&has(config,resource)?config[resource]:void 0}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>baseReducer(state,reducer,type);export default paymentMethodReducer;
@@ -11,6 +11,9 @@ export declare type PlaceOrderOptions = {
11
11
  MD: string;
12
12
  PaRes: string;
13
13
  };
14
+ checkoutCom?: {
15
+ session_id: string;
16
+ };
14
17
  };
15
18
  export interface PlaceOrderActionPayload {
16
19
  errors: BaseError[];
@@ -42,8 +45,12 @@ export declare type SetPlaceOrder = (args: {
42
45
  config?: CommerceLayerConfig;
43
46
  order?: Order;
44
47
  state?: PlaceOrderState;
45
- setOrderErrors?: (collection: any) => void;
46
- paymentSource?: Record<string, string>;
48
+ setOrderErrors?: (errors: BaseError[]) => void;
49
+ paymentSource?: PaymentSourceType & {
50
+ approval_url?: string;
51
+ };
52
+ include?: string[];
53
+ setOrder?: (order: Order) => void;
47
54
  }) => Promise<{
48
55
  placed: boolean;
49
56
  }>;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import{shipmentsFilled}from"../utils/shipments";import{saveBillingAddress,saveShippingAddress,saveToWallet}from"../utils/customerOrderOptions";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const placeOrderInitialState={errors:[],isPermitted:!1},setPlaceOrderErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},placeOrderPermitted=async({config,order,dispatch,options})=>{var _a;if(order&&config){let isPermitted=!0;order.privacy_url&&order.terms_url&&(isPermitted=localStorage.getItem("privacy-terms")==="true");const billingAddress=order.billing_address;isEmpty(billingAddress)&&(isPermitted=!1);const shippingAddress=order.shipping_address;isEmpty(shippingAddress)&&(isPermitted=!1);const shipments=order.shipments,shipment=shipments&&shipmentsFilled(shipments);!isEmpty(shipments)&&!shipment&&(isPermitted=!1);const paymentMethod=order.payment_method,paymentSource=order.payment_source;order.total_amount_with_taxes_cents!==0&&isEmpty(paymentMethod==null?void 0:paymentMethod.id)&&(isPermitted=!1),dispatch({type:"setPlaceOrderPermitted",payload:{isPermitted,paymentType:paymentMethod==null?void 0:paymentMethod.payment_source_type,paymentSecret:paymentSource==null?void 0:paymentSource.client_secret,paymentId:(_a=paymentSource==null?void 0:paymentSource.options)===null||_a===void 0?void 0:_a.id,paymentSource,options}})}},setPlaceOrder=async({state,order,config,setOrderErrors,paymentSource})=>{const response={placed:!1};try{if(state&&order&&config){const sdk=getSdk(config),{options,paymentType}=state;if(paymentType==="paypal_payments"&&paymentSource){if(!(options==null?void 0:options.paypalPayerId)&&(paymentSource==null?void 0:paymentSource.approval_url))return window.location.href=paymentSource==null?void 0:paymentSource.approval_url,response;await sdk.paypal_payments.update({id:paymentSource.id,paypal_payer_id:options==null?void 0:options.paypalPayerId})}const updateAttributes={id:order.id,_place:!0};switch(saveBillingAddress()&&await sdk.orders.update({id:order.id,_save_billing_address_to_customer_address_book:!0}),saveShippingAddress()&&await sdk.orders.update({id:order.id,_save_shipping_address_to_customer_address_book:!0}),paymentType){case"braintree_payments":return saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0}),await sdk.orders.update(updateAttributes),setOrderErrors&&setOrderErrors([]),{placed:!0};default:return await sdk.orders.update(updateAttributes),saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0}),setOrderErrors&&setOrderErrors([]),{placed:!0}}}return response}catch(error){const errors=getErrors(error,"orders");return setOrderErrors&&setOrderErrors(errors),Object.assign(Object.assign({},response),{errors})}};const type=["setErrors","setPlaceOrderPermitted"],placeOrderReducer=(state,reducer)=>baseReducer(state,reducer,type);export default placeOrderReducer;
1
+ import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import{isDoNotShip,shipmentsFilled}from"../utils/shipments";import{saveBillingAddress,saveShippingAddress,saveToWallet}from"../utils/customerOrderOptions";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const placeOrderInitialState={errors:[],isPermitted:!1},setPlaceOrderErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},placeOrderPermitted=async({config,order,dispatch,options})=>{if(order&&config){let isPermitted=!0;order.privacy_url&&order.terms_url&&(isPermitted=localStorage.getItem("privacy-terms")==="true");const billingAddress=order.billing_address,shippingAddress=order.shipping_address,doNotShip=isDoNotShip(order.line_items),shipments=order.shipments,shipment=shipments&&shipmentsFilled(shipments),paymentMethod=order.payment_method,paymentSource=order.payment_source;order.total_amount_with_taxes_cents!==0&&isEmpty(paymentMethod?.id)&&(isPermitted=!1),isEmpty(billingAddress)&&(isPermitted=!1),isEmpty(shippingAddress)&&!doNotShip&&(isPermitted=!1),!isEmpty(shipments)&&!shipment&&(isPermitted=!1),paymentSource?.mismatched_amounts&&(isPermitted=!1),dispatch({type:"setPlaceOrderPermitted",payload:{isPermitted,paymentType:paymentMethod?.payment_source_type,paymentSecret:paymentSource?.client_secret,paymentId:paymentSource?.options?.id,paymentSource,options}})}},setPlaceOrder=async({state,order,config,setOrderErrors,paymentSource,setOrder,include})=>{const response={placed:!1};if(state&&config&&order){const sdk=getSdk(config),{options,paymentType}=state;try{if(paymentType==="paypal_payments"&&paymentSource){if(!options?.paypalPayerId&&paymentSource?.approval_url)return window.location.href=paymentSource?.approval_url,response;await sdk[paymentType].update({id:paymentSource.id,paypal_payer_id:options?.paypalPayerId})}if(paymentType==="checkout_com_payments"&&paymentSource&&options?.checkoutCom?.session_id){const payment=await sdk[paymentType].update({id:paymentSource.id,_details:!0,session_id:options?.checkoutCom?.session_id});if(payment?.payment_response?.status!=="Authorized"){const[action]=payment?.payment_response?.actions||[""];throw{errors:[{code:"PAYMENT_NOT_APPROVED_FOR_EXECUTION",message:action?.response_summary,resource:"orders",field:"checkout_com_payments"}]}}}const updateAttributes={id:order.id,_place:!0};switch(saveBillingAddress()&&await sdk.orders.update({id:order.id,_save_billing_address_to_customer_address_book:!0}),saveShippingAddress()&&await sdk.orders.update({id:order.id,_save_shipping_address_to_customer_address_book:!0}),paymentType){case"braintree_payments":{saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0});const orderUpdated=await sdk.orders.update(updateAttributes,{include});return setOrder&&setOrder(orderUpdated),setOrderErrors&&setOrderErrors([]),{placed:!0}}default:{const orderUpdated=await sdk.orders.update(updateAttributes,{include});return setOrder&&setOrder(orderUpdated),saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0}),setOrderErrors&&setOrderErrors([]),{placed:!0}}}}catch(error){const errors=getErrors(error,"orders",paymentType);return setOrderErrors&&setOrderErrors(errors),{...response,errors}}}return response};const type=["setErrors","setPlaceOrderPermitted"],placeOrderReducer=(state,reducer)=>baseReducer(state,reducer,type);export default placeOrderReducer;
@@ -1 +1 @@
1
- import getPrices from"../utils/getPrices";import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]},getSkusPrice=(skuCodes,{config,dispatch,setPrices,prices,perPage,filters})=>{let allPrices={};const sdk=getSdk(config);sdk.prices.list({filters:Object.assign({sku_code_in:skuCodes.join(",")},filters),pageSize:perPage}).then(async response=>{const pricesObj=getPrices(response);allPrices=Object.assign(Object.assign(Object.assign({},allPrices),prices),pricesObj),setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}}),dispatch({type:"setLoading",payload:{loading:!1}});const meta=response.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const pageResponse=await sdk.prices.list({filters:Object.assign({sku_code_in:skuCodes.join(",")},filters),pageSize:perPage,pageNumber}),pricesObj2=getPrices(pageResponse);allPrices=Object.assign(Object.assign({},allPrices),pricesObj2),setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=getErrors(error,"prices");dispatch({type:"setErrors",payload:{errors}})})},unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default priceReducer;
1
+ import getPrices from"../utils/getPrices";import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]},getSkusPrice=(skuCodes,{config,dispatch,setPrices,prices,perPage,filters})=>{let allPrices={};const sdk=getSdk(config);sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage}).then(async response=>{const pricesObj=getPrices(response);allPrices={...allPrices,...prices,...pricesObj},setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}}),dispatch({type:"setLoading",payload:{loading:!1}});const meta=response.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const pageResponse=await sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage,pageNumber}),pricesObj2=getPrices(pageResponse);allPrices={...allPrices,...pricesObj2},setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=getErrors(error,"prices");dispatch({type:"setErrors",payload:{errors}})})},unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default priceReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments,deliveryLeadTimes=await sdk.delivery_lead_times.list({include:["shipping_method","stock_location"]});dispatch({type:"setShipments",payload:{shipments,deliveryLeadTimes}})}catch(error){console.error(error)}},setShippingMethod=async({config,shipmentId,shippingMethodId,getOrder,order})=>{try{if(shippingMethodId){const sdk=getSdk(config);await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder&&order&&getOrder(order.id)}}catch(error){console.error(error)}};const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shipmentReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments,deliveryLeadTimes=await sdk.delivery_lead_times.list({include:["shipping_method","stock_location"]});dispatch({type:"setShipments",payload:{shipments,deliveryLeadTimes}})}catch(error){console.error(error)}},setShippingMethod=async({config,shipmentId,shippingMethodId,getOrder,order})=>{try{if(shippingMethodId){const sdk=getSdk(config);await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder&&order&&await getOrder(order.id)}}catch(error){console.error(error)}};const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shipmentReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shippingAddressInitialState={_shipping_address_clone_id:""},setShippingAddress=async(id,options)=>{try{if(options==null?void 0:options.order){if(options.customerAddressId){const sdk=getSdk(options.config),attributes={id,reference:options.customerAddressId};await sdk.addresses.update(attributes)}options.dispatch({type:"setShippingAddress",payload:{_shipping_address_clone_id:id}})}}catch(error){console.error(error)}},setShippingCustomerAddressId=async({dispatch,order,setCloneAddress})=>{var _a;const customerAddressId=(_a=order==null?void 0:order.shipping_address)===null||_a===void 0?void 0:_a.reference;try{customerAddressId&&(dispatch({type:"setShippingCustomerAddressId",payload:{shippingCustomerAddressId:customerAddressId}}),setCloneAddress(customerAddressId,"shipping_address"))}catch(error){console.error("error",error)}};const type=["setShippingAddress","setShippingCustomerAddressId","cleanup"],shippingAddressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shippingAddressReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shippingAddressInitialState={_shipping_address_clone_id:""},setShippingAddress=async(id,options)=>{try{if(options?.order){if(options.customerAddressId){const sdk=getSdk(options.config),attributes={id,reference:options.customerAddressId};await sdk.addresses.update(attributes)}options.dispatch({type:"setShippingAddress",payload:{_shipping_address_clone_id:id}})}}catch(error){console.error(error)}},setShippingCustomerAddressId=async({dispatch,order,setCloneAddress})=>{const customerAddressId=order?.shipping_address?.reference;try{customerAddressId&&(dispatch({type:"setShippingCustomerAddressId",payload:{shippingCustomerAddressId:customerAddressId}}),setCloneAddress(customerAddressId,"shipping_address"))}catch(error){console.error("error",error)}};const type=["setShippingAddress","setShippingCustomerAddressId","cleanup"],shippingAddressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shippingAddressReducer;
@@ -0,0 +1,21 @@
1
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
2
+ import { BaseAction } from '../typings/index';
3
+ import { QueryParamsList, Sku } from '@commercelayer/sdk';
4
+ import { Dispatch } from 'react';
5
+ declare type SkuActionType = 'getSkus' | 'setLoading';
6
+ declare type SkuAction = BaseAction<SkuActionType, SkuState>;
7
+ export declare type SkuState = Partial<{
8
+ skus: Sku[];
9
+ loading: boolean;
10
+ skuCodes: string[];
11
+ }>;
12
+ export declare const skuInitialState: SkuState;
13
+ declare type GetSku = {
14
+ config: CommerceLayerConfig;
15
+ skus: string[];
16
+ dispatch: Dispatch<SkuAction>;
17
+ queryParams?: QueryParamsList;
18
+ };
19
+ export declare function getSku<T extends GetSku>({ config, skus, dispatch, queryParams, }: T): Promise<void>;
20
+ export default function skuReducer(state: SkuState, reducer: SkuAction): SkuState;
21
+ export {};
@@ -0,0 +1 @@
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";const actionType=["getSkus"];export const skuInitialState={skus:[],loading:!0,skuCodes:[]};export async function getSku({config,skus,dispatch,queryParams}){if(!config.accessToken||skus.length===0)return;const sdk=getSdk(config);let allSkus=[];const get=await sdk.skus.list({...queryParams,filters:{...queryParams?.filters,code_in:skus.join(",")}});allSkus=[...get];const meta=get.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const getPage=await sdk.skus.list({...queryParams,filters:{...queryParams?.filters,code_in:skus.join(",")},pageNumber});allSkus=[...allSkus,...getPage]}dispatch({type:"getSkus",payload:{skus:allSkus,loading:!1,skuCodes:skus}})}export default function skuReducer(state,reducer){return baseReducer(state,reducer,actionType)}
@@ -10,6 +10,7 @@ declare type SetSkuCodeVariantParams = {
10
10
  config: CommerceLayerConfig;
11
11
  dispatch: Dispatch<VariantAction>;
12
12
  setItem: ((item: Items) => void) | undefined;
13
+ setItemSkuCode?: ((skuCode: string) => void) | undefined;
13
14
  };
14
15
  export interface SetSkuCodeVariant {
15
16
  (params: SetSkuCodeVariantParams): void;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSkus from"../utils/getSkus";import{isEmpty,has}from"lodash";import getSdk from"../utils/getSdk";export const setVariantSkuCodes=({skuCodes,dispatch,setCustomLineItems})=>{const lineItems={},sCodes=skuCodes.map(s=>(has(s,"lineItem")&&(lineItems[s.code]=s.lineItem),s.code));isEmpty(lineItems)||setCustomLineItems&&setCustomLineItems(lineItems),dispatch({type:"setSkuCodes",payload:{skuCodes:sCodes}})},setSkuCode=params=>{const{id,code,config,setItem,dispatch}=params;id&&getSdk(config).skus.retrieve(id,{include:["sku_options"]}).then(sku=>{setItem&&setItem({[`${code}`]:sku})}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},getVariants=params=>{const{config,state,skuCode,dispatch,setItem,filters}=params;getSdk(config).skus.list({filters:Object.assign({code_in:state.skuCodes.join(",")},filters)}).then(skus=>{const skusObj=getSkus(skus,state.skuCodes);skuCode&&setSkuCode({code:skusObj[skuCode].code,id:skusObj[skuCode].id,config,dispatch,setItem}),dispatch({type:"setVariants",payload:{variants:skusObj}}),dispatch({type:"setLoading",payload:{loading:!1}})}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},unsetVariantState=dispatch=>{dispatch({type:"setSkuCode",payload:{skuCode:""}}),dispatch({type:"setVariants",payload:{variants:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})},variantInitialState={loading:!1,variants:{},skuCodes:[],skuCode:"",errors:[],currentSkuId:"",currentSkuInventory:{available:!1,quantity:0,levels:[]},currentQuantity:1,currentPrices:[]};const actionType=["setLoading","setVariants","setSkuCodes","setSkuCode","setCurrentSkuId","setCurrentSkuInventory","setCurrentPrices","setErrors"],variantReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default variantReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSkus from"../utils/getSkus";import{isEmpty,has}from"lodash";import getSdk from"../utils/getSdk";export const setVariantSkuCodes=({skuCodes,dispatch,setCustomLineItems})=>{const lineItems={},sCodes=skuCodes.map(s=>(has(s,"lineItem")&&(lineItems[s.code]=s.lineItem),s.code));isEmpty(lineItems)||setCustomLineItems&&setCustomLineItems(lineItems),dispatch({type:"setSkuCodes",payload:{skuCodes:sCodes}})},setSkuCode=params=>{const{id,code,config,setItem,dispatch,setItemSkuCode}=params;id&&getSdk(config).skus.retrieve(id,{include:["sku_options"]}).then(sku=>{setItem&&setItem({[`${code}`]:sku}),setItemSkuCode&&setItemSkuCode(code)}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},getVariants=params=>{const{config,state,skuCode,dispatch,setItem,filters}=params;getSdk(config).skus.list({filters:{code_in:state.skuCodes.join(","),...filters}}).then(skus=>{const skusObj=getSkus(skus,state.skuCodes);skuCode&&setSkuCode({code:skusObj[skuCode].code,id:skusObj[skuCode].id,config,dispatch,setItem}),dispatch({type:"setVariants",payload:{variants:skusObj}}),dispatch({type:"setLoading",payload:{loading:!1}})}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},unsetVariantState=dispatch=>{dispatch({type:"setSkuCode",payload:{skuCode:""}}),dispatch({type:"setVariants",payload:{variants:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})},variantInitialState={loading:!1,variants:{},skuCodes:[],skuCode:"",errors:[],currentSkuId:"",currentSkuInventory:{available:!1,quantity:0,levels:[]},currentQuantity:1,currentPrices:[]};const actionType=["setLoading","setVariants","setSkuCodes","setSkuCode","setCurrentSkuId","setCurrentSkuInventory","setCurrentPrices","setErrors"],variantReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default variantReducer;
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import { FunctionChildren } from './index';
3
- export declare type CodeErrorType = 'EMPTY_ERROR' | 'FILTER_NOT_ALLOWED' | 'FORBIDDEN' | 'INTERNAL_SERVER_ERROR' | 'INVALID_DATA_FORMAT' | 'INVALID_FIELD' | 'INVALID_FIELD_FORMAT' | 'INVALID_FIELD_VALUE' | 'INVALID_FILTERS_SYNTAX' | 'INVALID_FILTER_VALUE' | 'INVALID_INCLUDE' | 'INVALID_LINKS_OBJECT' | 'INVALID_PAGE_OBJECT' | 'INVALID_PAGE_VALUE' | 'INVALID_RESOURCE' | 'INVALID_RESOURCE_ID' | 'INVALID_SORT_CRITERIA' | 'INVALID_TOKEN' | 'KEY_NOT_INCLUDED_IN_URL' | 'KEY_ORDER_MISMATCH' | 'LOCKED' | 'NOT_ACCEPTABLE' | 'PARAM_MISSING' | 'PARAM_NOT_ALLOWED' | 'PAYMENT_NOT_APPROVED_FOR_EXECUTION' | 'PAYMENT_INTENT_AUTHENTICATION_FAILURE' | 'RECORD_NOT_FOUND' | 'RECORD_NOT_FOUND' | 'RELATION_EXISTS' | 'SAVE_FAILED' | 'TYPE_MISMATCH' | 'UNAUTHORIZED' | 'UNSUPPORTED_MEDIA_TYPE' | 'VALIDATION_ERROR';
4
- export declare type ResourceErrorType = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipping_address' | 'sku_options' | 'variant';
3
+ export declare type CodeErrorType = 'EMPTY_ERROR' | 'FILTER_NOT_ALLOWED' | 'FORBIDDEN' | 'INTERNAL_SERVER_ERROR' | 'INVALID_DATA_FORMAT' | 'INVALID_FIELD' | 'INVALID_FIELD_FORMAT' | 'INVALID_FIELD_VALUE' | 'INVALID_FILTERS_SYNTAX' | 'INVALID_FILTER_VALUE' | 'INVALID_INCLUDE' | 'INVALID_LINKS_OBJECT' | 'INVALID_PAGE_OBJECT' | 'INVALID_PAGE_VALUE' | 'INVALID_RESOURCE' | 'INVALID_RESOURCE_ID' | 'INVALID_SORT_CRITERIA' | 'INVALID_TOKEN' | 'KEY_NOT_INCLUDED_IN_URL' | 'KEY_ORDER_MISMATCH' | 'LOCKED' | 'NOT_ACCEPTABLE' | 'OUT_OF_STOCK' | 'PARAM_MISSING' | 'PARAM_NOT_ALLOWED' | 'PAYMENT_NOT_APPROVED_FOR_EXECUTION' | 'PAYMENT_INTENT_AUTHENTICATION_FAILURE' | 'RECORD_NOT_FOUND' | 'RECORD_NOT_FOUND' | 'RELATION_EXISTS' | 'NO_SHIPPING_METHODS' | 'SAVE_FAILED' | 'TYPE_MISMATCH' | 'UNAUTHORIZED' | 'UNSUPPORTED_MEDIA_TYPE' | 'VALIDATION_ERROR';
4
+ export declare type ResourceErrorType = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipments' | 'shipping_address' | 'customer_address' | 'sku_options' | 'variant';
5
5
  export interface BaseError {
6
6
  code: CodeErrorType;
7
7
  message: string;
@@ -27,10 +27,19 @@ export declare const ErrorPropTypes: {
27
27
  declare type ErrorChildrenComponentProps = FunctionChildren<Omit<ErrorComponentProps, 'children'> & {
28
28
  errors: string[];
29
29
  }>;
30
- export interface ErrorComponentProps {
30
+ export declare type ErrorComponentProps = {
31
+ /**
32
+ * Resource which caused the error
33
+ */
31
34
  resource: ResourceErrorType;
32
35
  children?: ErrorChildrenComponentProps;
36
+ /**
37
+ * Field which caused the error
38
+ */
33
39
  field?: string;
40
+ /**
41
+ * Error message which you can translate
42
+ */
34
43
  messages?: {
35
44
  code: CodeErrorType;
36
45
  message: string;
@@ -38,5 +47,5 @@ export interface ErrorComponentProps {
38
47
  field?: string;
39
48
  id?: string;
40
49
  }[];
41
- }
50
+ };
42
51
  export {};
@@ -1 +1 @@
1
- import PropTypes from"prop-types";const CEType=["EMPTY_ERROR","FILTER_NOT_ALLOWED","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_DATA_FORMAT","INVALID_FIELD","INVALID_FIELD_FORMAT","INVALID_FIELD_VALUE","INVALID_FILTERS_SYNTAX","INVALID_FILTER_VALUE","INVALID_INCLUDE","INVALID_LINKS_OBJECT","INVALID_PAGE_OBJECT","INVALID_PAGE_VALUE","INVALID_RESOURCE","INVALID_RESOURCE_ID","INVALID_SORT_CRITERIA","INVALID_TOKEN","KEY_NOT_INCLUDED_IN_URL","KEY_ORDER_MISMATCH","LOCKED","NOT_ACCEPTABLE","PARAM_MISSING","PARAM_NOT_ALLOWED","RECORD_NOT_FOUND","RECORD_NOT_FOUND","RELATION_EXISTS","SAVE_FAILED","TYPE_MISMATCH","UNAUTHORIZED","UNSUPPORTED_MEDIA_TYPE","VALIDATION_ERROR"];export const REType=["gift_cards","line_items","orders","prices","sku_options","variant"],BaseErrorObject=PropTypes.shape({code:PropTypes.oneOf(CEType).isRequired,message:PropTypes.string.isRequired,resource:PropTypes.oneOf(REType),field:PropTypes.string,id:PropTypes.string}),ErrorPropTypes={resource:PropTypes.oneOf(["billing_address","gift_cards","line_items","orders","payment_methods","prices","shipping_address","sku_options","variant"]).isRequired,children:PropTypes.func,field:PropTypes.string};
1
+ import PropTypes from"prop-types";const CEType=["EMPTY_ERROR","FILTER_NOT_ALLOWED","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_DATA_FORMAT","INVALID_FIELD","INVALID_FIELD_FORMAT","INVALID_FIELD_VALUE","INVALID_FILTERS_SYNTAX","INVALID_FILTER_VALUE","INVALID_INCLUDE","INVALID_LINKS_OBJECT","INVALID_PAGE_OBJECT","INVALID_PAGE_VALUE","INVALID_RESOURCE","INVALID_RESOURCE_ID","INVALID_SORT_CRITERIA","INVALID_TOKEN","KEY_NOT_INCLUDED_IN_URL","KEY_ORDER_MISMATCH","LOCKED","NOT_ACCEPTABLE","PARAM_MISSING","PARAM_NOT_ALLOWED","RECORD_NOT_FOUND","RECORD_NOT_FOUND","RELATION_EXISTS","SAVE_FAILED","TYPE_MISMATCH","UNAUTHORIZED","UNSUPPORTED_MEDIA_TYPE","VALIDATION_ERROR"];export const REType=["gift_cards","line_items","orders","prices","sku_options","variant"],BaseErrorObject=PropTypes.shape({code:PropTypes.oneOf(CEType).isRequired,message:PropTypes.string.isRequired,resource:PropTypes.oneOf(REType),field:PropTypes.string,id:PropTypes.string}),ErrorPropTypes={resource:PropTypes.oneOf(["billing_address","gift_cards","line_items","orders","payment_methods","prices","shipping_address","customer_address","sku_options","variant","shipments"]).isRequired,children:PropTypes.func,field:PropTypes.string};
@@ -1,4 +1,4 @@
1
- import { Dispatch, ReactNode, RefObject } from 'react';
1
+ import { Dispatch, ForwardedRef, ReactNode, Ref } from 'react';
2
2
  import PropTypes, { InferProps } from 'prop-types';
3
3
  import { BaseError } from './errors';
4
4
  export declare const BC: {
@@ -37,6 +37,7 @@ export interface BaseSelectComponentProps {
37
37
  className?: string;
38
38
  required?: boolean;
39
39
  name: string;
40
+ onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
40
41
  }
41
42
  export declare const BaseInputComponentPropTypes: {
42
43
  children: PropTypes.Requireable<(...args: any[]) => any>;
@@ -47,9 +48,10 @@ export declare const BaseInputComponentPropTypes: {
47
48
  };
48
49
  declare type BaseInputChildrenComponentProps = Omit<BaseInputComponentProps, 'children'> & {
49
50
  handleChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
51
+ parentRef: ForwardedRef<any>;
50
52
  };
51
53
  export interface BaseInputComponentProps {
52
- ref?: () => RefObject<any>;
54
+ ref?: Ref<any>;
53
55
  children?: (props: BaseInputChildrenComponentProps) => ReactNode;
54
56
  name: string;
55
57
  onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
@@ -57,9 +59,9 @@ export interface BaseInputComponentProps {
57
59
  }
58
60
  export declare type LineItemType = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
59
61
  export declare type GiftCardInputName = 'balanceCents' | 'balanceMaxCents' | 'singleUse' | 'rechargeable' | 'imageUrl' | 'expiresAt' | 'referenceOrigin' | 'email' | 'firstName' | 'lastName' | 'reference';
60
- export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
61
- export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code';
62
- export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code';
62
+ export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'customer_address_city' | 'customer_address_company' | 'customer_address_first_name' | 'customer_address_email' | 'customer_address_last_name' | 'customer_address_line_1' | 'customer_address_line_2' | 'customer_address_phone' | 'customer_address_state_code' | 'customer_address_zip_code' | 'customer_address_billing_info' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
63
+ export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code' | 'customer_address_country_code';
64
+ export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code' | 'customer_address_state_code';
63
65
  export declare type BaseInputType = 'checkbox' | 'date' | 'email' | 'number' | 'tel' | 'text' | 'textarea';
64
66
  export declare type LoaderType = string | ReactNode;
65
67
  export declare const BMObject: PropTypes.Requireable<{
@@ -70,9 +72,9 @@ export declare type BaseMetadataObject = {
70
72
  };
71
73
  export declare type TimeFormat = 'days' | 'hours';
72
74
  export declare type BaseComponent = InferProps<typeof BC>;
73
- export interface BaseAction<A = string> {
75
+ export interface BaseAction<A = string, P = Record<string, any>> {
74
76
  type: A;
75
- payload: Record<string, any>;
77
+ payload: P;
76
78
  }
77
79
  export interface BaseState {
78
80
  [key: string]: any;
@@ -123,4 +125,13 @@ export declare type BaseAmountComponent = {
123
125
  export interface FunctionChildren<P = Record<string, any>> {
124
126
  (props: P): ReactNode;
125
127
  }
128
+ export declare type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JSX.IntrinsicElements, T>;
129
+ export declare type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
130
+ export declare type ConditionalElement<E> = ({
131
+ attribute: Extract<keyof E, 'image_url'>;
132
+ tagElement: ExtractTag<'img'>;
133
+ } & JSX.IntrinsicElements['img']) | ({
134
+ attribute: Exclude<keyof E, 'image_url'>;
135
+ tagElement: ExcludeTag<'img'>;
136
+ } & JSX.IntrinsicElements[ExcludeTag<'img'>]);
126
137
  export {};
@@ -1 +1 @@
1
- import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},BaseInputComponentPropTypes={children:PropTypes.func,name:PropTypes.string.isRequired,type:PropTypes.oneOf(["text","email","number","date","checkbox","textarea"]).isRequired,onChange:PropTypes.func,placeholder:PropTypes.string},BMObject=PropTypes.objectOf(PropTypes.string),baseOrderPricePropTypes=Object.assign({base:PropTypes.string.isRequired,type:PropTypes.string.isRequired,children:PropTypes.func,format:PropTypes.oneOf(["formatted","cents","float"])},BC),baseOrderComponentPricePropTypes=Object.assign({children:baseOrderPricePropTypes.children,format:baseOrderPricePropTypes.format},BC);
1
+ import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},BaseInputComponentPropTypes={children:PropTypes.func,name:PropTypes.string.isRequired,type:PropTypes.oneOf(["text","email","number","date","checkbox","textarea"]).isRequired,onChange:PropTypes.func,placeholder:PropTypes.string},BMObject=PropTypes.objectOf(PropTypes.string),baseOrderPricePropTypes={base:PropTypes.string.isRequired,type:PropTypes.string.isRequired,children:PropTypes.func,format:PropTypes.oneOf(["formatted","cents","float"]),...BC},baseOrderComponentPricePropTypes={children:baseOrderPricePropTypes.children,format:baseOrderPricePropTypes.format,...BC};
@@ -8,7 +8,7 @@ declare type BillingAddressController = (params: {
8
8
  }) => boolean;
9
9
  export declare const billingAddressController: BillingAddressController;
10
10
  declare type ShippingAddressController = (params: {
11
- billingDisable: boolean;
11
+ billingDisable?: boolean;
12
12
  errors?: BaseError[];
13
13
  shipToDifferentAddress?: boolean;
14
14
  shipping_address?: AddressCreate;
@@ -1 +1 @@
1
- import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses==null?void 0:addresses.find(a=>(a.id===billingAddressId||a.reference===billingAddressId)&&a.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}if(countryCodeLock&&!isEmpty(billing_address)&&!shipToDifferentAddress)return(billing_address==null?void 0:billing_address.country_code)!==countryCodeLock;if(countryCodeLock&&!isEmpty(shipping_address)&&shipToDifferentAddress)return(shipping_address==null?void 0:shipping_address.country_code)!==countryCodeLock;if(countryCodeLock&&!isEmpty(addresses)&&shippingAddressId&&shipToDifferentAddress){const addressLocked=addresses==null?void 0:addresses.find(a=>(a.id===shippingAddressId||a.reference===shippingAddressId)&&a.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}return!1};
1
+ import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo=!1})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===billingAddressId||a?.reference===billingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}if(countryCodeLock&&!isEmpty(billing_address)&&!shipToDifferentAddress)return billing_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(shipping_address)&&shipToDifferentAddress)return shipping_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(addresses)&&shippingAddressId&&shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===shippingAddressId||a?.reference===shippingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}return!1};
@@ -1 +1 @@
1
- const baseReducer=(state,action,actionTypes)=>{if(actionTypes.indexOf(action.type)!==-1){const data=action.payload;state=Object.assign(Object.assign({},state),data)}return state};export default baseReducer;
1
+ const baseReducer=(state,action,actionTypes)=>{if(actionTypes.indexOf(action.type)!==-1){const data=action.payload;state={...state,...data}}return state};export default baseReducer;
@@ -0,0 +1,8 @@
1
+ import { ResourceIncluded } from '../reducers/OrderReducer';
2
+ import type { Order } from '@commercelayer/sdk';
3
+ declare type Params = {
4
+ order: Order;
5
+ resourceInclude: ResourceIncluded[];
6
+ };
7
+ export default function checkIncludeResources({ order, resourceInclude, }: Params): boolean;
8
+ export {};
@@ -0,0 +1 @@
1
+ export default function checkIncludeResources({order,resourceInclude}){const checkKeys=[];return resourceInclude.forEach(v=>{if(v.includes(".")){const[first]=v.split(".");order?.[first]===void 0&&checkKeys.push(!1)}else order?.[v]===void 0&&checkKeys.push(!1)}),checkKeys.length===0}
@@ -5,5 +5,5 @@ export interface CheckChildrenTypes {
5
5
  [key: string]: any;
6
6
  }, propName: string, componentName: string, location: string, propFullName: string): Error | null;
7
7
  }
8
- declare const _default: Requireable<ReactNode>;
8
+ declare const _default: Requireable<ReactNode | (() => ReactNode)>;
9
9
  export default _default;
@@ -1 +1 @@
1
- import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(props,propName,componentName)=>{let error=null;const children=props[propName],cpName=componentName.replace("CL","");return(isEmpty(children)&&typeof children!="function"||typeof children=="function"&&!children)&&props.isRequired&&(error=new Error(`The prop '${propName}' is marked as required in '${cpName}', but its value is '${children}'.`)),Children.map(children,c=>{if(error)return error;const type=c.type,itemTypes=get(components,`${cpName}.permittedChildren`),errorMsg=`Invalid prop '${propName}' supplied to ${cpName}. Only components ${itemTypes.join(", ")} are allowed.`;if(isFunction(type)&&has(type,"displayName")){const displayName=get(type,"displayName"),childComponentName=type.name;displayName&&displayName===`${childComponentName}`&&(itemTypes.includes(childComponentName)||(error=new Error(errorMsg)))}isValidElement(c)||(error=new Error(errorMsg))}),error},childrenTypes=checkChildrenTypes;childrenTypes.isRequired=(props,propName,componentName,location,propFullName)=>checkChildrenTypes(Object.assign(Object.assign({},props),{isRequired:!0}),propName,componentName,location,propFullName);export default childrenTypes;
1
+ import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(props,propName,componentName)=>{let error=null;const children=props[propName],cpName=componentName.replace("CL","");return(isEmpty(children)&&typeof children!="function"||typeof children=="function"&&!children)&&props.isRequired&&(error=new Error(`The prop '${propName}' is marked as required in '${cpName}', but its value is '${children}'.`)),Children.map(children,c=>{if(error)return error;const type=c?.type,itemTypes=get(components,`${cpName}.permittedChildren`),errorMsg=`Invalid prop '${propName}' supplied to ${cpName}. Only components ${itemTypes.join(", ")} are allowed.`;if(isFunction(type)&&has(type,"displayName")){const displayName=get(type,"displayName"),childComponentName=type.name;displayName&&displayName===`${childComponentName}`&&(itemTypes.includes(childComponentName)||(error=new Error(errorMsg)))}!isValidElement(c)&&c!==null&&(error=new Error(errorMsg))}),error},childrenTypes=checkChildrenTypes;childrenTypes.isRequired=(props,propName,componentName,location,propFullName)=>checkChildrenTypes({...props,isRequired:!0},propName,componentName,location,propFullName);export default childrenTypes;
@@ -0,0 +1,7 @@
1
+ declare type Item = Record<string, any>;
2
+ declare type TArgs<A, B> = {
3
+ attributes: A;
4
+ object: B;
5
+ };
6
+ export default function compareObjAttribute<A extends Item, B extends Item>({ attributes, object, }: TArgs<A, B>): Item;
7
+ export {};
@@ -0,0 +1 @@
1
+ function sortObj(obj){return Object.keys(obj).sort().reduce((result,key)=>(result[key]=obj[key],result),{})}export default function compareObjAttribute({attributes,object}){const returnObj={};return Object.keys(object).forEach(v=>{const element=attributes[v],compare=object[v];if(typeof element=="object"&&element){const elementSorted=sortObj(element),compareSorted=sortObj(compare);JSON.stringify(elementSorted)!==JSON.stringify(compareSorted)&&(returnObj[v]=element)}typeof element!="object"&&element&&element!==compare&&(returnObj[v]=element)}),returnObj}
@@ -1,8 +1,2 @@
1
1
  import { BaseError } from '../typings/errors';
2
- export interface CustomMessages {
3
- (messages: BaseError[], v: BaseError): {
4
- message?: string;
5
- } | null;
6
- }
7
- declare const customMessages: CustomMessages;
8
- export default customMessages;
2
+ export default function customMessages(messages: BaseError[] | undefined, v: BaseError): BaseError | null;
@@ -1 +1 @@
1
- import findIndex from"lodash/findIndex";import pick from"lodash/pick";const customMessages=(messages=[],v)=>{const i=findIndex(messages,pick(v,["field","code","resource"]));return i!==-1?messages[i]:null};export default customMessages;
1
+ import findIndex from"lodash/findIndex";import pick from"lodash/pick";export default function customMessages(messages=[],v){const i=findIndex(messages,pick(v,["field","code","resource"]));return i!==-1?messages[i]:null}
@@ -0,0 +1,15 @@
1
+ import { IconBrand } from '../context/PaymentSourceContext';
2
+ import { PaymentResource } from '../reducers/PaymentMethodReducer';
3
+ import { CustomerPaymentSource } from '@commercelayer/sdk';
4
+ declare type CardDetails = {
5
+ brand: IconBrand | string;
6
+ last4: string;
7
+ exp_month: number | string;
8
+ exp_year: number | string;
9
+ };
10
+ declare type Args = {
11
+ paymentType: PaymentResource;
12
+ customerPayment: Partial<CustomerPaymentSource>;
13
+ };
14
+ export default function getCardDetails({ paymentType, customerPayment, }: Args): CardDetails;
15
+ export {};
@@ -0,0 +1 @@
1
+ export default function getCardDetails({paymentType,customerPayment}){switch(paymentType){case"checkout_com_payments":{const source=customerPayment.payment_source?.payment_response?.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":case"braintree_payments":{const source=customerPayment.payment_source?.options?.card;if(source)return{...source};break}case"adyen_payments":{const ps=customerPayment.payment_source,source=ps?.payment_request_data?.payment_method,authorized=ps?.payment_response?.resultCode==="Authorised";if(source&&authorized)return{...source,brand:source?.brand?source.brand:"credit-card"};break}default:{const source=customerPayment.payment_source?.metadata?.card;if(source)return{...source};break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****"}}
@@ -0,0 +1,7 @@
1
+ declare type TArgs = {
2
+ orderId: string;
3
+ accessToken: string;
4
+ slug: string;
5
+ };
6
+ export default function getCartLink({ orderId, accessToken, slug }: TArgs): string;
7
+ export {};
@@ -0,0 +1 @@
1
+ export default function getCartLink({orderId,accessToken,slug}){const env=process.env.NODE_ENV==="production"?"":"stg.";return`${slug}.${env}commercelayer.app/cart/${orderId}?accessToken=${accessToken}`}
@@ -1 +1 @@
1
- import{first,keys}from"lodash";const getCurrentItemKey=item=>first(keys(item))||"";export default getCurrentItemKey;
1
+ import first from"lodash/first";import keys from"lodash/keys";const getCurrentItemKey=item=>first(keys(item))||"";export default getCurrentItemKey;
@@ -1,6 +1,6 @@
1
1
  import { BaseError, ResourceErrorType } from '../typings/errors';
2
2
  import { Dispatch } from 'react';
3
- export default function getErrors(error: any, resource: ResourceErrorType): BaseError[];
3
+ export default function getErrors(error: any, resource: ResourceErrorType, field?: string): BaseError[];
4
4
  declare type SetErrorsArgs<D> = {
5
5
  currentErrors?: BaseError[];
6
6
  newErrors?: BaseError[];
@@ -1 +1 @@
1
- import differenceBy from"lodash/differenceBy";export default function getErrors(error,resource){var _a;return(_a=error==null?void 0:error.errors)===null||_a===void 0?void 0:_a.map(e=>Object.assign(Object.assign({},e),{resource}))}export function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=differenceBy(currentErrors,newErrors,filterBy),mergeErrors=(currentErrors==null?void 0:currentErrors.length)===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];if(!dispatch)return errors;dispatch({type:"setErrors",payload:{errors}})}
1
+ import differenceBy from"lodash/differenceBy";export default function getErrors(error,resource,field){return error?.errors?.map(e=>({...e,resource,...field&&{field}}))}export function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=differenceBy(currentErrors,newErrors,filterBy),mergeErrors=currentErrors?.length===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];if(!dispatch)return errors;dispatch({type:"setErrors",payload:{errors}})}
@@ -1,12 +1,10 @@
1
- import { LineItem } from '@commercelayer/sdk';
1
+ import type { LineItem } from '@commercelayer/sdk';
2
2
  import { LineItemType } from '../typings/index';
3
- export interface GetLineItemsCountInterface {
4
- (args: {
5
- lineItems: LineItem[];
6
- quantity?: number;
7
- typeAccepted?: TypeAccepted[];
8
- }): number;
9
- }
10
3
  export declare type TypeAccepted = Extract<LineItemType, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
11
- declare const getLineItemsCount: GetLineItemsCountInterface;
12
- export default getLineItemsCount;
4
+ declare type Args = {
5
+ lineItems: LineItem[];
6
+ quantity?: number;
7
+ typeAccepted?: TypeAccepted[];
8
+ };
9
+ export default function getLineItemsCount({ lineItems, quantity, typeAccepted, }: Args): number;
10
+ export {};
@@ -1 +1 @@
1
- const getLineItemsCount=({lineItems,quantity=0,typeAccepted=["skus","gift_cards","bundles","adjustments"]})=>(lineItems.filter(l=>l.item_type&&typeAccepted.includes(l.item_type)).forEach(l=>{l.quantity&&(quantity+=l.quantity)}),quantity);export default getLineItemsCount;
1
+ export default function getLineItemsCount({lineItems,quantity=0,typeAccepted=["skus","gift_cards","bundles","adjustments"]}){return lineItems.filter(l=>typeAccepted.includes(l.item_type)&&l?.total_amount_cents!==void 0&&l.total_amount_cents>=0).forEach(l=>{l.quantity&&(quantity+=l.quantity)}),quantity}
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(Loader){return typeof Loader=="function"?_jsx(Loader,{},void 0):_jsx(_Fragment,{children:Loader},void 0)}
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(Loader){return typeof Loader=="function"?_jsx(Loader,{}):_jsx(_Fragment,{children:Loader})}
@@ -1 +1 @@
1
- import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(skuPrices,code="")=>code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices),getPricesComponent=(skuPrices,props)=>isEmpty(skuPrices)?_jsx(PriceTemplate,Object.assign({},props),void 0):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare=="undefined"&&(p==null?void 0:p.compare_at_amount_cents)>(p==null?void 0:p.amount_cents)||props.showCompare;return _createElement(PriceTemplate,Object.assign({},props,{key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount}))});export default function getPrices(prices){const obj={};return isArray(prices)&&prices.forEach(p=>{const sku=p.sku_code;has(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}
1
+ import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(skuPrices,code="")=>code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices),getPricesComponent=(skuPrices,props)=>isEmpty(skuPrices)?_jsx(PriceTemplate,{...props}):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return _createElement(PriceTemplate,{...props,key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount})});export default function getPrices(prices){const obj={};return isArray(prices)&&prices.forEach(p=>{const sku=p.sku_code;has(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}
@@ -1 +1 @@
1
- import getOrganizationSlug from"./organization";import Sdk from"@commercelayer/sdk";export default function getSdk({endpoint,accessToken}){const org=getOrganizationSlug(endpoint);return Sdk(Object.assign({accessToken},org))}
1
+ import getOrganizationSlug from"./organization";import Sdk from"@commercelayer/sdk";export default function getSdk({endpoint,accessToken}){const org=getOrganizationSlug(endpoint);return Sdk({accessToken,...org})}