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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +3 -3
  3. package/lib/components/AdyenPayment.d.ts +3 -3
  4. package/lib/components/AdyenPayment.js +1 -1
  5. package/lib/components/AvailabilityContainer.d.ts +10 -3
  6. package/lib/components/AvailabilityContainer.js +1 -1
  7. package/lib/components/AvailabilityTemplate.d.ts +13 -4
  8. package/lib/components/AvailabilityTemplate.js +1 -1
  9. package/lib/components/BillingAddressContainer.d.ts +7 -2
  10. package/lib/components/BillingAddressContainer.js +1 -1
  11. package/lib/components/BillingAddressForm.d.ts +8 -3
  12. package/lib/components/BillingAddressForm.js +1 -1
  13. package/lib/components/BraintreePayment.d.ts +3 -3
  14. package/lib/components/BraintreePayment.js +1 -1
  15. package/lib/components/CheckoutComPayment.d.ts +23 -0
  16. package/lib/components/CheckoutComPayment.js +1 -0
  17. package/lib/components/CheckoutLink.d.ts +16 -4
  18. package/lib/components/CheckoutLink.js +1 -1
  19. package/lib/components/DeliveryLeadTime.d.ts +11 -4
  20. package/lib/components/DeliveryLeadTime.js +1 -1
  21. package/lib/components/DiscountAmount.d.ts +16 -2
  22. package/lib/components/DiscountAmount.js +1 -1
  23. package/lib/components/Errors.d.ts +4 -4
  24. package/lib/components/Errors.js +1 -1
  25. package/lib/components/ExternalFunction.d.ts +9 -2
  26. package/lib/components/ExternalFunction.js +1 -1
  27. package/lib/components/GiftCard.d.ts +13 -3
  28. package/lib/components/GiftCard.js +1 -1
  29. package/lib/components/GiftCardContainer.d.ts +9 -3
  30. package/lib/components/GiftCardContainer.js +1 -1
  31. package/lib/components/GiftCardCurrencySelector.d.ts +18 -3
  32. package/lib/components/GiftCardCurrencySelector.js +1 -1
  33. package/lib/components/GiftCardInput.d.ts +12 -3
  34. package/lib/components/GiftCardInput.js +1 -1
  35. package/lib/components/GiftCardOrCouponCode.d.ts +17 -6
  36. package/lib/components/GiftCardOrCouponCode.js +1 -1
  37. package/lib/components/GiftCardOrCouponForm.d.ts +9 -4
  38. package/lib/components/GiftCardOrCouponForm.js +1 -1
  39. package/lib/components/GiftCardOrCouponInput.d.ts +14 -3
  40. package/lib/components/GiftCardOrCouponInput.js +1 -1
  41. package/lib/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
  42. package/lib/components/GiftCardOrCouponRemoveButton.js +1 -1
  43. package/lib/components/GiftCardOrCouponSubmit.d.ts +11 -4
  44. package/lib/components/GiftCardOrCouponSubmit.js +1 -1
  45. package/lib/components/ItemContainer.d.ts +14 -3
  46. package/lib/components/ItemContainer.js +1 -1
  47. package/lib/components/KlarnaPayment.d.ts +10 -0
  48. package/lib/components/KlarnaPayment.js +1 -0
  49. package/lib/components/LineItem.d.ts +10 -3
  50. package/lib/components/LineItem.js +1 -1
  51. package/lib/components/LineItemAmount.d.ts +16 -3
  52. package/lib/components/LineItemAmount.js +1 -1
  53. package/lib/components/LineItemCode.d.ts +10 -4
  54. package/lib/components/LineItemCode.js +1 -1
  55. package/lib/components/LineItemImage.d.ts +11 -4
  56. package/lib/components/LineItemImage.js +1 -1
  57. package/lib/components/LineItemName.d.ts +11 -5
  58. package/lib/components/LineItemName.js +1 -1
  59. package/lib/components/LineItemOption.d.ts +15 -4
  60. package/lib/components/LineItemOption.js +1 -1
  61. package/lib/components/LineItemOptions.d.ts +8 -3
  62. package/lib/components/LineItemOptions.js +1 -1
  63. package/lib/components/LineItemQuantity.d.ts +16 -4
  64. package/lib/components/LineItemQuantity.js +1 -1
  65. package/lib/components/LineItemRemoveLink.d.ts +15 -5
  66. package/lib/components/LineItemRemoveLink.js +1 -1
  67. package/lib/components/LineItemsContainer.d.ts +15 -3
  68. package/lib/components/LineItemsContainer.js +1 -1
  69. package/lib/components/LineItemsCount.d.ts +14 -4
  70. package/lib/components/LineItemsCount.js +1 -1
  71. package/lib/components/LineItemsEmpty.d.ts +13 -2
  72. package/lib/components/LineItemsEmpty.js +1 -1
  73. package/lib/components/MetadataInput.d.ts +13 -3
  74. package/lib/components/MetadataInput.js +1 -1
  75. package/lib/components/PaymentGateway.d.ts +4 -4
  76. package/lib/components/PaymentGateway.js +1 -1
  77. package/lib/components/PaymentMethod.d.ts +9 -3
  78. package/lib/components/PaymentMethod.js +1 -1
  79. package/lib/components/PaymentMethodAmount.d.ts +16 -2
  80. package/lib/components/PaymentMethodAmount.js +1 -1
  81. package/lib/components/PaymentMethodName.d.ts +10 -4
  82. package/lib/components/PaymentMethodName.js +1 -1
  83. package/lib/components/PaymentMethodPrice.d.ts +15 -4
  84. package/lib/components/PaymentMethodPrice.js +1 -1
  85. package/lib/components/PaymentMethodRadioButton.d.ts +11 -4
  86. package/lib/components/PaymentMethodRadioButton.js +1 -1
  87. package/lib/components/PaymentMethodsContainer.d.ts +9 -3
  88. package/lib/components/PaymentMethodsContainer.js +1 -1
  89. package/lib/components/PaymentSource.d.ts +9 -2
  90. package/lib/components/PaymentSource.js +1 -1
  91. package/lib/components/PaymentSourceBrandIcon.d.ts +14 -4
  92. package/lib/components/PaymentSourceBrandIcon.js +1 -1
  93. package/lib/components/PaymentSourceBrandName.d.ts +11 -4
  94. package/lib/components/PaymentSourceBrandName.js +1 -1
  95. package/lib/components/PaymentSourceDetail.d.ts +8 -2
  96. package/lib/components/PaymentSourceDetail.js +1 -1
  97. package/lib/components/PaymentSourceEditButton.d.ts +9 -2
  98. package/lib/components/PaymentSourceEditButton.js +1 -1
  99. package/lib/components/PaypalPayment.d.ts +2 -2
  100. package/lib/components/PaypalPayment.js +1 -1
  101. package/lib/components/Price.d.ts +15 -3
  102. package/lib/components/Price.js +1 -1
  103. package/lib/components/PricesContainer.d.ts +19 -3
  104. package/lib/components/PricesContainer.js +1 -1
  105. package/lib/components/QuantitySelector.d.ts +19 -5
  106. package/lib/components/QuantitySelector.js +1 -1
  107. package/lib/components/SaveAddressesButton.d.ts +18 -5
  108. package/lib/components/SaveAddressesButton.js +1 -1
  109. package/lib/components/SaveCustomerButton.d.ts +16 -5
  110. package/lib/components/SaveCustomerButton.js +1 -1
  111. package/lib/components/Shipment.d.ts +9 -2
  112. package/lib/components/Shipment.js +1 -1
  113. package/lib/components/ShipmentField.d.ts +11 -4
  114. package/lib/components/ShipmentField.js +1 -1
  115. package/lib/components/ShipmentsContainer.d.ts +9 -3
  116. package/lib/components/ShipmentsContainer.js +1 -1
  117. package/lib/components/ShippingAddressContainer.d.ts +7 -2
  118. package/lib/components/ShippingAddressContainer.js +1 -1
  119. package/lib/components/ShippingAddressForm.d.ts +8 -3
  120. package/lib/components/ShippingAddressForm.js +1 -1
  121. package/lib/components/ShippingAmount.d.ts +13 -2
  122. package/lib/components/ShippingAmount.js +1 -1
  123. package/lib/components/ShippingMethod.d.ts +10 -3
  124. package/lib/components/ShippingMethod.js +1 -1
  125. package/lib/components/ShippingMethodName.d.ts +11 -5
  126. package/lib/components/ShippingMethodName.js +1 -1
  127. package/lib/components/ShippingMethodPrice.d.ts +15 -3
  128. package/lib/components/ShippingMethodPrice.js +1 -1
  129. package/lib/components/ShippingMethodRadioButton.d.ts +11 -5
  130. package/lib/components/ShippingMethodRadioButton.js +1 -1
  131. package/lib/components/StockTransfer.d.ts +9 -3
  132. package/lib/components/StockTransfer.js +1 -1
  133. package/lib/components/StockTransferField.d.ts +9 -8
  134. package/lib/components/StockTransferField.js +1 -1
  135. package/lib/components/StripePayment.d.ts +3 -3
  136. package/lib/components/StripePayment.js +1 -1
  137. package/lib/components/SubmitButton.d.ts +15 -5
  138. package/lib/components/SubmitButton.js +1 -1
  139. package/lib/components/VariantSelector.d.ts +28 -5
  140. package/lib/components/VariantSelector.js +1 -1
  141. package/lib/components/VariantsContainer.d.ts +15 -3
  142. package/lib/components/VariantsContainer.js +1 -1
  143. package/lib/components/WireTransferPayment.d.ts +2 -2
  144. package/lib/components/WireTransferPayment.js +1 -1
  145. package/lib/components/addresses/Address.d.ts +18 -0
  146. package/lib/components/addresses/Address.js +1 -0
  147. package/lib/components/addresses/AddressCountrySelector.d.ts +26 -0
  148. package/lib/components/addresses/AddressCountrySelector.js +1 -0
  149. package/lib/components/addresses/AddressField.d.ts +43 -0
  150. package/lib/components/addresses/AddressField.js +1 -0
  151. package/lib/components/addresses/AddressInput.d.ts +19 -0
  152. package/lib/components/addresses/AddressInput.js +1 -0
  153. package/lib/components/addresses/AddressStateSelector.d.ts +27 -0
  154. package/lib/components/addresses/AddressStateSelector.js +1 -0
  155. package/lib/components/addresses/AddressesContainer.d.ts +15 -0
  156. package/lib/components/addresses/AddressesContainer.js +1 -0
  157. package/lib/components/auth/CommerceLayer.d.ts +15 -0
  158. package/lib/components/auth/CommerceLayer.js +1 -0
  159. package/lib/components/customers/CustomerAddressForm.d.ts +13 -0
  160. package/lib/components/customers/CustomerAddressForm.js +1 -0
  161. package/lib/components/customers/CustomerContainer.d.ts +17 -0
  162. package/lib/components/customers/CustomerContainer.js +1 -0
  163. package/lib/components/customers/CustomerField.d.ts +10 -0
  164. package/lib/components/customers/CustomerField.js +1 -0
  165. package/lib/components/customers/CustomerInput.d.ts +23 -0
  166. package/lib/components/customers/CustomerInput.js +1 -0
  167. package/lib/components/gateways/AdyenGateway.d.ts +2 -2
  168. package/lib/components/gateways/AdyenGateway.js +1 -1
  169. package/lib/components/gateways/BraintreeGateway.d.ts +2 -2
  170. package/lib/components/gateways/BraintreeGateway.js +1 -1
  171. package/lib/components/gateways/CheckoutComGateway.d.ts +5 -0
  172. package/lib/components/gateways/CheckoutComGateway.js +1 -0
  173. package/lib/components/gateways/KlarnaGateway.d.ts +5 -0
  174. package/lib/components/gateways/KlarnaGateway.js +1 -0
  175. package/lib/components/gateways/PaypalGateway.d.ts +3 -3
  176. package/lib/components/gateways/PaypalGateway.js +1 -1
  177. package/lib/components/gateways/StripeGateway.d.ts +2 -2
  178. package/lib/components/gateways/StripeGateway.js +1 -1
  179. package/lib/components/gateways/WireTransferGateway.d.ts +2 -2
  180. package/lib/components/gateways/WireTransferGateway.js +1 -1
  181. package/lib/components/orders/AddToCartButton.d.ts +34 -0
  182. package/lib/components/orders/AddToCartButton.js +1 -0
  183. package/lib/components/orders/AdjustmentAmount.d.ts +18 -0
  184. package/lib/components/orders/AdjustmentAmount.js +1 -0
  185. package/lib/components/orders/CartLink.d.ts +12 -0
  186. package/lib/components/orders/CartLink.js +1 -0
  187. package/lib/components/orders/GiftCardAmount.d.ts +15 -0
  188. package/lib/components/orders/GiftCardAmount.js +1 -0
  189. package/lib/components/orders/OrderContainer.d.ts +26 -0
  190. package/lib/components/orders/OrderContainer.js +1 -0
  191. package/lib/components/orders/OrderList.d.ts +61 -0
  192. package/lib/components/orders/OrderList.js +1 -0
  193. package/lib/components/orders/OrderListRow.d.ts +30 -0
  194. package/lib/components/orders/OrderListRow.js +1 -0
  195. package/lib/components/orders/OrderNumber.d.ts +11 -0
  196. package/lib/components/orders/OrderNumber.js +1 -0
  197. package/lib/components/orders/OrderStorage.d.ts +16 -0
  198. package/lib/components/orders/OrderStorage.js +1 -0
  199. package/lib/components/orders/PlaceOrderButton.d.ts +24 -0
  200. package/lib/components/orders/PlaceOrderButton.js +1 -0
  201. package/lib/components/orders/PlaceOrderContainer.d.ts +14 -0
  202. package/lib/components/orders/PlaceOrderContainer.js +1 -0
  203. package/lib/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
  204. package/lib/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  205. package/lib/components/orders/SubTotalAmount.d.ts +18 -0
  206. package/lib/components/orders/SubTotalAmount.js +1 -0
  207. package/lib/components/orders/TaxesAmount.d.ts +18 -0
  208. package/lib/components/orders/TaxesAmount.js +1 -0
  209. package/lib/components/orders/TotalAmount.d.ts +18 -0
  210. package/lib/components/orders/TotalAmount.js +1 -0
  211. package/lib/components/skus/SkuField.d.ts +14 -0
  212. package/lib/components/skus/SkuField.js +1 -0
  213. package/lib/components/skus/SkuList.d.ts +14 -0
  214. package/lib/components/skus/SkuList.js +1 -0
  215. package/lib/components/skus/SkuListsContainer.d.ts +12 -0
  216. package/lib/components/skus/SkuListsContainer.js +1 -0
  217. package/lib/components/skus/SkuOption.d.ts +14 -0
  218. package/lib/components/skus/SkuOption.js +1 -0
  219. package/lib/components/skus/SkuOptionInput.d.ts +15 -0
  220. package/lib/components/skus/SkuOptionInput.js +1 -0
  221. package/lib/components/skus/SkuOptionsContainer.d.ts +14 -0
  222. package/lib/components/skus/SkuOptionsContainer.js +1 -0
  223. package/lib/components/skus/Skus.d.ts +11 -0
  224. package/lib/components/skus/Skus.js +1 -0
  225. package/lib/components/skus/SkusContainer.d.ts +23 -0
  226. package/lib/components/skus/SkusContainer.js +1 -0
  227. package/lib/components/utils/AddressCardsTemplate.d.ts +1 -1
  228. package/lib/components/utils/AddressCardsTemplate.js +1 -1
  229. package/lib/components/utils/BaseField.js +1 -1
  230. package/lib/components/utils/BaseInput.d.ts +1 -1
  231. package/lib/components/utils/BaseInput.js +1 -1
  232. package/lib/components/utils/BaseOrderPrice.js +1 -1
  233. package/lib/components/utils/BaseSelect.js +1 -1
  234. package/lib/components/utils/GenericFieldComponent.d.ts +42 -0
  235. package/lib/components/utils/GenericFieldComponent.js +1 -0
  236. package/lib/components/utils/Parent.d.ts +3 -5
  237. package/lib/components/utils/Parent.js +1 -1
  238. package/lib/components/utils/PaymentCardsTemplate.d.ts +2 -2
  239. package/lib/components/utils/PaymentCardsTemplate.js +1 -1
  240. package/lib/components/utils/PriceTemplate.d.ts +2 -2
  241. package/lib/components/utils/PriceTemplate.js +1 -1
  242. package/lib/components/utils/VariantTemplate.js +1 -1
  243. package/lib/components/utils/getAllErrors.js +1 -1
  244. package/lib/config/components.d.ts +77 -35
  245. package/lib/config/components.js +1 -1
  246. package/lib/context/AddressChildrenContext.d.ts +1 -1
  247. package/lib/context/AddressChildrenContext.js +1 -1
  248. package/lib/context/AddressContext.d.ts +1 -1
  249. package/lib/context/BillingAddressContext.d.ts +2 -4
  250. package/lib/context/BillingAddressContext.js +1 -1
  251. package/lib/context/BillingAddressFormContext.d.ts +17 -10
  252. package/lib/context/CouponAndGiftCardFormContext.d.ts +2 -0
  253. package/lib/context/CustomerAddressFormContext.d.ts +20 -0
  254. package/lib/context/CustomerAddressFormContext.js +1 -0
  255. package/lib/context/CustomerContext.d.ts +17 -11
  256. package/lib/context/CustomerContext.js +1 -1
  257. package/lib/context/OrderContext.d.ts +8 -4
  258. package/lib/context/OrderContext.js +1 -1
  259. package/lib/context/OrderListChildrenContext.d.ts +60 -0
  260. package/lib/context/OrderListChildrenContext.js +1 -0
  261. package/lib/context/PaymentSourceContext.d.ts +4 -4
  262. package/lib/context/PlaceOrderContext.d.ts +4 -2
  263. package/lib/context/ShippingAddressContext.d.ts +1 -1
  264. package/lib/context/SkuChildrenContext.d.ts +9 -0
  265. package/lib/context/SkuChildrenContext.js +1 -0
  266. package/lib/context/SkuContext.d.ts +9 -0
  267. package/lib/context/SkuContext.js +1 -0
  268. package/lib/index.d.ts +101 -90
  269. package/lib/index.js +1 -1
  270. package/lib/reducers/AddressReducer.d.ts +4 -2
  271. package/lib/reducers/AddressReducer.js +1 -1
  272. package/lib/reducers/AvailabilityReducer.d.ts +8 -0
  273. package/lib/reducers/AvailabilityReducer.js +1 -1
  274. package/lib/reducers/BillingAddressReducer.js +1 -1
  275. package/lib/reducers/CustomerReducer.d.ts +98 -17
  276. package/lib/reducers/CustomerReducer.js +1 -1
  277. package/lib/reducers/GiftCardReducer.js +1 -1
  278. package/lib/reducers/LineItemReducer.js +1 -1
  279. package/lib/reducers/OrderReducer.d.ts +24 -8
  280. package/lib/reducers/OrderReducer.js +1 -1
  281. package/lib/reducers/PaymentMethodReducer.d.ts +51 -5
  282. package/lib/reducers/PaymentMethodReducer.js +1 -1
  283. package/lib/reducers/PlaceOrderReducer.d.ts +9 -2
  284. package/lib/reducers/PlaceOrderReducer.js +1 -1
  285. package/lib/reducers/ShipmentReducer.js +1 -1
  286. package/lib/reducers/ShippingAddressReducer.js +1 -1
  287. package/lib/reducers/SkuReducer.d.ts +21 -0
  288. package/lib/reducers/SkuReducer.js +1 -0
  289. package/lib/reducers/VariantReducer.d.ts +1 -0
  290. package/lib/reducers/VariantReducer.js +1 -1
  291. package/lib/typings/errors.d.ts +13 -4
  292. package/lib/typings/errors.js +1 -1
  293. package/lib/typings/index.d.ts +17 -6
  294. package/lib/utils/addressesManager.d.ts +1 -1
  295. package/lib/utils/addressesManager.js +1 -1
  296. package/lib/utils/checkIncludeResource.d.ts +8 -0
  297. package/lib/utils/checkIncludeResource.js +1 -0
  298. package/lib/utils/childrenTypes.d.ts +1 -1
  299. package/lib/utils/childrenTypes.js +1 -1
  300. package/lib/utils/compareObjAttribute.d.ts +7 -0
  301. package/lib/utils/compareObjAttribute.js +1 -0
  302. package/lib/utils/customMessages.d.ts +1 -7
  303. package/lib/utils/customMessages.js +1 -1
  304. package/lib/utils/getCardDetails.d.ts +15 -0
  305. package/lib/utils/getCardDetails.js +1 -0
  306. package/lib/utils/getCartLink.d.ts +7 -0
  307. package/lib/utils/getCartLink.js +1 -0
  308. package/lib/utils/getCurrentItemKey.js +1 -1
  309. package/lib/utils/getErrors.d.ts +1 -1
  310. package/lib/utils/getErrors.js +1 -1
  311. package/lib/utils/getLineItemsCount.d.ts +8 -10
  312. package/lib/utils/getLineItemsCount.js +1 -1
  313. package/lib/utils/getLoaderComponent.js +1 -1
  314. package/lib/utils/getPrices.js +1 -1
  315. package/lib/utils/getSkus.js +1 -1
  316. package/lib/utils/hooks/useExternalScript.d.ts +1 -0
  317. package/lib/utils/hooks/useExternalScript.js +1 -0
  318. package/lib/utils/icons.d.ts +3 -0
  319. package/lib/utils/icons.js +1 -0
  320. package/lib/utils/isDate.d.ts +1 -0
  321. package/lib/utils/isDate.js +1 -0
  322. package/lib/utils/jwt.d.ts +1 -1
  323. package/lib/utils/placeholderImages.d.ts +2 -0
  324. package/lib/utils/placeholderImages.js +1 -0
  325. package/lib/utils/promisify.js +1 -1
  326. package/lib/utils/scrollbarWidth.d.ts +1 -0
  327. package/lib/utils/scrollbarWidth.js +1 -0
  328. package/lib/utils/shipments.d.ts +2 -1
  329. package/lib/utils/shipments.js +1 -1
  330. package/lib/utils/validateFormFields.d.ts +2 -0
  331. package/lib/utils/validateFormFields.js +1 -1
  332. package/package.json +96 -93
  333. package/lib/components/AddToCartButton.d.ts +0 -20
  334. package/lib/components/AddToCartButton.js +0 -1
  335. package/lib/components/Address.d.ts +0 -13
  336. package/lib/components/Address.js +0 -1
  337. package/lib/components/AddressCountrySelector.d.ts +0 -9
  338. package/lib/components/AddressCountrySelector.js +0 -1
  339. package/lib/components/AddressField.d.ts +0 -15
  340. package/lib/components/AddressField.js +0 -1
  341. package/lib/components/AddressInput.d.ts +0 -7
  342. package/lib/components/AddressInput.js +0 -1
  343. package/lib/components/AddressStateSelector.d.ts +0 -11
  344. package/lib/components/AddressStateSelector.js +0 -1
  345. package/lib/components/AddressesContainer.d.ts +0 -7
  346. package/lib/components/AddressesContainer.js +0 -1
  347. package/lib/components/AdjustmentAmount.d.ts +0 -4
  348. package/lib/components/AdjustmentAmount.js +0 -1
  349. package/lib/components/CommerceLayer.d.ts +0 -8
  350. package/lib/components/CommerceLayer.js +0 -1
  351. package/lib/components/CustomerContainer.d.ts +0 -7
  352. package/lib/components/CustomerContainer.js +0 -1
  353. package/lib/components/CustomerInput.d.ts +0 -11
  354. package/lib/components/CustomerInput.js +0 -1
  355. package/lib/components/GiftCardAmount.d.ts +0 -4
  356. package/lib/components/GiftCardAmount.js +0 -1
  357. package/lib/components/OrderContainer.d.ts +0 -11
  358. package/lib/components/OrderContainer.js +0 -1
  359. package/lib/components/OrderNumber.d.ts +0 -5
  360. package/lib/components/OrderNumber.js +0 -1
  361. package/lib/components/OrderStorage.d.ts +0 -8
  362. package/lib/components/OrderStorage.js +0 -1
  363. package/lib/components/PlaceOrderButton.d.ts +0 -12
  364. package/lib/components/PlaceOrderButton.js +0 -1
  365. package/lib/components/PlaceOrderContainer.d.ts +0 -8
  366. package/lib/components/PlaceOrderContainer.js +0 -1
  367. package/lib/components/PrivacyAndTermsCheckbox.d.ts +0 -4
  368. package/lib/components/PrivacyAndTermsCheckbox.js +0 -1
  369. package/lib/components/SkuList.d.ts +0 -7
  370. package/lib/components/SkuList.js +0 -1
  371. package/lib/components/SkuListsContainer.d.ts +0 -6
  372. package/lib/components/SkuListsContainer.js +0 -1
  373. package/lib/components/SkuOption.d.ts +0 -7
  374. package/lib/components/SkuOption.js +0 -1
  375. package/lib/components/SkuOptionInput.d.ts +0 -5
  376. package/lib/components/SkuOptionInput.js +0 -1
  377. package/lib/components/SkuOptionsContainer.d.ts +0 -7
  378. package/lib/components/SkuOptionsContainer.js +0 -1
  379. package/lib/components/SubTotalAmount.d.ts +0 -4
  380. package/lib/components/SubTotalAmount.js +0 -1
  381. package/lib/components/TaxesAmount.d.ts +0 -4
  382. package/lib/components/TaxesAmount.js +0 -1
  383. package/lib/components/TotalAmount.d.ts +0 -4
  384. package/lib/components/TotalAmount.js +0 -1
