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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/lib/cjs/components/MetadataInput.d.ts +1 -0
  2. package/lib/cjs/components/addresses/Address.d.ts +18 -0
  3. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +24 -0
  4. package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -1
  5. package/lib/cjs/components/addresses/AddressField.d.ts +22 -0
  6. package/lib/cjs/components/addresses/AddressInput.d.ts +19 -0
  7. package/lib/cjs/components/addresses/AddressInput.js +1 -1
  8. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +26 -0
  9. package/lib/cjs/components/addresses/AddressStateSelector.js +1 -1
  10. package/lib/cjs/components/addresses/AddressesContainer.d.ts +22 -0
  11. package/lib/cjs/components/addresses/AddressesEmpty.d.ts +13 -0
  12. package/lib/cjs/components/addresses/BillingAddressForm.d.ts +20 -0
  13. package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -1
  14. package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +1 -0
  15. package/lib/cjs/components/addresses/ShippingAddressForm.d.ts +17 -0
  16. package/lib/cjs/components/auth/CommerceLayer.d.ts +1 -0
  17. package/lib/cjs/components/customers/CustomerAddressForm.d.ts +5 -0
  18. package/lib/cjs/components/customers/CustomerAddressForm.js +1 -1
  19. package/lib/cjs/components/customers/CustomerContainer.d.ts +20 -1
  20. package/lib/cjs/components/customers/CustomerField.d.ts +16 -0
  21. package/lib/cjs/components/customers/CustomerInput.d.ts +1 -0
  22. package/lib/cjs/components/customers/CustomerInput.js +1 -1
  23. package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +1 -0
  24. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
  25. package/lib/cjs/components/customers/MyAccountLink.d.ts +11 -0
  26. package/lib/cjs/components/customers/MyIdentityLink.d.ts +16 -0
  27. package/lib/cjs/components/customers/MyIdentityLink.js +1 -1
  28. package/lib/cjs/components/errors/Errors.d.ts +1 -0
  29. package/lib/cjs/components/errors/Errors.js +1 -1
  30. package/lib/cjs/components/gift_cards/GiftCard.d.ts +1 -0
  31. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
  32. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -0
  33. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
  34. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
  35. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
  36. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
  37. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
  38. package/lib/cjs/components/line_items/LineItem.d.ts +1 -0
  39. package/lib/cjs/components/line_items/LineItem.js +1 -1
  40. package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -0
  41. package/lib/cjs/components/line_items/LineItemAmount.js +1 -1
  42. package/lib/cjs/components/line_items/LineItemBundleSkuField.d.ts +24 -0
  43. package/lib/cjs/components/line_items/LineItemBundleSkuField.js +2 -0
  44. package/lib/cjs/components/line_items/LineItemBundleSkus.d.ts +6 -0
  45. package/lib/cjs/components/line_items/LineItemBundleSkus.js +2 -0
  46. package/lib/cjs/components/line_items/LineItemCode.d.ts +1 -0
  47. package/lib/cjs/components/line_items/LineItemCode.js +1 -1
  48. package/lib/cjs/components/line_items/LineItemField.d.ts +1 -0
  49. package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -0
  50. package/lib/cjs/components/line_items/LineItemImage.js +1 -1
  51. package/lib/cjs/components/line_items/LineItemName.d.ts +1 -0
  52. package/lib/cjs/components/line_items/LineItemName.js +1 -1
  53. package/lib/cjs/components/line_items/LineItemQuantity.d.ts +5 -0
  54. package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
  55. package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
  56. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +1 -0
  57. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
  58. package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -0
  59. package/lib/cjs/components/line_items/LineItemsCount.js +1 -1
  60. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +1 -0
  61. package/lib/cjs/components/orders/AddToCartButton.d.ts +32 -0
  62. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +1 -0
  63. package/lib/cjs/components/orders/CartLink.d.ts +8 -0
  64. package/lib/cjs/components/orders/CartLink.js +1 -1
  65. package/lib/cjs/components/orders/CheckoutLink.d.ts +16 -0
  66. package/lib/cjs/components/orders/DiscountAmount.d.ts +1 -0
  67. package/lib/cjs/components/orders/GiftCardAmount.d.ts +1 -0
  68. package/lib/cjs/components/orders/HostedCart.d.ts +30 -8
  69. package/lib/cjs/components/orders/HostedCart.js +1 -1
  70. package/lib/cjs/components/orders/OrderContainer.d.ts +34 -0
  71. package/lib/cjs/components/orders/OrderContainer.js +1 -1
  72. package/lib/cjs/components/orders/OrderList.d.ts +1 -0
  73. package/lib/cjs/components/orders/OrderList.js +1 -1
  74. package/lib/cjs/components/orders/OrderListEmpty.d.ts +1 -0
  75. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +1 -0
  76. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +1 -0
  77. package/lib/cjs/components/orders/OrderListRow.d.ts +1 -0
  78. package/lib/cjs/components/orders/OrderNumber.d.ts +1 -0
  79. package/lib/cjs/components/orders/OrderStorage.d.ts +23 -0
  80. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +1 -0
  81. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  82. package/lib/cjs/components/orders/ShippingAmount.d.ts +1 -0
  83. package/lib/cjs/components/orders/SubTotalAmount.d.ts +1 -0
  84. package/lib/cjs/components/orders/TaxesAmount.d.ts +1 -0
  85. package/lib/cjs/components/orders/TotalAmount.d.ts +1 -0
  86. package/lib/cjs/components/parcels/ParcelField.d.ts +1 -0
  87. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +1 -0
  88. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +1 -0
  89. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  90. package/lib/cjs/components/parcels/Parcels.d.ts +1 -0
  91. package/lib/cjs/components/parcels/ParcelsCount.d.ts +1 -0
  92. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -0
  93. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  94. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  95. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +1 -0
  96. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  97. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +1 -0
  98. package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
  99. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -0
  100. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -0
  101. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  102. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -0
  103. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +1 -0
  104. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  105. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +1 -0
  106. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +1 -0
  107. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +1 -0
  108. package/lib/cjs/components/payment_source/ExternalPayment.js +1 -1
  109. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -0
  110. package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -1
  111. package/lib/cjs/components/payment_source/PaymentSource.d.ts +1 -0
  112. package/lib/cjs/components/payment_source/PaymentSource.js +1 -1
  113. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  114. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  115. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  116. package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +1 -0
  117. package/lib/cjs/components/payment_source/StripePayment.d.ts +1 -0
  118. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +1 -0
  119. package/lib/cjs/components/prices/Price.d.ts +1 -0
  120. package/lib/cjs/components/prices/PricesContainer.d.ts +1 -0
  121. package/lib/cjs/components/shipments/ShipmentField.d.ts +1 -0
  122. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +1 -0
  123. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  124. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  125. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  126. package/lib/cjs/components/skus/AvailabilityContainer.d.ts +27 -1
  127. package/lib/cjs/components/skus/AvailabilityContainer.js +1 -1
  128. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +17 -3
  129. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +1 -0
  130. package/lib/cjs/components/skus/SkuField.d.ts +14 -2
  131. package/lib/cjs/components/skus/Skus.d.ts +12 -0
  132. package/lib/cjs/components/skus/SkusContainer.d.ts +14 -1
  133. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +1 -0
  134. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +1 -0
  135. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -0
  136. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +1 -0
  137. package/lib/cjs/components/utils/GenericFieldComponent.d.ts +6 -0
  138. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +1 -0
  139. package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -0
  140. package/lib/cjs/components/utils/getAllErrors.d.ts +1 -0
  141. package/lib/cjs/context/LineItemBundleChildrenContext.d.ts +11 -0
  142. package/lib/cjs/context/LineItemBundleChildrenContext.js +2 -0
  143. package/lib/cjs/context/LineItemBundleSkuChildrenContext.d.ts +9 -0
  144. package/lib/cjs/context/LineItemBundleSkuChildrenContext.js +2 -0
  145. package/lib/cjs/reducers/AddressReducer.js +1 -1
  146. package/lib/cjs/reducers/AvailabilityReducer.d.ts +3 -2
  147. package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
  148. package/lib/cjs/reducers/CustomerReducer.d.ts +1 -1
  149. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  150. package/lib/cjs/reducers/LineItemReducer.d.ts +2 -1
  151. package/lib/cjs/reducers/LineItemReducer.js +1 -1
  152. package/lib/cjs/reducers/OrderReducer.d.ts +1 -1
  153. package/lib/cjs/typings/globals.d.ts +1 -0
  154. package/lib/cjs/utils/addressesManager.d.ts +5 -4
  155. package/lib/cjs/utils/addressesManager.js +1 -1
  156. package/lib/cjs/utils/countryStateCity.d.ts +798 -5
  157. package/lib/cjs/utils/countryStateCity.js +1 -1
  158. package/lib/cjs/utils/filterChildren.d.ts +1 -0
  159. package/lib/cjs/utils/getLoaderComponent.d.ts +1 -0
  160. package/lib/cjs/utils/getPrices.d.ts +1 -0
  161. package/lib/cjs/utils/validateFormFields.d.ts +1 -1
  162. package/lib/cjs/utils/validateFormFields.js +1 -1
  163. package/lib/esm/components/MetadataInput.d.ts +1 -0
  164. package/lib/esm/components/addresses/Address.d.ts +18 -0
  165. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +24 -0
  166. package/lib/esm/components/addresses/AddressCountrySelector.js +1 -1
  167. package/lib/esm/components/addresses/AddressField.d.ts +22 -0
  168. package/lib/esm/components/addresses/AddressInput.d.ts +19 -0
  169. package/lib/esm/components/addresses/AddressInput.js +1 -1
  170. package/lib/esm/components/addresses/AddressStateSelector.d.ts +26 -0
  171. package/lib/esm/components/addresses/AddressStateSelector.js +1 -1
  172. package/lib/esm/components/addresses/AddressesContainer.d.ts +22 -0
  173. package/lib/esm/components/addresses/AddressesEmpty.d.ts +13 -0
  174. package/lib/esm/components/addresses/BillingAddressForm.d.ts +20 -0
  175. package/lib/esm/components/addresses/SaveAddressesButton.js +1 -1
  176. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +1 -0
  177. package/lib/esm/components/addresses/ShippingAddressForm.d.ts +17 -0
  178. package/lib/esm/components/auth/CommerceLayer.d.ts +1 -0
  179. package/lib/esm/components/customers/CustomerAddressForm.d.ts +5 -0
  180. package/lib/esm/components/customers/CustomerAddressForm.js +1 -1
  181. package/lib/esm/components/customers/CustomerContainer.d.ts +20 -1
  182. package/lib/esm/components/customers/CustomerField.d.ts +16 -0
  183. package/lib/esm/components/customers/CustomerInput.d.ts +1 -0
  184. package/lib/esm/components/customers/CustomerInput.js +1 -1
  185. package/lib/esm/components/customers/CustomerPaymentSource.d.ts +1 -0
  186. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
  187. package/lib/esm/components/customers/MyAccountLink.d.ts +11 -0
  188. package/lib/esm/components/customers/MyIdentityLink.d.ts +16 -0
  189. package/lib/esm/components/customers/MyIdentityLink.js +1 -1
  190. package/lib/esm/components/errors/Errors.d.ts +1 -0
  191. package/lib/esm/components/errors/Errors.js +1 -1
  192. package/lib/esm/components/gift_cards/GiftCard.d.ts +1 -0
  193. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
  194. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -0
  195. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
  196. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
  197. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
  198. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
  199. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
  200. package/lib/esm/components/line_items/LineItem.d.ts +1 -0
  201. package/lib/esm/components/line_items/LineItem.js +1 -1
  202. package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -0
  203. package/lib/esm/components/line_items/LineItemAmount.js +1 -1
  204. package/lib/esm/components/line_items/LineItemBundleSkuField.d.ts +24 -0
  205. package/lib/esm/components/line_items/LineItemBundleSkuField.js +2 -0
  206. package/lib/esm/components/line_items/LineItemBundleSkus.d.ts +6 -0
  207. package/lib/esm/components/line_items/LineItemBundleSkus.js +2 -0
  208. package/lib/esm/components/line_items/LineItemCode.d.ts +1 -0
  209. package/lib/esm/components/line_items/LineItemCode.js +1 -1
  210. package/lib/esm/components/line_items/LineItemField.d.ts +1 -0
  211. package/lib/esm/components/line_items/LineItemImage.d.ts +1 -0
  212. package/lib/esm/components/line_items/LineItemImage.js +1 -1
  213. package/lib/esm/components/line_items/LineItemName.d.ts +1 -0
  214. package/lib/esm/components/line_items/LineItemName.js +1 -1
  215. package/lib/esm/components/line_items/LineItemQuantity.d.ts +5 -0
  216. package/lib/esm/components/line_items/LineItemQuantity.js +1 -1
  217. package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -1
  218. package/lib/esm/components/line_items/LineItemsContainer.d.ts +1 -0
  219. package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
  220. package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -0
  221. package/lib/esm/components/line_items/LineItemsCount.js +1 -1
  222. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +1 -0
  223. package/lib/esm/components/orders/AddToCartButton.d.ts +32 -0
  224. package/lib/esm/components/orders/AdjustmentAmount.d.ts +1 -0
  225. package/lib/esm/components/orders/CartLink.d.ts +8 -0
  226. package/lib/esm/components/orders/CartLink.js +1 -1
  227. package/lib/esm/components/orders/CheckoutLink.d.ts +16 -0
  228. package/lib/esm/components/orders/DiscountAmount.d.ts +1 -0
  229. package/lib/esm/components/orders/GiftCardAmount.d.ts +1 -0
  230. package/lib/esm/components/orders/HostedCart.d.ts +30 -8
  231. package/lib/esm/components/orders/HostedCart.js +1 -1
  232. package/lib/esm/components/orders/OrderContainer.d.ts +34 -0
  233. package/lib/esm/components/orders/OrderContainer.js +1 -1
  234. package/lib/esm/components/orders/OrderList.d.ts +1 -0
  235. package/lib/esm/components/orders/OrderList.js +1 -1
  236. package/lib/esm/components/orders/OrderListEmpty.d.ts +1 -0
  237. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +1 -0
  238. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +1 -0
  239. package/lib/esm/components/orders/OrderListRow.d.ts +1 -0
  240. package/lib/esm/components/orders/OrderNumber.d.ts +1 -0
  241. package/lib/esm/components/orders/OrderStorage.d.ts +23 -0
  242. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +1 -0
  243. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  244. package/lib/esm/components/orders/ShippingAmount.d.ts +1 -0
  245. package/lib/esm/components/orders/SubTotalAmount.d.ts +1 -0
  246. package/lib/esm/components/orders/TaxesAmount.d.ts +1 -0
  247. package/lib/esm/components/orders/TotalAmount.d.ts +1 -0
  248. package/lib/esm/components/parcels/ParcelField.d.ts +1 -0
  249. package/lib/esm/components/parcels/ParcelLineItem.d.ts +1 -0
  250. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +1 -0
  251. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  252. package/lib/esm/components/parcels/Parcels.d.ts +1 -0
  253. package/lib/esm/components/parcels/ParcelsCount.d.ts +1 -0
  254. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -0
  255. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  256. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  257. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +1 -0
  258. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  259. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +1 -0
  260. package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
  261. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -0
  262. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -0
  263. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  264. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -0
  265. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +1 -0
  266. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  267. package/lib/esm/components/payment_source/BraintreePayment.d.ts +1 -0
  268. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +1 -0
  269. package/lib/esm/components/payment_source/ExternalPayment.d.ts +1 -0
  270. package/lib/esm/components/payment_source/ExternalPayment.js +1 -1
  271. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -0
  272. package/lib/esm/components/payment_source/KlarnaPayment.js +1 -1
  273. package/lib/esm/components/payment_source/PaymentSource.d.ts +1 -0
  274. package/lib/esm/components/payment_source/PaymentSource.js +1 -1
  275. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  276. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  277. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  278. package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +1 -0
  279. package/lib/esm/components/payment_source/StripePayment.d.ts +1 -0
  280. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +1 -0
  281. package/lib/esm/components/prices/Price.d.ts +1 -0
  282. package/lib/esm/components/prices/PricesContainer.d.ts +1 -0
  283. package/lib/esm/components/shipments/ShipmentField.d.ts +1 -0
  284. package/lib/esm/components/shipments/ShipmentsCount.d.ts +1 -0
  285. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  286. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  287. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  288. package/lib/esm/components/skus/AvailabilityContainer.d.ts +27 -1
  289. package/lib/esm/components/skus/AvailabilityContainer.js +1 -1
  290. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +17 -3
  291. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +1 -0
  292. package/lib/esm/components/skus/SkuField.d.ts +14 -2
  293. package/lib/esm/components/skus/Skus.d.ts +12 -0
  294. package/lib/esm/components/skus/SkusContainer.d.ts +14 -1
  295. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +1 -0
  296. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +1 -0
  297. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -0
  298. package/lib/esm/components/utils/BaseOrderPrice.d.ts +1 -0
  299. package/lib/esm/components/utils/GenericFieldComponent.d.ts +6 -0
  300. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +1 -0
  301. package/lib/esm/components/utils/PriceTemplate.d.ts +1 -0
  302. package/lib/esm/components/utils/getAllErrors.d.ts +1 -0
  303. package/lib/esm/context/LineItemBundleChildrenContext.d.ts +11 -0
  304. package/lib/esm/context/LineItemBundleChildrenContext.js +2 -0
  305. package/lib/esm/context/LineItemBundleSkuChildrenContext.d.ts +9 -0
  306. package/lib/esm/context/LineItemBundleSkuChildrenContext.js +2 -0
  307. package/lib/esm/reducers/AddressReducer.js +1 -1
  308. package/lib/esm/reducers/AvailabilityReducer.d.ts +3 -2
  309. package/lib/esm/reducers/AvailabilityReducer.js +1 -1
  310. package/lib/esm/reducers/CustomerReducer.d.ts +1 -1
  311. package/lib/esm/reducers/CustomerReducer.js +1 -1
  312. package/lib/esm/reducers/LineItemReducer.d.ts +2 -1
  313. package/lib/esm/reducers/LineItemReducer.js +1 -1
  314. package/lib/esm/reducers/OrderReducer.d.ts +1 -1
  315. package/lib/esm/typings/globals.d.ts +1 -0
  316. package/lib/esm/utils/addressesManager.d.ts +5 -4
  317. package/lib/esm/utils/addressesManager.js +1 -1
  318. package/lib/esm/utils/countryStateCity.d.ts +798 -5
  319. package/lib/esm/utils/countryStateCity.js +1 -1
  320. package/lib/esm/utils/filterChildren.d.ts +1 -0
  321. package/lib/esm/utils/getLoaderComponent.d.ts +1 -0
  322. package/lib/esm/utils/getPrices.d.ts +1 -0
  323. package/lib/esm/utils/validateFormFields.d.ts +1 -1
  324. package/lib/esm/utils/validateFormFields.js +1 -1
  325. package/package.json +2 -4
  326. package/lib/cjs/utils/isEmptyStates.d.ts +0 -1
  327. package/lib/cjs/utils/isEmptyStates.js +0 -2
  328. package/lib/esm/utils/isEmptyStates.d.ts +0 -1
  329. package/lib/esm/utils/isEmptyStates.js +0 -2
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type TOrderList, type InitialOrderListContext, type OrderListContent } from '../../context/OrderListChildrenContext';
2
3
  import { type ColumnDef, type SortingState } from '@tanstack/react-table';