@@ -1,4 +1,4 @@
1
- import { Dispatch, ReactNode, RefObject } from 'react';
1
+ import { Dispatch, ForwardedRef, ReactNode, RefObject } from 'react';
2
2
  import PropTypes, { InferProps } from 'prop-types';
3
3
  import { BaseError } from './errors';
4
4
  export declare const BC: {
@@ -37,6 +37,7 @@ export interface BaseSelectComponentProps {
37
37
  className?: string;
38
38
  required?: boolean;
39
39
  name: string;
40
+ onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
40
41
  }
41
42
  export declare const BaseInputComponentPropTypes: {
42
43
  children: PropTypes.Requireable<(...args: any[]) => any>;
@@ -47,6 +48,7 @@ export declare const BaseInputComponentPropTypes: {
47
48
  };
48
49
  declare type BaseInputChildrenComponentProps = Omit<BaseInputComponentProps, 'children'> & {
49
50
  handleChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
51
+ parentRef: ForwardedRef<any>;
50
52
  };
51
53
  export interface BaseInputComponentProps {
52
54
  ref?: () => RefObject<any>;
@@ -57,9 +59,9 @@ export interface BaseInputComponentProps {
57
59
  }
58
60
  export declare type LineItemType = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
59
61
  export declare type GiftCardInputName = 'balanceCents' | 'balanceMaxCents' | 'singleUse' | 'rechargeable' | 'imageUrl' | 'expiresAt' | 'referenceOrigin' | 'email' | 'firstName' | 'lastName' | 'reference';
60
- export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
61
- export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code';
62
- export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code';
62
+ export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'customer_address_city' | 'customer_address_company' | 'customer_address_first_name' | 'customer_address_email' | 'customer_address_last_name' | 'customer_address_line_1' | 'customer_address_line_2' | 'customer_address_phone' | 'customer_address_state_code' | 'customer_address_zip_code' | 'customer_address_billing_info' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
63
+ export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code' | 'customer_address_country_code';
64
+ export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code' | 'customer_address_state_code';
63
65
  export declare type BaseInputType = 'checkbox' | 'date' | 'email' | 'number' | 'tel' | 'text' | 'textarea';
64
66
  export declare type LoaderType = string | ReactNode;
65
67
  export declare const BMObject: PropTypes.Requireable<{
@@ -70,9 +72,9 @@ export declare type BaseMetadataObject = {
70
72
  };
71
73
  export declare type TimeFormat = 'days' | 'hours';
72
74
  export declare type BaseComponent = InferProps<typeof BC>;
73
- export interface BaseAction<A = string> {
75
+ export interface BaseAction<A = string, P = Record<string, any>> {
74
76
  type: A;
75
- payload: 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 {};
@@ -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};
@@ -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(Object.assign(Object.assign({},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 | undefined;
@@ -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}){var _a,_b,_c,_d,_e;switch(paymentType){case"checkout_com_payments":{const ps=customerPayment.payment_source,source=(_a=ps?.payment_response)===null||_a===void 0?void 0:_a.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":case"braintree_payments":{const ps=customerPayment.payment_source,source=(_b=ps?.options)===null||_b===void 0?void 0:_b.card;if(source)return Object.assign({},source);break}case"adyen_payments":{const ps=customerPayment.payment_source,source=(_c=ps?.payment_request_data)===null||_c===void 0?void 0:_c.payment_method,authorized=((_d=ps?.payment_response)===null||_d===void 0?void 0:_d.resultCode)==="Authorised";if(source&&authorized)return Object.assign(Object.assign({},source),{brand:source?.brand?source.brand:"credit-card"});break}default:{const ps=customerPayment.payment_source,source=(_e=ps?.metadata)===null||_e===void 0?void 0:_e.card;if(source)return Object.assign({},source);break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****"}}
@@ -0,0 +1,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){var _a;return(_a=error?.errors)===null||_a===void 0?void 0:_a.map(e=>Object.assign(Object.assign(Object.assign({},e),{resource}),field&&{field}))}export function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=differenceBy(currentErrors,newErrors,filterBy),mergeErrors=currentErrors?.length===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];if(!dispatch)return errors;dispatch({type:"setErrors",payload:{errors}})}
@@ -1,12 +1,10 @@
1
- import { LineItem } from '@commercelayer/sdk';
1
+ import type { LineItem } from '@commercelayer/sdk';
2
2
  import { LineItemType } from '../typings/index';
3
- export interface GetLineItemsCountInterface {
4
- (args: {
5
- lineItems: LineItem[];
6
- quantity?: number;
7
- typeAccepted?: TypeAccepted[];
8
- }): number;
9
- }
10
3
  export declare type TypeAccepted = Extract<LineItemType, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
11
- declare 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,Object.assign({},props)):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return _createElement(PriceTemplate,Object.assign({},props,{key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount}))});export default function getPrices(prices){const obj={};return isArray(prices)&&prices.forEach(p=>{const sku=p.sku_code;has(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}
@@ -1 +1 @@
1
- const getSkus=(skus,sortBy)=>{const obj={};return sortBy.forEach(sku=>{skus.forEach(o=>{(o==null?void 0:o.code)===sku&&(obj[o.code]=o)})}),obj};export default getSkus;
1
+ const getSkus=(skus,sortBy)=>{const obj={};return sortBy.forEach(sku=>{skus.forEach(o=>{o?.code===sku&&(obj[o.code]=o)})}),obj};export default getSkus;
@@ -0,0 +1 @@
1
+ export default function useExternalScript(url: string): boolean;
@@ -0,0 +1 @@
1
+ import{useEffect,useState}from"react";export default function useExternalScript(url){const[loaded,setLoaded]=useState(!1);return useEffect(()=>{const script=document.createElement("script");return script.src=url,script.async=!0,document.body.appendChild(script),script.onload=()=>{setLoaded(!0)},()=>{document.body.removeChild(script),setLoaded(!1)}},[url]),loaded}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const sortDescIcon: JSX.Element;
3
+ export declare const sortAscIcon: JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";export const sortDescIcon=_jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},{children:_jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4"})})),sortAscIcon=_jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},{children:_jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})}));
@@ -0,0 +1 @@
1
+ export default function isDate(value: string): boolean;
@@ -0,0 +1 @@
1
+ export default function isDate(value){return!isNaN(Date.parse(value))}
@@ -17,7 +17,7 @@ declare type JWT = {
17
17
  slug: string;
18
18
  };
19
19
  owner: {
20
- id: 'gOqzZhZrmQ';
20
+ id: string;
21
21
  type: 'Customer';
22
22
  };
23
23
  rand: number;
@@ -0,0 +1,2 @@
1
+ export declare const defaultImgUrl = "https://data.commercelayer.app/assets/images/placeholders/img_placeholder.svg";
2
+ export declare const defaultGiftCardImgUrl = "https://data.commercelayer.app/assets/images/placeholders/gift_placeholder.svg";
@@ -0,0 +1 @@
1
+ export const defaultImgUrl="https://data.commercelayer.app/assets/images/placeholders/img_placeholder.svg",defaultGiftCardImgUrl="https://data.commercelayer.app/assets/images/placeholders/gift_placeholder.svg";
@@ -1 +1 @@
1
- import isFunction from"lodash/isFunction";export default function promisify(cb,params){return new Promise((resolve,reject)=>{params?cb(params,(err,res)=>{err&&reject(err),resolve(res)}):isFunction(cb==null?void 0:cb.tokenize)?cb==null||cb.tokenize((err,payload)=>{err&&reject(err),resolve(payload)}):cb((err,res)=>{err&&reject(err),resolve(res)})})}
1
+ import isFunction from"lodash/isFunction";export default function promisify(cb,params){return new Promise((resolve,reject)=>{params?cb(params,(err,res)=>{err&&reject(err),resolve(res)}):isFunction(cb?.tokenize)?cb?.tokenize((err,payload)=>{err&&reject(err),resolve(payload)}):cb((err,res)=>{err&&reject(err),resolve(res)})})}
@@ -0,0 +1 @@
1
+ export default function scrollbarWidth(): number;
@@ -0,0 +1 @@
1
+ export default function scrollbarWidth(){if(typeof document>"u")return 0;const scrollDiv=document.createElement("div");scrollDiv.setAttribute("style","width: 100px; height: 100px; overflow: scroll; position:absolute; top:-9999px;"),document.body.appendChild(scrollDiv);const scrollbarWidth2=scrollDiv.offsetWidth-scrollDiv.clientWidth;return document.body.removeChild(scrollDiv),scrollbarWidth2}
@@ -1,2 +1,3 @@
1
- import { Shipment } from '@commercelayer/sdk';
1
+ import { LineItem, Shipment } from '@commercelayer/sdk';
2
2
  export declare function shipmentsFilled(shipments: Shipment[]): boolean;