3
4
  import type { DefaultChildrenType, TRange } from '../../typings/globals';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useMemo,useState,useEffect}from"react";import CustomerContext from"../../context/CustomerContext";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import OrderListPagination from"../../context/OrderListPaginationContext";import{useReactTable,getCoreRowModel,getPaginationRowModel,getSortedRowModel,flexRender}from"@tanstack/react-table";import{sortDescIcon,sortAscIcon}from"../../utils/icons";import filterChildren from"../../utils/filterChildren";const rowComponents=["OrderListRow","OrderListEmpty"],paginationComponents=["OrderListPaginationInfo","OrderListPaginationButtons"];export function OrderList({type="orders",children,columns,loadingElement,showActions=!1,showPagination=!1,sortBy=[{id:"number",desc:!0}],pageSize=10,paginationContainerClassName,actionsComponent,actionsContainerClassName,theadClassName,rowTrClassName,...p}){const[loading,setLoading]=useState(!0),[sorting,setSorting]=useState(sortBy),[{pageIndex,pageSize:currentPageSize},setPagination]=useState({pageIndex:0,pageSize}),{orders,subscriptions,getCustomerOrders,getCustomerSubscriptions}=useContext(CustomerContext);useEffect(()=>{type==="orders"&&getCustomerOrders!=null&&getCustomerOrders({pageNumber:pageIndex,pageSize:currentPageSize}),type==="subscriptions"&&getCustomerSubscriptions!=null&&getCustomerSubscriptions({pageNumber:pageIndex,pageSize:currentPageSize})},[pageIndex,currentPageSize]);const data=useMemo(()=>type==="subscriptions"?subscriptions??[]:orders??[],[orders,subscriptions]),cols=useMemo(()=>columns,[columns]),pagination=useMemo(()=>({pageIndex,pageSize:currentPageSize}),[pageIndex,currentPageSize]),pageCount=orders?.pageCount??subscriptions?.pageCount??-1,table=useReactTable({data,columns:cols,getSortedRowModel:getSortedRowModel(),getCoreRowModel:getCoreRowModel(),getPaginationRowModel:getPaginationRowModel(),manualPagination:!0,pageCount,state:{sorting,pagination},onSortingChange:setSorting,onPaginationChange:setPagination}),TableHtmlElement="table",TheadHtmlElement="thead",TbodyHtmlElement="tbody",ThHtmlElement="th",TrHtmlElement="tr";useEffect(()=>(type==="orders"&&orders!=null&&setLoading(!1),type==="subscriptions"&&subscriptions!=null&&setLoading(!1),()=>{setLoading(!0)}),[orders,subscriptions]);const LoadingComponent=loadingElement||_jsx("div",{children:"Loading..."}),headerComponent=table.getHeaderGroups().map(headerGroup=>{const columns2=headerGroup.headers.map((header,k)=>{const sortLabel=header.column.getIsSorted()!==!1?header.column.getIsSorted():"";return _jsx(ThHtmlElement,{"data-testid":`thead-${k}`,"data-sort":`${sortLabel||""}`,children:_jsxs("span",{className:header.column.getCanSort()?"cursor-pointer select-none":"",onClick:header.column.getToggleSortingHandler(),children:[flexRender(header.column.columnDef.header,header.getContext()),{asc:sortAscIcon,desc:sortDescIcon}[header.column.getIsSorted()]??null]})},header.id)});return _jsx(TrHtmlElement,{children:columns2},headerGroup.id)}),rowsComponents=filterChildren({children,filterBy:rowComponents,componentName:"OrderList"}),components=table.getRowModel().rows.map(row=>{const childProps={type,orders:type==="orders"?orders:subscriptions,order:row.original,row,showActions,actionsComponent,actionsContainerClassName};return _jsx(TrHtmlElement,{className:rowTrClassName,children:_jsx(OrderListChildrenContext.Provider,{value:childProps,children:rowsComponents})},row.id)}),pagComponents=filterChildren({children,filterBy:paginationComponents,componentName:"OrderList"}),totalRows=orders?.meta.recordCount??subscriptions?.meta.recordCount??0,Pagination=()=>showPagination?_jsx(OrderListPagination.Provider,{value:{canNextPage:table.getCanNextPage(),canPreviousPage:table.getCanPreviousPage(),gotoPage:table.setPageIndex,nextPage:table.nextPage,pageCount:table.getPageCount(),pageIndex:table.getState().pagination.pageIndex,pageOptions:table.getPageOptions(),pageSize:table.getState().pagination.pageSize,previousPage:table.previousPage,setPageSize:table.setPageSize,totalRows},children:pagComponents}):null;return loading&&(orders==null||subscriptions==null)?_jsx(_Fragment,{children:LoadingComponent}):orders?.length===0||subscriptions?.length===0?_jsxs(OrderListChildrenContext.Provider,{value:{orders:type==="orders"?orders:subscriptions},children:[rowsComponents,_jsx(Pagination,{})]}):_jsxs(_Fragment,{children:[_jsxs(TableHtmlElement,{...p,children:[_jsx(TheadHtmlElement,{className:theadClassName,children:headerComponent}),_jsx(TbodyHtmlElement,{children:components})]}),totalRows<=pageSize?null:_jsx("div",{className:paginationContainerClassName,children:_jsx(Pagination,{})})]})}export default OrderList;
2
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useMemo,useState,useEffect}from"react";import CustomerContext from"../../context/CustomerContext";import OrderListChildrenContext from"../../context/OrderListChildrenContext";import OrderListPagination from"../../context/OrderListPaginationContext";import{useReactTable,getCoreRowModel,getPaginationRowModel,getSortedRowModel,flexRender}from"@tanstack/react-table";import{sortDescIcon,sortAscIcon}from"../../utils/icons";import filterChildren from"../../utils/filterChildren";const rowComponents=["OrderListRow","OrderListEmpty"],paginationComponents=["OrderListPaginationInfo","OrderListPaginationButtons"];export function OrderList({type="orders",children,columns,loadingElement,showActions=!1,showPagination=!1,sortBy=[{id:"number",desc:!0}],pageSize=10,paginationContainerClassName,actionsComponent,actionsContainerClassName,theadClassName,rowTrClassName,...p}){const[loading,setLoading]=useState(!0),[sorting,setSorting]=useState(sortBy),[{pageIndex,pageSize:currentPageSize},setPagination]=useState({pageIndex:0,pageSize}),{orders,subscriptions,getCustomerOrders,getCustomerSubscriptions}=useContext(CustomerContext);useEffect(()=>{type==="orders"&&getCustomerOrders!=null&&getCustomerOrders({pageNumber:pageIndex+1,pageSize:currentPageSize}),type==="subscriptions"&&getCustomerSubscriptions!=null&&getCustomerSubscriptions({pageNumber:pageIndex+1,pageSize:currentPageSize})},[pageIndex,currentPageSize]);const data=useMemo(()=>type==="subscriptions"?subscriptions??[]:orders??[],[orders,subscriptions]),cols=useMemo(()=>columns,[columns]),pagination=useMemo(()=>({pageIndex,pageSize:currentPageSize}),[pageIndex,currentPageSize]),pageCount=orders?.pageCount??subscriptions?.pageCount??-1,table=useReactTable({data,columns:cols,getSortedRowModel:getSortedRowModel(),getCoreRowModel:getCoreRowModel(),getPaginationRowModel:getPaginationRowModel(),manualPagination:!0,pageCount,state:{sorting,pagination},onSortingChange:setSorting,onPaginationChange:setPagination}),TableHtmlElement="table",TheadHtmlElement="thead",TbodyHtmlElement="tbody",ThHtmlElement="th",TrHtmlElement="tr";useEffect(()=>(type==="orders"&&orders!=null&&setLoading(!1),type==="subscriptions"&&subscriptions!=null&&setLoading(!1),()=>{setLoading(!0)}),[orders,subscriptions]);const LoadingComponent=loadingElement||_jsx("div",{children:"Loading..."}),headerComponent=table.getHeaderGroups().map(headerGroup=>{const columnsComponents=headerGroup.headers.map((header,k)=>{const sortLabel=header.column.getIsSorted()!==!1?header.column.getIsSorted():"";return _jsx(ThHtmlElement,{"data-testid":`thead-${k}`,"data-sort":`${sortLabel||""}`,className:columns[k]?.className,children:_jsxs("span",{className:`${columns[k]?.titleClassName??""} ${header.column.getCanSort()?"cursor-pointer select-none":""}`,onClick:header.column.getToggleSortingHandler(),children:[flexRender(header.column.columnDef.header,header.getContext()),{asc:sortAscIcon,desc:sortDescIcon}[header.column.getIsSorted()]??null]})},header.id)});return _jsx(TrHtmlElement,{children:columnsComponents},headerGroup.id)}),rowsComponents=filterChildren({children,filterBy:rowComponents,componentName:"OrderList"}),components=table.getRowModel().rows.map(row=>{const childProps={type,orders:type==="orders"?orders:subscriptions,order:row.original,row,showActions,actionsComponent,actionsContainerClassName};return _jsx(TrHtmlElement,{className:rowTrClassName,children:_jsx(OrderListChildrenContext.Provider,{value:childProps,children:rowsComponents})},row.id)}),pagComponents=filterChildren({children,filterBy:paginationComponents,componentName:"OrderList"}),totalRows=orders?.meta.recordCount??subscriptions?.meta.recordCount??0,Pagination=()=>showPagination?_jsx(OrderListPagination.Provider,{value:{canNextPage:table.getCanNextPage(),canPreviousPage:table.getCanPreviousPage(),gotoPage:table.setPageIndex,nextPage:table.nextPage,pageCount:table.getPageCount(),pageIndex:table.getState().pagination.pageIndex,pageOptions:table.getPageOptions(),pageSize:table.getState().pagination.pageSize,previousPage:table.previousPage,setPageSize:table.setPageSize,totalRows},children:pagComponents}):null;return loading&&(orders==null||subscriptions==null)?_jsx(_Fragment,{children:LoadingComponent}):(type==="orders"?orders:subscriptions)?.length===0?_jsxs(OrderListChildrenContext.Provider,{value:{orders:type==="orders"?orders:subscriptions},children:[rowsComponents,_jsx(Pagination,{})]}):_jsxs(_Fragment,{children:[_jsxs(TableHtmlElement,{...p,children:[_jsx(TheadHtmlElement,{className:theadClassName,children:headerComponent}),_jsx(TbodyHtmlElement,{children:components})]}),totalRows<=pageSize?null:_jsx("div",{className:paginationContainerClassName,children:_jsx(Pagination,{})})]})}export default OrderList;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type OrderListPaginationContext as TOrderListPaginationContext } from '../../context/OrderListPaginationContext';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  interface PaginationButton extends Omit<JSX.IntrinsicElements['button'], 'children' | 'disabled'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  type TAsComponent = keyof Pick<JSX.IntrinsicElements, 'p' | 'span' | 'div'>;
3
4
  type ChildrenProps<A extends TAsComponent> = Omit<Props<A>, 'children'> & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type TOrderList, type OrderListContent, type TableAccessor } from '../../context/OrderListChildrenContext';