3
+ export declare function isDoNotShip(lineItems?: LineItem[]): boolean;
@@ -1 +1 @@
1
- import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}
1
+ import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}export function isDoNotShip(lineItems){const itemDoNotShip=[],items=lineItems?lineItems.filter(({item_type})=>item_type==="skus").map(lineItem=>{var _a;return lineItem.item&&((_a=lineItem.item)===null||_a===void 0?void 0:_a.do_not_ship)&&itemDoNotShip.push(!0),lineItem}):[];return itemDoNotShip.length>0&&itemDoNotShip.length===items.length}
@@ -2,6 +2,7 @@ import { BaseState } from '../typings/index';
2
2
  import { ResourceErrorType, BaseError } from '../typings/errors';
3
3
  import { AddressField } from '../reducers/AddressReducer';
4
4
  import { AddressCreate } from '@commercelayer/sdk';
5
+ import { AddressInputName } from '../typings/index';
5
6
  export interface ValidateFormFields {
6
7
  <R extends string[]>(fields: HTMLFormControlsCollection, required: R, resourceType: ResourceErrorType): {
7
8
  errors: BaseError[];
@@ -17,4 +18,5 @@ export interface FieldsExist {
17
18
  (address: AddressCreate, schema?: AddressField[]): boolean;
18
19
  }
19
20
  export declare const fieldsExist: FieldsExist;
21
+ export declare function businessMandatoryField(fieldName: AddressInputName, isBusiness?: boolean): boolean;
20
22
  export default validateFormFields;
@@ -1 +1 @@
1
- import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import get from"lodash/get";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const isTick=!!get(v,"checked"),val=isTick||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.indexOf(attrName)!==-1||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values=Object.assign(Object.assign({},values),{[`${v.name}`]:val})}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?Object.assign(Object.assign({},values),{metadata:Object.assign(Object.assign({},values.metadata),{[`${v.name}`]:val})}):Object.assign(Object.assign({},values),{[`${v.name}`]:val}))}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};export default validateFormFields;
1
+ import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import get from"lodash/get";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const isTick=!!get(v,"checked"),val=isTick||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.indexOf(attrName)!==-1||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values=Object.assign(Object.assign({},values),{[`${v.name}`]:val})}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?Object.assign(Object.assign({},values),{metadata:Object.assign(Object.assign({},values.metadata),{[`${v.name}`]:val})}):Object.assign(Object.assign({},values),{[`${v.name}`]:val}))}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};const businessOptionalFields=["billing_address_first_name","billing_address_last_name","shipping_address_first_name","shipping_address_last_name","first_name","last_name"],customerOptionalFields=["billing_address_company","shipping_address_company","company"];export function businessMandatoryField(fieldName,isBusiness){return!(isBusiness&&businessOptionalFields.includes(fieldName)||!isBusiness&&customerOptionalFields.includes(fieldName))}export default validateFormFields;
package/package.json CHANGED
@@ -1,57 +1,51 @@
1
1
  {
2
2
  "name": "@commercelayer/react-components",
3
- "version": "2.53.3",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "The Official Commerce Layer React Components",
5
5
  "module": "lib/index.js",
6
+ "types": "lib/index.d.ts",
6
7
  "files": [
7
8
  "lib",
8
9
  "package.json",
9
10
  "README.md"
10
11
  ],
11
- "publishConfig": {
12
- "access": "public"
12
+ "exports": {
13
+ ".": "./lib/index.js",
14
+ "./auth/*": "./lib/components/auth/*.js",
15
+ "./orders/*": "./lib/components/orders/*.js",
16
+ "./skus/*": "./lib/components/skus/*.js",
17
+ "./customers/*": "./lib/components/customers/*.js"
13
18
  },
14
- "release": {
15
- "branches": [
16
- "+([0-9])?(.{+([0-9]),x}).x",
17
- "master",
18
- "next",
19
- "next-major",
20
- {
21
- "name": "beta",
22
- "prerelease": true
23
- },
24
- {
25
- "name": "alpha",
26
- "prerelease": true
27
- }
28
- ],
29
- "plugins": [
30
- "@semantic-release/commit-analyzer",
31
- "@semantic-release/release-notes-generator",
32
- "@semantic-release/changelog",
33
- "@semantic-release/npm",
34
- "@semantic-release/git",
35
- [
36
- "@semantic-release/github",
37
- {
38
- "addReleases": "top"
39
- }
19
+ "typesVersions": {
20
+ "*": {
21
+ "auth/*": [
22
+ "lib/components/auth/*.d.ts"
23
+ ],
24
+ "orders/*": [
25
+ "lib/components/orders/*.d.ts"
26
+ ],
27
+ "skus/*": [
28
+ "lib/components/skus/*.d.ts"
29
+ ],
30
+ "customers/*": [
31
+ "lib/components/customers/*.d.ts"
40
32
  ]
41
- ]
33
+ }
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
42
37
  },
43
38
  "scripts": {
44
39
  "test": "jest",
45
40
  "test:coverage": "jest --coverage",
46
- "build": "tsc -b tsconfig.prod.json --verbose",
41
+ "test:e2e": "NODE_ENV=test playwright test",
42
+ "test:e2e:coverage": "nyc pnpm test:e2e && pnpm coverage:report",
43
+ "coverage:report": "nyc report --reporter=html",
44
+ "lint": "eslint src",
45
+ "build": "tsc -b tsconfig.prod.json --verbose && pnpm postbuild",
46
+ "build:dev": "tsc -b tsconfig.prod.json --verbose && tsc-alias -p tsconfig.prod.json",
47
47
  "postbuild": "tsc-alias -p tsconfig.prod.json && minimize-js lib -w -s",
48
- "start": "NODE_OPTIONS='--inspect' next dev",
49
- "version:fix": "npm version patch",
50
- "version:feat": "npm version minor",
51
- "version:perf": "npm version major",
52
- "publish:fix": "npm run build && npm run version:fix && git push --follow-tags && npm publish --access public",
53
- "publish:feat": "npm run build && npm run version:feat && git push --follow-tags && npm publish --access public",
54
- "publish:perf": "npm run build && npm run version:perf && git push --follow-tags && npm publish --access public"
48
+ "start": "NODE_OPTIONS='--inspect' next dev"
55
49
  },
56
50
  "repository": {
57
51
  "type": "git",
@@ -76,77 +70,86 @@
76
70
  },
77
71
  "homepage": "https://github.com/commercelayer/commercelayer-react-components#readme",
78
72
  "dependencies": {
79
- "@ac-dev/countries-service": "^1.1.3",
80
- "@ac-dev/states-service": "^1.0.2",
81
- "@adyen/adyen-web": "^5.3.1",
82
- "@commercelayer/js-auth": "^2.2.6",
83
- "@commercelayer/sdk": "^2.3.11",
84
- "@stripe/react-stripe-js": "^1.6.0",
85
- "@stripe/stripe-js": "^1.21.2",
86
- "axios": "^0.24.0",
87
- "braintree-web": "^3.84.0",
73
+ "@ac-dev/countries-service": "^1.2.0",
74
+ "@ac-dev/states-service": "^1.1.0",
75
+ "@adyen/adyen-web": "^5.16.2",
76
+ "@commercelayer/sdk": "^4.14.0",
77
+ "@stripe/react-stripe-js": "^1.9.0",
78
+ "@stripe/stripe-js": "^1.32.0",
79
+ "axios": "^0.27.2",
80
+ "braintree-web": "^3.85.3",
81
+ "frames-react": "^1.0.10",
88
82
  "jwt-decode": "^3.1.2",
89
83
  "lodash": "^4.17.21",
90
84
  "lodash-es": "^4.17.21",
91
- "rapid-form": "^1.6.0"
85
+ "rapid-form": "^1.6.2",
86
+ "react-table": "^7.8.0",
87
+ "react-window": "^1.8.7"
92
88
  },
93
89
  "devDependencies": {
94
- "@babel/plugin-proposal-class-properties": "^7.16.0",
95
- "@babel/preset-env": "^7.16.4",
96
- "@babel/preset-react": "^7.16.0",
97
- "@babel/preset-typescript": "^7.16.0",
98
- "@playwright/test": "^1.17.1",
90
+ "@babel/core": "^7.18.5",
91
+ "@babel/plugin-proposal-class-properties": "^7.17.12",
92
+ "@babel/plugin-syntax-flow": "^7.17.12",
93
+ "@babel/plugin-transform-react-jsx": "^7.17.12",
94
+ "@babel/preset-env": "^7.18.2",
95
+ "@babel/preset-react": "^7.17.12",
96
+ "@babel/preset-typescript": "^7.17.12",
97
+ "@commercelayer/js-auth": "^2.3.0",
98
+ "@playwright/test": "^1.22.2",
99
99
  "@semantic-release/changelog": "^6.0.1",
100
100
  "@semantic-release/commit-analyzer": "^9.0.2",
101
101
  "@semantic-release/git": "^10.0.1",
102
- "@semantic-release/github": "^8.0.2",
103
- "@semantic-release/npm": "^8.0.3",
102
+ "@semantic-release/github": "^8.0.4",
103
+ "@semantic-release/npm": "^9.0.1",
104
104
  "@semantic-release/release-notes-generator": "^10.0.3",
105
- "@tailwindcss/aspect-ratio": "^0.3.0",
106
- "@tailwindcss/forms": "^0.3.4",
107
- "@tailwindcss/typography": "^0.4.1",
108
- "@types/braintree-web": "^3.75.12",
109
- "@types/jest": "^27.0.3",
110
- "@types/lodash": "^4.14.177",
111
- "@types/node": "^16.11.12",
112
- "@types/prop-types": "^15.7.4",
113
- "@types/react": "^17.0.37",
114
- "@types/react-test-renderer": "^17.0.1",
115
- "@typescript-eslint/eslint-plugin": "^5.6.0",
116
- "@typescript-eslint/parser": "^5.6.0",
117
- "@zeit/next-css": "^1.0.1",
105
+ "@tailwindcss/aspect-ratio": "^0.4.0",
106
+ "@tailwindcss/forms": "^0.5.2",
107
+ "@tailwindcss/line-clamp": "^0.4.0",
108
+ "@tailwindcss/typography": "^0.5.2",
109
+ "@types/braintree-web": "^3.75.19",
110
+ "@types/jest": "^27.5.2",
111
+ "@types/lodash": "^4.14.182",
112
+ "@types/node": "^17.0.45",
113
+ "@types/prop-types": "^15.7.5",
114
+ "@types/react": "^17.0.47",
115
+ "@types/react-table": "^7.7.12",
116
+ "@types/react-test-renderer": "^17.0.2",
117
+ "@types/react-window": "^1.8.5",
118
+ "@typescript-eslint/eslint-plugin": "^5.29.0",
119
+ "@typescript-eslint/parser": "^5.29.0",
118
120
  "@zerollup/ts-transform-paths": "^1.7.18",
119
- "autoprefixer": "^10.4.0",
120
- "babel-jest": "^27.4.2",
121
- "babel-loader": "^8.2.3",
121
+ "autoprefixer": "^10.4.7",
122
+ "babel-jest": "^28.1.1",
123
+ "babel-loader": "^8.2.5",
122
124
  "babel-plugin-istanbul": "^6.1.1",
123
- "dotenv": "^10.0.0",
124
- "eslint": "^8.4.1",
125
- "eslint-config-prettier": "^8.3.0",
126
- "eslint-config-react-app": "^6.0.0",
127
- "eslint-plugin-react": "^7.27.1",
128
- "eslint-plugin-react-hooks": "^4.3.0",
129
- "jest": "^27.4.3",
130
- "minimize-js": "^1.2.0",
131
- "next": "^12.0.7",
132
- "playwright": "^1.17.1",
133
- "postcss": "^8.4.4",
125
+ "dotenv": "^16.0.1",
126
+ "eslint": "^8.18.0",
127
+ "eslint-config-prettier": "^8.5.0",
128
+ "eslint-config-react-app": "^7.0.1",
129
+ "eslint-plugin-react": "^7.30.1",
130
+ "eslint-plugin-react-hooks": "^4.6.0",
131
+ "jest": "^28.1.1",
132
+ "minimize-js": "^1.3.0",
133
+ "next": "^12.1.6",
134
+ "nyc": "^15.1.0",
135
+ "playwright": "^1.22.2",
136
+ "postcss": "^8.4.14",
134
137
  "postcss-loader": "^6.2.1",
135
- "prettier": "^2.5.1",
136
- "prop-types": "^15.7.2",
138
+ "prettier": "^2.7.1",
139
+ "prop-types": "^15.8.1",
137
140
  "react": "^17.0.2",
138
141
  "react-dom": "^17.0.2",
139
142
  "react-test-renderer": "^17.0.2",
140
- "rollup-plugin-babel": "^4.4.0",
141
- "rollup-plugin-node-resolve": "^5.2.0",
142
- "tailwindcss": "^2.2.19",
143
- "ts-jest": "^27.1.0",
144
- "ts-loader": "^9.2.6",
145
- "tsc-alias": "^1.4.2",
143
+ "semantic-release": "^19.0.3",
144
+ "tailwindcss": "^3.1.4",
145
+ "ts-jest": "^28.0.5",
146
+ "ts-loader": "^9.3.1",
147
+ "tsc-alias": "^1.6.11",
146
148
  "tsconfig-paths-jest": "^0.0.1",
147
- "ttypescript": "^1.5.13",
148
- "typescript": "^4.5.2",
149
- "v8-to-istanbul": "^8.1.0"
149
+ "tslib": "^2.4.0",
150
+ "typescript": "^4.7.4",
151
+ "v8-to-istanbul": "^9.0.1",
152
+ "webpack": "^5.73.0"
150
153
  },
151
154
  "peerDependencies": {
152
155
  "react": "^17.0.2"
@@ -1,20 +0,0 @@
1
- import { FunctionComponent, PropsWithoutRef, ReactNode } from 'react';
2
- import { FunctionChildren } from '../typings/index';
3
- import { AddToCartReturn } from '../reducers/OrderReducer';
4
- import { VariantOption } from './VariantSelector';
5
- declare type ChildrenProps = {
6
- handleClick: () => AddToCartReturn;
7
- } & Omit<AddToCartButtonProps, 'children'>;
8
- declare type AddToCartButtonChildrenProps = FunctionChildren<ChildrenProps>;
9
- export declare type AddToCartButtonType = ChildrenProps;
10
- declare type AddToCartButtonProps = {
11
- children?: AddToCartButtonChildrenProps;
12
- label?: string | ReactNode;
13
- skuCode?: string;
14
- bundleCode?: string;
15
- disabled?: boolean;
16
- skuListId?: string;
17
- lineItem?: VariantOption['lineItem'];
18
- } & PropsWithoutRef<JSX.IntrinsicElements['button']>;
19
- declare const AddToCartButton: FunctionComponent<AddToCartButtonProps>;
20
- export default AddToCartButton;