2
3
  import { type Row } from '@tanstack/react-table';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseFieldProps } from '../utils/BaseField';
2
3
  type Props = Omit<BaseFieldProps, 'attribute'>;
3
4
  export declare function OrderNumber(props: Props): JSX.Element;
@@ -1,8 +1,31 @@
1
1
  import { type ReactNode } from 'react';
2
2
  interface Props {
3
3
  children: ReactNode;
4
+ /**
5
+ * The key used to persist the order id in the browser local storage.
6
+ */
4
7
  persistKey: string;
8
+ /**
9
+ * Removes the saved order id from the local storage when order is placed.
10
+ * @default true
11
+ */
5
12
  clearWhenPlaced?: boolean;
6
13
  }
14
+ /**
15
+ * This component handle the persistence of the order id in the browser local storage.
16
+ * When adding a product into the cart and the order does not exist yet, in will be created by the `OrderContainer` and
17
+ * the order id will then be automatically saved in the local storage using `OrderStorage` context.
18
+ * In this way on page refresh or components remounting, the `OrderContainer` will be able to load the order getting the id from this context.
19
+ *
20
+ * By default, the localStorage key will be deleted once the order has been placed, but you can disable this behavior via `clearWhenPlaced` prop.
21
+ *
22
+ * <span title="Requirement" type="warning">
23
+ * Must be a child of the `<CommerceLayer>` component. <br />
24
+ * </span>
25
+ *
26
+ * <span title="Children" type="info">
27
+ * `<OrderContainer>`,
28
+ * </span>
29
+ */
7
30
  export declare function OrderStorage(props: Props): JSX.Element;
8
31
  export default OrderStorage;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function PaymentMethodAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default PaymentMethodAmount;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseInputProps } from '../utils/BaseInput';
2
3
  export declare function PrivacyAndTermsCheckbox(props: Partial<BaseInputProps>): JSX.Element;
3
4
  export default PrivacyAndTermsCheckbox;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function ShippingAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default ShippingAmount;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function SubTotalAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default SubTotalAmount;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function TaxesAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default TaxesAmount;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function TotalAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default TotalAmount;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ConditionalElement } from '../../typings/index';
2
3
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
3
4
  type ParcelFieldChildrenProps = TGenericChildrenProps<TResources['Parcel']>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { DefaultChildrenType } from '../../typings/globals';
2
3
  interface Props {
3
4
  children: DefaultChildrenType;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ConditionalElement } from '../../typings/index';
2
3
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
3
4
  type ParcelLineItemFieldChildrenProps = TGenericChildrenProps<TResources['ParcelLineItem']>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  import type { Parcel } from '@commercelayer/sdk';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  interface Props {
2
3
  children: JSX.Element | JSX.Element[];
3
4
  filterBy?: string[];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  import type { Parcel } from '@commercelayer/sdk';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = GatewayBaseType;
3
4
  export declare function AdyenGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = GatewayBaseType;
3
4
  export declare function BraintreeGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = GatewayBaseType;
3
4
  export declare function CheckoutComGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = GatewayBaseType;
3
4
  export declare function ExternalGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = GatewayBaseType;
3
4
  export declare function KlarnaGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LoaderType } from '../../typings/index';
2
3
  import { type PaymentSourceProps } from '../payment_source/PaymentSource';
3
4
  export type GatewayBaseType = Props & {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes,getStripeAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource&&!expressPayments){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config)),config!=null&&paymentResource==="stripe_payments"&&(attributes=getStripeAttributes(paymentResource,config),attributes!=null&&attributes.return_url==null&&(attributes.return_url=window.location.href));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show&&!expressPayments||(!paymentSource&&!expressPayments||paymentSource?.type!==paymentResource)&&show)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return expressPayments&&setLoading(!1),()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
2
+ import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes,getStripeAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource&&!expressPayments){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config)),config!=null&&paymentResource==="stripe_payments"&&(attributes=getStripeAttributes(paymentResource,config),attributes!=null&&attributes.return_url==null&&(attributes.return_url=window.location.href));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show&&!expressPayments||(!paymentSource&&!expressPayments||paymentSource?.type!==paymentResource)&&show)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return expressPayments&&show&&setLoading(!1),()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = Partial<GatewayBaseType>;
3
4
  export declare function PaypalGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = GatewayBaseType;
3
4
  export declare function StripeGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
3
  type Props = GatewayBaseType;
3
4
  export declare function WireTransferGateway(props: Props): JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { LoaderType } from '../../typings/index';
2
3
  import type { Order, PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
3
4
  import type { PaymentResource } from '../../reducers/PaymentMethodReducer';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  interface ChildrenProps extends Omit<Props, 'children'> {
3
4
  labelName: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  interface Props extends BaseAmountComponent {
3
4
  type?: 'amount';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type PaymentSourceProps } from './PaymentSource';
2
3
  import { type HostedFieldFieldOptions } from 'braintree-web';
3
4
  type BraintreeHostedFields<Type> = {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
2
3
  import { type PaymentSourceProps } from './PaymentSource';
3
4
  import { type FramesStyle } from 'frames-react';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  import type { StripeElementLocale } from '@stripe/stripe-js';
3
4
  import { type PaymentSourceProps } from './PaymentSource';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import Parent from"../utils/Parent";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useRef}from"react";export function ExternalPayment(props){const{setPaymentRef}=useContext(PaymentMethodContext),ref=useRef(null);return useEffect(()=>{ref!==null&&(ref.current.onsubmit=async()=>!0,setPaymentRef({ref}))},[ref]),props?.customComponent!=null&&props.show?_jsxs("form",{ref,children:[_jsx(Parent,{children:props.customComponent}),props?.templateCustomerSaveToWallet!=null&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:props.templateCustomerSaveToWallet})]}):null}export default ExternalPayment;
2
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import Parent from"../utils/Parent";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useRef}from"react";import OrderContext from"../../context/OrderContext";export function ExternalPayment(props){const{setPaymentRef}=useContext(PaymentMethodContext),{order,updateOrder}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{ref?.current!=null&&(ref.current.onsubmit=async()=>!0,setPaymentRef({ref}))},[ref]);const parentProps={...props,order,updateOrder};return props?.customComponent!=null&&props.show?_jsxs("form",{ref,children:[_jsx(Parent,{...parentProps,children:props.customComponent}),props?.templateCustomerSaveToWallet!=null&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:props.templateCustomerSaveToWallet})]}):null}export default ExternalPayment;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
2
3
  import { type PaymentSourceProps } from './PaymentSource';
3
4
  type KlarnaPaymentProps = PaymentMethodConfig['klarnaPayment'] & JSX.IntrinsicElements['div'] & Partial<PaymentSourceProps['templateCustomerSaveToWallet']> & {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";function typeOfLine(lineItemType){switch(lineItemType){case"percentage_discount_promotions":return"discount";case"shipments":return"shipping_fee";case"skus":return"physical";case"payment_methods":default:return null}}function klarnaOrderLines(lineItems){return lineItems?lineItems?.map(item=>{const type=item.item_type?typeOfLine(item.item_type):null;return{quantity:item.quantity,total_amount:item.total_amount_cents,unit_price:item.unit_amount_cents,type}}):[]}export default function KlarnaPayment({clientToken,placeOrderCallback,locale="EN",...p}){const ref=useRef(null),{paymentSource,currentPaymentMethodType,setPaymentRef,setPaymentSource}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),loaded=useExternalScript("https://x.klarnacdn.net/kp/lib/v1/api.js"),[klarna,setKlarna]=useState(),{containerClassName,...divProps}=p;useEffect(()=>{loaded&&window?.Klarna!==void 0&&setKlarna(window.Klarna)},[loaded,window.Klarna]),useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&loaded&&klarna&&(ref.current.onsubmit=async props=>{handleClick(klarna,props)},setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType,loaded,klarna]);const handleClick=(kl,props)=>{console.log("props",props);const[first]=paymentSource?.payment_methods||void 0,paymentMethodCategories=first?.identifier,billingAddress={given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:null,organization_name:null,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shippingAddress={given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,email:order?.customer_email,street_address:order?.shipping_address?.line_1,street_address2:null,postal_code:order?.shipping_address?.zip_code,organization_name:null,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code},klarnaData={merchant_data:order?.id,purchase_country:order?.country_code,purchase_currency:order?.currency_code,locale,shipping_address:shippingAddress,billing_address:billingAddress,order_amount:order?.total_amount_cents,order_lines:klarnaOrderLines(order?.line_items),order_tax_amount:order?.total_tax_amount_cents};kl.Payments.authorize({payment_method_category:paymentMethodCategories,...klarnaData},async function(res){if(console.log("res",res),res.approved&&paymentSource&&currentPaymentMethodType){const ps=await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{auth_token:res.authorization_token}});if(props.setPlaceOrder!=null){const placed=await props.setPlaceOrder({paymentSource:ps});placed&&props.onclickCallback!=null&&props.onclickCallback(placed)}}})};if(klarna&&clientToken){const[first]=paymentSource?.payment_methods||void 0;klarna.Payments.init({client_token:clientToken}),klarna.Payments.load({container:"#klarna-payments-container",payment_method_category:first?.identifier})}return _jsx("form",{ref,children:_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"klarna-payments-container"})})})}
2
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";function typeOfLine(lineItemType){switch(lineItemType){case"percentage_discount_promotions":return"discount";case"shipments":return"shipping_fee";case"skus":return"physical";case"payment_methods":default:return null}}function klarnaOrderLines(lineItems){return lineItems?lineItems?.map(item=>{const type=item.item_type?typeOfLine(item.item_type):null;return{quantity:item.quantity,total_amount:item.total_amount_cents,unit_price:item.unit_amount_cents,type}}):[]}export default function KlarnaPayment({clientToken,placeOrderCallback,locale="EN",...p}){const ref=useRef(null),{paymentSource,currentPaymentMethodType,setPaymentRef,setPaymentSource}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),loaded=useExternalScript("https://x.klarnacdn.net/kp/lib/v1/api.js"),[klarna,setKlarna]=useState(),{containerClassName,...divProps}=p;useEffect(()=>{loaded&&window?.Klarna!==void 0&&setKlarna(window.Klarna)},[loaded,window.Klarna]),useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&loaded&&klarna&&(ref.current.onsubmit=async props=>{handleClick(klarna,props)},setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType,loaded,klarna]);const handleClick=(kl,props)=>{const[first]=paymentSource?.payment_methods||void 0,paymentMethodCategories=first?.identifier,billingAddress={given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:null,organization_name:null,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shippingAddress={given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,email:order?.customer_email,street_address:order?.shipping_address?.line_1,street_address2:null,postal_code:order?.shipping_address?.zip_code,organization_name:null,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code},klarnaData={merchant_data:order?.id,purchase_country:order?.country_code,purchase_currency:order?.currency_code,locale,shipping_address:shippingAddress,billing_address:billingAddress,order_amount:order?.total_amount_cents,order_lines:klarnaOrderLines(order?.line_items),order_tax_amount:order?.total_tax_amount_cents};kl.Payments.authorize({payment_method_category:paymentMethodCategories,...klarnaData},async function(res){if(res.approved&&paymentSource&&currentPaymentMethodType){const ps=await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{auth_token:res.authorization_token}});if(props.setPlaceOrder!=null){const placed=await props.setPlaceOrder({paymentSource:ps});placed&&props.onclickCallback!=null&&props.onclickCallback(placed)}}})};if(klarna&&clientToken){const[first]=paymentSource?.payment_methods||void 0;klarna.Payments.init({client_token:clientToken}),klarna.Payments.load({container:"#klarna-payments-container",payment_method_category:first?.identifier})}return _jsx("form",{ref,children:_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"klarna-payments-container"})})})}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LoaderType } from '../../typings/index';
2
3
  import { type CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
3
4
  export interface CustomerCardsProps {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!!expressPayments),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
2
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource,currentPaymentMethodType}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId&&!expressPayments?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!!(expressPayments&&currentPaymentMethodType==="stripe_payments")),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order,expressPayments]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type IconBrand } from '../../context/PaymentSourceContext';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type IconBrand } from '../../context/PaymentSourceContext';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  interface CustomComponent extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { ChildrenFunction } from '../../typings/index';
2
3
  export type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  interface Props {
2
3
  clientSecret: string;
3
4
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type StripeElementLocale, type StripeElementsOptions, type StripePaymentElementOptions } from '@stripe/stripe-js';
2
3
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
3
4
  import { type PaymentSourceProps } from './PaymentSource';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface WireTransferConfig {
2
3
  infoMessage?: {
3
4
  text?: string | JSX.Element[];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type Price as PriceType } from '@commercelayer/sdk';
2
3
  import { type ChildrenFunction, type LoaderType } from '../../typings/index';
3
4
  interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LoaderType } from '../../typings/index';
2
3
  interface Props {
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type Shipment } from '@commercelayer/sdk';
2
3
  type ShipmentFieldChildrenProps = Omit<Props, 'children'> & {
3
4
  shipment: Shipment;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  import type { Shipment } from '@commercelayer/sdk';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ShippingMethod } from '@commercelayer/sdk';
2
3
  type ChildrenProps = Omit<Props, 'children'> & {
3
4
  label: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  type Props = BaseAmountComponent & {
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { Order, ShippingMethod } from '@commercelayer/sdk';
2
3
  interface ShippingMethodRadioButtonType extends Omit<Props, 'children'> {
3
4
  shippingMethod: ShippingMethod;
@@ -1,8 +1,34 @@
1
1
  import { type ReactNode } from 'react';
2
2
  interface Props {
3
+ /**
4
+ * The children component
5
+ */
3
6
  children: ReactNode;
7
+ /**
8
+ * The sku code
9
+ */
4
10
  skuCode?: string;
11
+ /**
12
+ * The sku id. If you use this prop, the skuCode will be ignored and the sku will be fetched by id improving the performance
13
+ */
14
+ skuId?: string;
15
+ /**
16
+ * Callback called when the quantity is updated
17
+ */
5
18
  getQuantity?: (quantity: number) => void;
6
19
  }
7
- export declare function AvailabilityContainer({ children, skuCode, getQuantity }: Props): JSX.Element;
20
+ /**
21
+ * Main container for the Availability components.
22
+ * It stores - in its context - the sku quantity returned from the `inventory_model` and the `delivery_lead_time` for the first shipping method found in the inventory model.
23
+ *
24
+ * It can be used to fetch the quantities for a specific `sku_code` passed as prop.
25
+ * <span title='Requirements' type='warning'>
26
+ * Must be a child of the `<CommerceLayer>` component. <br/>
27
+ * Can be a child of the `<SkusContainer>` component and receive the `sku_code` from its context.
28
+ * </span>
29
+ * <span title='Children' type='info'>
30
+ * `<AvailabilityTemplate>`
31
+ * </span>
32
+ */
33
+ export declare function AvailabilityContainer({ children, skuCode, skuId, getQuantity }: Props): JSX.Element;
8
34
  export default AvailabilityContainer;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useReducer,useEffect,useMemo}from"react";import availabilityReducer,{availabilityInitialState,getAvailability}from"../../reducers/AvailabilityReducer";import AvailabilityContext from"../../context/AvailabilityContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import SkuChildrenContext from"../../context/SkuChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityContainer({children,skuCode,getQuantity}){const{lineItem}=useContext(LineItemChildrenContext),{sku}=useContext(SkuChildrenContext),{accessToken,endpoint}=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"AvailabilityContainer",key:"accessToken"}),[state,dispatch]=useReducer(availabilityReducer,availabilityInitialState),sCode=skuCode||lineItem?.sku_code||sku?.code;useEffect(()=>(accessToken!=null&&accessToken!==""&&sCode&&getAvailability({skuCode:sCode,config:{accessToken,endpoint},dispatch}),()=>{dispatch({type:"setAvailability",payload:{}})}),[accessToken,sCode]),useEffect(()=>{getQuantity!=null&&state?.quantity!=null&&getQuantity(state?.quantity)},[state.quantity]);const memoized=useMemo(()=>({...state,parent:!0}),[state]);return _jsx(AvailabilityContext.Provider,{value:memoized,children})}export default AvailabilityContainer;
2
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useReducer,useEffect,useMemo}from"react";import availabilityReducer,{availabilityInitialState,getAvailability}from"../../reducers/AvailabilityReducer";import AvailabilityContext from"../../context/AvailabilityContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import SkuChildrenContext from"../../context/SkuChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityContainer({children,skuCode,skuId,getQuantity}){const{lineItem}=useContext(LineItemChildrenContext),{sku}=useContext(SkuChildrenContext),{accessToken,endpoint}=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"AvailabilityContainer",key:"accessToken"}),[state,dispatch]=useReducer(availabilityReducer,availabilityInitialState),sCode=skuCode||lineItem?.sku_code||sku?.code;useEffect(()=>{if(accessToken!=null&&accessToken!==""){const config={accessToken,endpoint};(sCode!=null||skuId!=null)&&getAvailability({skuCode:sCode,skuId,config,dispatch})}return()=>{dispatch({type:"setAvailability",payload:{}})}},[accessToken,sCode,skuId]),useEffect(()=>{getQuantity!=null&&state?.quantity!=null&&getQuantity(state?.quantity)},[state.quantity]);const memoized=useMemo(()=>({...state,parent:!0}),[state]);return _jsx(AvailabilityContext.Provider,{value:memoized,children})}export default AvailabilityContainer;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type TimeFormat, type ChildrenFunction } from '../../typings/index';
2
3
  import { type DeliveryLeadTime } from '../../reducers/AvailabilityReducer';
3
4
  interface AvailabilityTemplateChildrenProps extends Omit<Props, 'children'>, DeliveryLeadTime {
@@ -6,15 +7,16 @@ interface AvailabilityTemplateChildrenProps extends Omit<Props, 'children'>, Del
6
7
  }
7
8
  type FormatRules = {
8
9
  /**
9
- * Set time format for shipping method
10
+ * Set time format for shipping method. When not set, ``delivery_lead_times`` will not be displayed.
11
+ * When set, `delivery_lead_times` for the first shipping method found in the inventory model, will be displayed in the format specified.
10
12
  */
11
13
  timeFormat?: TimeFormat;
12
14
  /**
13
- * Show shipping method name
15
+ * Show shipping method name. Requires `timeFormat` to be set.
14
16
  */
15
17
  showShippingMethodName?: false;
16
18
  /**
17
- * Show shipping method price
19
+ * Show shipping method price. Requires `timeFormat` to be set.
18
20
  */
19
21
  showShippingMethodPrice?: false;
20
22
  } | {
@@ -34,5 +36,17 @@ type Props = {
34
36
  negativeStock?: string;
35
37
  };
36
38
  } & Omit<JSX.IntrinsicElements['span'], 'children'> & FormatRules;
39
+ /**
40
+ * The AvailabilityTemplate component displays the availability of the SKU specified
41
+ * in the parent `<AvailabilityContainer>` component.
42
+ *
43
+ * It is possible to customize the text displayed in case of `available`, `outOfStock` or `negativeStock.
44
+ * It is also possible to show delivery lead time and either shipping method name and/or price.
45
+ * This information will be retrieve from the first shipping method found in the inventory model.
46
+ *
47
+ * <span type="Requirement" type="info">
48
+ * It must to be used inside the `<AvailabilityContainer>` component.
49
+ * </span>
50
+ */
37
51
  export declare function AvailabilityTemplate(props: Props): JSX.Element;
38
52
  export default AvailabilityTemplate;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type DeliveryLeadTimeField = 'min_hours' | 'max_hours' | 'min_days' | 'max_days';
2
3
  export type DeliveryLeadTimeComponentChildren = Omit<Props, 'children'>;
3
4
  type Props = Partial<JSX.IntrinsicElements['span']> & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ConditionalElement } from '../../typings/index';
2
3
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
3
4
  type SkuFieldChildrenProps = TGenericChildrenProps<TResources['Sku']>;
@@ -6,8 +7,19 @@ type Props = {
6
7
  children?: (props: SkuFieldChildrenProps) => JSX.Element;
7
8
  } & TCondition;
8
9
  /**
9
- * @param props {@link Props}
10
- * @returns
10
+ * The SkuField component displays any attribute of the `sku` specified in the parent `<SkusContainer>` component.
11
+ *
12
+ * It also accepts a `tagElement` props to enable specific tag-related props.
13
+ * For examples, when `tagElement` is set to `img` it will also accept props related to `<img>` tag such as `height` and `width`.
14
+ *
15
+ * <span title="Requirement" type="warning">
16
+ * It must to be used inside the `<SkusContainer>` component.
17
+ * </span>
18
+ *
19
+ * <span title="Fields" type="info">
20
+ * Check the `skus` resource from our [Core API documentation](https://docs.commercelayer.io/core/v/api-reference/skus/object)
21
+ * for more details about the available attributes to render.
22
+ * </span>
11
23
  */
12
24
  export declare function SkuField<P extends Props>(props: P): JSX.Element;
13
25
  export default SkuField;
@@ -2,5 +2,17 @@ import { type ReactNode } from 'react';
2
2
  interface Props {
3
3
  children: ReactNode;
4
4
  }
5
+ /**
6
+ * The `Skus` components loop through the list of `skus` found in `SkusContainer` context and render the children filled with the proper sku value.
7
+ * This means that the children will be rendered as many times as the number of skus found in the `skus` prop array
8
+ * and there is no need to manually loop through them from your consumer app.
9
+ *
10
+ * <span title='Requirements' type='warning'>
11
+ * Must be a child of the `<SkusContainer>` component.
12
+ * </span>
13
+ * <span title='Children' type='info'>
14
+ * `<SkuField>`, `<AvailabilityContainer>`
15
+ * </span>
16
+ */
5
17
  export declare function Skus<P extends Props>({ children }: P): JSX.Element;
6
18
  export default Skus;
@@ -6,7 +6,7 @@ interface Props {
6
6
  */
7
7
  skus: string[];
8
8
  /**
9
- * Accept a React node, [Skus](./Skus.d.ts), and [ItemContainer](../ItemContainer.d.ts) as children to display above the skus.
9
+ * Accept a React node and [Skus](./Skus.d.ts) component as children to display above the skus.
10
10
  */
11
11
  children: ReactNode;
12
12
  /**
@@ -14,5 +14,18 @@ interface Props {
14
14
  */
15
15
  queryParams?: QueryParamsList;
16
16
  }
17
+ /**
18
+ * Main container for the SKUs components.
19
+ * It stores - in its context - the details for each `sku` defined in the `skus` prop array.
20
+ *
21
+ * It also accept a `queryParams` prop to refine pagination, sorting, filtering and includes for the fetch request.
22
+ *
23
+ * <span title='Requirements' type='warning'>
24
+ * Must be a child of the `<CommerceLayer>` component.
25
+ * </span>
26
+ * <span title='Children' type='info'>
27
+ * `<Skus>`
28
+ * </span>
29
+ */
17
30
  export declare function SkusContainer<P extends Props>(props: P): JSX.Element;
18
31
  export default SkusContainer;