@commercelayer/react-components 4.8.0-beta.1 → 4.8.0-beta.3

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 (299) 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/LineItemAmount.d.ts +1 -0
  40. package/lib/cjs/components/line_items/LineItemCode.d.ts +1 -0
  41. package/lib/cjs/components/line_items/LineItemField.d.ts +1 -0
  42. package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -0
  43. package/lib/cjs/components/line_items/LineItemName.d.ts +1 -0
  44. package/lib/cjs/components/line_items/LineItemQuantity.d.ts +5 -0
  45. package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
  46. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +1 -0
  47. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
  48. package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -0
  49. package/lib/cjs/components/line_items/LineItemsCount.js +1 -1
  50. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +1 -0
  51. package/lib/cjs/components/orders/AddToCartButton.d.ts +32 -0
  52. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +1 -0
  53. package/lib/cjs/components/orders/CartLink.d.ts +8 -0
  54. package/lib/cjs/components/orders/CartLink.js +1 -1
  55. package/lib/cjs/components/orders/CheckoutLink.d.ts +16 -0
  56. package/lib/cjs/components/orders/DiscountAmount.d.ts +1 -0
  57. package/lib/cjs/components/orders/GiftCardAmount.d.ts +1 -0
  58. package/lib/cjs/components/orders/HostedCart.d.ts +30 -8
  59. package/lib/cjs/components/orders/HostedCart.js +1 -1
  60. package/lib/cjs/components/orders/OrderContainer.d.ts +34 -0
  61. package/lib/cjs/components/orders/OrderContainer.js +1 -1
  62. package/lib/cjs/components/orders/OrderList.d.ts +1 -0
  63. package/lib/cjs/components/orders/OrderList.js +1 -1
  64. package/lib/cjs/components/orders/OrderListEmpty.d.ts +1 -0
  65. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +1 -0
  66. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +1 -0
  67. package/lib/cjs/components/orders/OrderListRow.d.ts +1 -0
  68. package/lib/cjs/components/orders/OrderListRow.js +1 -1
  69. package/lib/cjs/components/orders/OrderNumber.d.ts +1 -0
  70. package/lib/cjs/components/orders/OrderStorage.d.ts +23 -0
  71. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +1 -0
  72. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  73. package/lib/cjs/components/orders/ShippingAmount.d.ts +1 -0
  74. package/lib/cjs/components/orders/SubTotalAmount.d.ts +1 -0
  75. package/lib/cjs/components/orders/TaxesAmount.d.ts +1 -0
  76. package/lib/cjs/components/orders/TotalAmount.d.ts +1 -0
  77. package/lib/cjs/components/parcels/ParcelField.d.ts +1 -0
  78. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +1 -0
  79. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +1 -0
  80. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  81. package/lib/cjs/components/parcels/Parcels.d.ts +1 -0
  82. package/lib/cjs/components/parcels/ParcelsCount.d.ts +1 -0
  83. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -0
  84. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  85. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  86. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +1 -0
  87. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  88. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +1 -0
  89. package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
  90. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -0
  91. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -0
  92. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  93. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -0
  94. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +1 -0
  95. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  96. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +1 -0
  97. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +1 -0
  98. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +1 -0
  99. package/lib/cjs/components/payment_source/ExternalPayment.js +1 -1
  100. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -0
  101. package/lib/cjs/components/payment_source/PaymentSource.d.ts +1 -0
  102. package/lib/cjs/components/payment_source/PaymentSource.js +1 -1
  103. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  104. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  105. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  106. package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +1 -0
  107. package/lib/cjs/components/payment_source/StripePayment.d.ts +1 -0
  108. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +1 -0
  109. package/lib/cjs/components/prices/Price.d.ts +1 -0
  110. package/lib/cjs/components/prices/PricesContainer.d.ts +1 -0
  111. package/lib/cjs/components/shipments/ShipmentField.d.ts +1 -0
  112. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +1 -0
  113. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  114. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  115. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  116. package/lib/cjs/components/skus/AvailabilityContainer.d.ts +27 -1
  117. package/lib/cjs/components/skus/AvailabilityContainer.js +1 -1
  118. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +17 -3
  119. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +1 -0
  120. package/lib/cjs/components/skus/SkuField.d.ts +14 -2
  121. package/lib/cjs/components/skus/Skus.d.ts +12 -0
  122. package/lib/cjs/components/skus/SkusContainer.d.ts +14 -1
  123. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +1 -0
  124. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +1 -0
  125. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -0
  126. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +1 -0
  127. package/lib/cjs/components/utils/GenericFieldComponent.d.ts +6 -0
  128. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +1 -0
  129. package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -0
  130. package/lib/cjs/components/utils/getAllErrors.d.ts +1 -0
  131. package/lib/cjs/reducers/AddressReducer.js +1 -1
  132. package/lib/cjs/reducers/AvailabilityReducer.d.ts +3 -2
  133. package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
  134. package/lib/cjs/reducers/CustomerReducer.d.ts +1 -1
  135. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  136. package/lib/cjs/reducers/LineItemReducer.d.ts +2 -1
  137. package/lib/cjs/reducers/LineItemReducer.js +1 -1
  138. package/lib/cjs/typings/globals.d.ts +1 -0
  139. package/lib/cjs/utils/addressesManager.d.ts +5 -4
  140. package/lib/cjs/utils/addressesManager.js +1 -1
  141. package/lib/cjs/utils/countryStateCity.d.ts +798 -5
  142. package/lib/cjs/utils/countryStateCity.js +1 -1
  143. package/lib/cjs/utils/filterChildren.d.ts +1 -0
  144. package/lib/cjs/utils/getLoaderComponent.d.ts +1 -0
  145. package/lib/cjs/utils/getPrices.d.ts +1 -0
  146. package/lib/cjs/utils/validateFormFields.d.ts +1 -1
  147. package/lib/cjs/utils/validateFormFields.js +1 -1
  148. package/lib/esm/components/MetadataInput.d.ts +1 -0
  149. package/lib/esm/components/addresses/Address.d.ts +18 -0
  150. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +24 -0
  151. package/lib/esm/components/addresses/AddressCountrySelector.js +1 -1
  152. package/lib/esm/components/addresses/AddressField.d.ts +22 -0
  153. package/lib/esm/components/addresses/AddressInput.d.ts +19 -0
  154. package/lib/esm/components/addresses/AddressInput.js +1 -1
  155. package/lib/esm/components/addresses/AddressStateSelector.d.ts +26 -0
  156. package/lib/esm/components/addresses/AddressStateSelector.js +1 -1
  157. package/lib/esm/components/addresses/AddressesContainer.d.ts +22 -0
  158. package/lib/esm/components/addresses/AddressesEmpty.d.ts +13 -0
  159. package/lib/esm/components/addresses/BillingAddressForm.d.ts +20 -0
  160. package/lib/esm/components/addresses/SaveAddressesButton.js +1 -1
  161. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +1 -0
  162. package/lib/esm/components/addresses/ShippingAddressForm.d.ts +17 -0
  163. package/lib/esm/components/auth/CommerceLayer.d.ts +1 -0
  164. package/lib/esm/components/customers/CustomerAddressForm.d.ts +5 -0
  165. package/lib/esm/components/customers/CustomerAddressForm.js +1 -1
  166. package/lib/esm/components/customers/CustomerContainer.d.ts +20 -1
  167. package/lib/esm/components/customers/CustomerField.d.ts +16 -0
  168. package/lib/esm/components/customers/CustomerInput.d.ts +1 -0
  169. package/lib/esm/components/customers/CustomerInput.js +1 -1
  170. package/lib/esm/components/customers/CustomerPaymentSource.d.ts +1 -0
  171. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
  172. package/lib/esm/components/customers/MyAccountLink.d.ts +11 -0
  173. package/lib/esm/components/customers/MyIdentityLink.d.ts +16 -0
  174. package/lib/esm/components/customers/MyIdentityLink.js +1 -1
  175. package/lib/esm/components/errors/Errors.d.ts +1 -0
  176. package/lib/esm/components/errors/Errors.js +1 -1
  177. package/lib/esm/components/gift_cards/GiftCard.d.ts +1 -0
  178. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
  179. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -0
  180. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
  181. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
  182. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
  183. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
  184. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
  185. package/lib/esm/components/line_items/LineItem.d.ts +1 -0
  186. package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -0
  187. package/lib/esm/components/line_items/LineItemCode.d.ts +1 -0
  188. package/lib/esm/components/line_items/LineItemField.d.ts +1 -0
  189. package/lib/esm/components/line_items/LineItemImage.d.ts +1 -0
  190. package/lib/esm/components/line_items/LineItemName.d.ts +1 -0
  191. package/lib/esm/components/line_items/LineItemQuantity.d.ts +5 -0
  192. package/lib/esm/components/line_items/LineItemQuantity.js +1 -1
  193. package/lib/esm/components/line_items/LineItemsContainer.d.ts +1 -0
  194. package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
  195. package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -0
  196. package/lib/esm/components/line_items/LineItemsCount.js +1 -1
  197. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +1 -0
  198. package/lib/esm/components/orders/AddToCartButton.d.ts +32 -0
  199. package/lib/esm/components/orders/AdjustmentAmount.d.ts +1 -0
  200. package/lib/esm/components/orders/CartLink.d.ts +8 -0
  201. package/lib/esm/components/orders/CartLink.js +1 -1
  202. package/lib/esm/components/orders/CheckoutLink.d.ts +16 -0
  203. package/lib/esm/components/orders/DiscountAmount.d.ts +1 -0
  204. package/lib/esm/components/orders/GiftCardAmount.d.ts +1 -0
  205. package/lib/esm/components/orders/HostedCart.d.ts +30 -8
  206. package/lib/esm/components/orders/HostedCart.js +1 -1
  207. package/lib/esm/components/orders/OrderContainer.d.ts +34 -0
  208. package/lib/esm/components/orders/OrderContainer.js +1 -1
  209. package/lib/esm/components/orders/OrderList.d.ts +1 -0
  210. package/lib/esm/components/orders/OrderList.js +1 -1
  211. package/lib/esm/components/orders/OrderListEmpty.d.ts +1 -0
  212. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +1 -0
  213. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +1 -0
  214. package/lib/esm/components/orders/OrderListRow.d.ts +1 -0
  215. package/lib/esm/components/orders/OrderListRow.js +1 -1
  216. package/lib/esm/components/orders/OrderNumber.d.ts +1 -0
  217. package/lib/esm/components/orders/OrderStorage.d.ts +23 -0
  218. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +1 -0
  219. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  220. package/lib/esm/components/orders/ShippingAmount.d.ts +1 -0
  221. package/lib/esm/components/orders/SubTotalAmount.d.ts +1 -0
  222. package/lib/esm/components/orders/TaxesAmount.d.ts +1 -0
  223. package/lib/esm/components/orders/TotalAmount.d.ts +1 -0
  224. package/lib/esm/components/parcels/ParcelField.d.ts +1 -0
  225. package/lib/esm/components/parcels/ParcelLineItem.d.ts +1 -0
  226. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +1 -0
  227. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  228. package/lib/esm/components/parcels/Parcels.d.ts +1 -0
  229. package/lib/esm/components/parcels/ParcelsCount.d.ts +1 -0
  230. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -0
  231. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  232. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  233. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +1 -0
  234. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  235. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +1 -0
  236. package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
  237. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -0
  238. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -0
  239. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  240. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -0
  241. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +1 -0
  242. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  243. package/lib/esm/components/payment_source/BraintreePayment.d.ts +1 -0
  244. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +1 -0
  245. package/lib/esm/components/payment_source/ExternalPayment.d.ts +1 -0
  246. package/lib/esm/components/payment_source/ExternalPayment.js +1 -1
  247. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -0
  248. package/lib/esm/components/payment_source/PaymentSource.d.ts +1 -0
  249. package/lib/esm/components/payment_source/PaymentSource.js +1 -1
  250. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  251. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  252. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  253. package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +1 -0
  254. package/lib/esm/components/payment_source/StripePayment.d.ts +1 -0
  255. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +1 -0
  256. package/lib/esm/components/prices/Price.d.ts +1 -0
  257. package/lib/esm/components/prices/PricesContainer.d.ts +1 -0
  258. package/lib/esm/components/shipments/ShipmentField.d.ts +1 -0
  259. package/lib/esm/components/shipments/ShipmentsCount.d.ts +1 -0
  260. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  261. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  262. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  263. package/lib/esm/components/skus/AvailabilityContainer.d.ts +27 -1
  264. package/lib/esm/components/skus/AvailabilityContainer.js +1 -1
  265. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +17 -3
  266. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +1 -0
  267. package/lib/esm/components/skus/SkuField.d.ts +14 -2
  268. package/lib/esm/components/skus/Skus.d.ts +12 -0
  269. package/lib/esm/components/skus/SkusContainer.d.ts +14 -1
  270. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +1 -0
  271. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +1 -0
  272. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -0
  273. package/lib/esm/components/utils/BaseOrderPrice.d.ts +1 -0
  274. package/lib/esm/components/utils/GenericFieldComponent.d.ts +6 -0
  275. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +1 -0
  276. package/lib/esm/components/utils/PriceTemplate.d.ts +1 -0
  277. package/lib/esm/components/utils/getAllErrors.d.ts +1 -0
  278. package/lib/esm/reducers/AddressReducer.js +1 -1
  279. package/lib/esm/reducers/AvailabilityReducer.d.ts +3 -2
  280. package/lib/esm/reducers/AvailabilityReducer.js +1 -1
  281. package/lib/esm/reducers/CustomerReducer.d.ts +1 -1
  282. package/lib/esm/reducers/CustomerReducer.js +1 -1
  283. package/lib/esm/reducers/LineItemReducer.d.ts +2 -1
  284. package/lib/esm/reducers/LineItemReducer.js +1 -1
  285. package/lib/esm/typings/globals.d.ts +1 -0
  286. package/lib/esm/utils/addressesManager.d.ts +5 -4
  287. package/lib/esm/utils/addressesManager.js +1 -1
  288. package/lib/esm/utils/countryStateCity.d.ts +798 -5
  289. package/lib/esm/utils/countryStateCity.js +1 -1
  290. package/lib/esm/utils/filterChildren.d.ts +1 -0
  291. package/lib/esm/utils/getLoaderComponent.d.ts +1 -0
  292. package/lib/esm/utils/getPrices.d.ts +1 -0
  293. package/lib/esm/utils/validateFormFields.d.ts +1 -1
  294. package/lib/esm/utils/validateFormFields.js +1 -1
  295. package/package.json +2 -4
  296. package/lib/cjs/utils/isEmptyStates.d.ts +0 -1
  297. package/lib/cjs/utils/isEmptyStates.js +0 -2
  298. package/lib/esm/utils/isEmptyStates.d.ts +0 -1
  299. package/lib/esm/utils/isEmptyStates.js +0 -2
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseInputComponentProps } from '../../typings/index';
2
3
  import { type OrderCodeType } from '../../reducers/OrderReducer';
3
4
  type Props = {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  interface Props extends Omit<JSX.IntrinsicElements['button'], 'children' | 'onClick'> {
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type DefaultChildrenType } from '../../typings/globals';
2
3
  interface Props {
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type TLineItem = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
2
3
  interface Props {
3
4
  children: JSX.Element | JSX.Element[];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent, type BasePriceType } from '../../typings/index';
2
3
  type Props = BaseAmountComponent & {
3
4
  type?: BasePriceType;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LineItem } from '@commercelayer/sdk';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  export interface TLineItemCode extends Omit<Props, 'children'> {
@@ -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 LineItemFieldChildrenProps = TGenericChildrenProps<TResources['LineItem']>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LineItem } from '@commercelayer/sdk';
2
3
  import type { ChildrenFunction } from '../../typings/index';
3
4
  import { type TLineItem } from './LineItem';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { LineItem } from '@commercelayer/sdk';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  export interface TLineItemName extends Omit<Props, 'children'> {
@@ -11,6 +11,11 @@ type Props = {
11
11
  max?: number;
12
12
  disabled?: boolean;
13
13
  readonly?: boolean;
14
+ /**
15
+ * force the update of the line item price using `_external_price: true` attribute
16
+ * @link https://docs.commercelayer.io/core/external-resources/external-prices
17
+ */
18
+ hasExternalPrice?: boolean;
14
19
  } & (Omit<JSX.IntrinsicElements['select'], 'children'> & Omit<JSX.IntrinsicElements['span'], 'children'>);
15
20
  export declare function LineItemQuantity(props: Props): JSX.Element;
16
21
  export default LineItemQuantity;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemQuantity=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemChildrenContext_1=tslib_1.__importDefault(require("../../context/LineItemChildrenContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function LineItemQuantity(props){var _a;const{max=50,readonly=!1}=props,p=tslib_1.__rest(props,["max","readonly"]),{lineItem}=(0,react_1.useContext)(LineItemChildrenContext_1.default),{updateLineItem}=(0,react_1.useContext)(LineItemContext_1.default),options=[];for(let i=1;i<=max;i++)options.push((0,jsx_runtime_1.jsx)("option",{value:`${i}`,children:i},i));const handleChange=e=>{const quantity2=Number(e.target.value);updateLineItem&&lineItem&&updateLineItem(lineItem.id,quantity2)},quantity=lineItem?.quantity,parentProps=Object.assign({handleChange,quantity,lineItem},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):readonly?(0,jsx_runtime_1.jsx)("span",Object.assign({},p,{children:quantity})):(0,jsx_runtime_1.jsx)("select",Object.assign({"data-testid":lineItem?.sku_code,title:(_a=lineItem?.name)!==null&&_a!==void 0?_a:"",value:quantity,onChange:handleChange},p,{children:options}))}exports.LineItemQuantity=LineItemQuantity,exports.default=LineItemQuantity;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemQuantity=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemChildrenContext_1=tslib_1.__importDefault(require("../../context/LineItemChildrenContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function LineItemQuantity(props){var _a;const{max=50,readonly=!1,hasExternalPrice}=props,p=tslib_1.__rest(props,["max","readonly","hasExternalPrice"]),{lineItem}=(0,react_1.useContext)(LineItemChildrenContext_1.default),{updateLineItem}=(0,react_1.useContext)(LineItemContext_1.default),options=[];for(let i=1;i<=max;i++)options.push((0,jsx_runtime_1.jsx)("option",{value:`${i}`,children:i},i));const handleChange=e=>{const quantity2=Number(e.target.value);updateLineItem&&lineItem&&updateLineItem(lineItem.id,quantity2,hasExternalPrice)},quantity=lineItem?.quantity,parentProps=Object.assign({handleChange,quantity,lineItem},props);return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:props.children})):readonly?(0,jsx_runtime_1.jsx)("span",Object.assign({},p,{children:quantity})):(0,jsx_runtime_1.jsx)("select",Object.assign({"data-testid":lineItem?.sku_code,title:(_a=lineItem?.name)!==null&&_a!==void 0?_a:"",value:quantity,onChange:handleChange},p,{children:options}))}exports.LineItemQuantity=LineItemQuantity,exports.default=LineItemQuantity;
@@ -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,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemsContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemReducer_1=tslib_1.__importStar(require("../../reducers/LineItemReducer")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext"));function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=(0,react_1.useContext)(OrderContext_1.default),config=(0,react_1.useContext)(CommerceLayerContext_1.default),[state,dispatch]=(0,react_1.useReducer)(LineItemReducer_1.default,LineItemReducer_1.lineItemInitialState);(0,react_1.useEffect)(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),(0,react_1.useEffect)(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue=Object.assign(Object.assign({},state),{loader,updateLineItem:(lineItemId,quantity=1)=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,LineItemReducer_1.updateLineItem)({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors})}),deleteLineItem:lineItemId=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,LineItemReducer_1.deleteLineItem)({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})})});return(0,jsx_runtime_1.jsx)(LineItemContext_1.default.Provider,{value:lineItemValue,children:state.loading?loader:children})}exports.LineItemsContainer=LineItemsContainer,exports.default=LineItemsContainer;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemsContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemReducer_1=tslib_1.__importStar(require("../../reducers/LineItemReducer")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext"));function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=(0,react_1.useContext)(OrderContext_1.default),config=(0,react_1.useContext)(CommerceLayerContext_1.default),[state,dispatch]=(0,react_1.useReducer)(LineItemReducer_1.default,LineItemReducer_1.lineItemInitialState);(0,react_1.useEffect)(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),(0,react_1.useEffect)(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue=Object.assign(Object.assign({},state),{loader,updateLineItem:(lineItemId,quantity=1,hasExternalPrice)=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,LineItemReducer_1.updateLineItem)({lineItemId,quantity,hasExternalPrice,dispatch,config,getOrder,orderId,errors:state.errors})}),deleteLineItem:lineItemId=>tslib_1.__awaiter(this,void 0,void 0,function*(){yield(0,LineItemReducer_1.deleteLineItem)({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})})});return(0,jsx_runtime_1.jsx)(LineItemContext_1.default.Provider,{value:lineItemValue,children:state.loading?loader:children})}exports.LineItemsContainer=LineItemsContainer,exports.default=LineItemsContainer;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type TypeAccepted } from '../../utils/getLineItemsCount';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemsCount=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),getLineItemsCount_1=tslib_1.__importDefault(require("../../utils/getLineItemsCount")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext"));function LineItemsCount(props){const{children,typeAccepted}=props,p=tslib_1.__rest(props,["children","typeAccepted"]),{lineItems}=(0,react_1.useContext)(LineItemContext_1.default),[quantity,setQuantity]=(0,react_1.useState)(0);(0,react_1.useEffect)(()=>{if(lineItems&&lineItems.length>0){const qty=(0,getLineItemsCount_1.default)({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps=Object.assign({quantity,typeAccepted},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("span",Object.assign({},p,{children:quantity}))}exports.LineItemsCount=LineItemsCount,exports.default=LineItemsCount;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LineItemsCount=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),getLineItemsCount_1=tslib_1.__importDefault(require("../../utils/getLineItemsCount")),LineItemContext_1=tslib_1.__importDefault(require("../../context/LineItemContext")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function LineItemsCount(props){const{children,typeAccepted}=props,p=tslib_1.__rest(props,["children","typeAccepted"]),{lineItems}=(0,useCustomContext_1.default)({context:LineItemContext_1.default,contextComponentName:"LineItemsContainer",currentComponentName:"LineItemsCount",key:"lineItems"}),[quantity,setQuantity]=(0,react_1.useState)(0);(0,react_1.useEffect)(()=>{if(lineItems&&lineItems.length>0){const qty=(0,getLineItemsCount_1.default)({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps=Object.assign({quantity,typeAccepted},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("span",Object.assign({},p,{children:quantity}))}exports.LineItemsCount=LineItemsCount,exports.default=LineItemsCount;
@@ -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
  quantity: number;
@@ -5,14 +5,26 @@ interface TAddToCartButton extends Omit<Props, 'children'> {
5
5
  handleClick: () => AddToCartReturn;
6
6
  }
7
7
  type BuyNowMode = {
8
+ /**
9
+ * Once item has been added, it redirects to the hosted checkout micro-frontend.
10
+ */
8
11
  buyNowMode: true;
12
+ /**
13
+ * If you have a self-hosted checkout, you can pass the url to redirect to it.
14
+ */
9
15
  checkoutUrl?: string;
10
16
  } | {
11
17
  buyNowMode?: false;
12
18
  checkoutUrl?: never;
13
19
  };
14
20
  type THostedCart = {
21
+ /**
22
+ * Once item has been added, it redirects to the hosted cart micro-frontend.
23
+ */
15
24
  redirectToHostedCart: true;
25
+ /**
26
+ * If you have a self-hosted cart, you can pass the url to redirect to it.
27
+ */
16
28
  hostedCartUrl?: string;
17
29
  } | {
18
30
  redirectToHostedCart?: false;
@@ -54,5 +66,25 @@ type Props = {
54
66
  */
55
67
  skuListId?: string;
56
68
  } & TButton & BuyNowMode & THostedCart;
69
+ /**
70
+ * This component adds `line_items` to the cart (aka draft order), see the [how to create a shopping cart](https://docs.commercelayer.io/core/v/how-tos/placing-orders/shopping-cart/create-a-shopping-cart) documentation,
71
+ * for a general understanding of the process.
72
+ *
73
+ * It can be used to add `skus` or `bundle` by receiving `skuCode` or `bundleCode` from props.
74
+ * When `skuListId` is passed as prop , it will add all the `skus` in the `sku_list` to the cart.
75
+ *
76
+ * It's possible to select the quantity of the item to add to cart by passing the `quantity` prop.
77
+ *
78
+ * When this component is used inside a `<Skus>` or `<SkuList>` component, it will automatically get the `skuCode` and quantity from the context,
79
+ * so you don't need to pass it as prop.
80
+ *
81
+ * It can automatically redirect to the cart page of the application using the `redirectToHostedCart` prop and optionally a `hostedCartUrl`.
82
+ *
83
+ * With a similar logic, you can enable a "Buy Now" experience and automatically redirect the customer to the checkout page using the `buyNowMode` prop and optionally a `checkoutUrl`.
84
+ *
85
+ * <span title="Requirement" type="warning">
86
+ * Must be a child of the `<OrderContainer>` component.
87
+ * </span>
88
+ */
57
89
  export declare function AddToCartButton(props: Props): JSX.Element;
58
90
  export default AddToCartButton;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function AdjustmentAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default AdjustmentAmount;
@@ -35,5 +35,13 @@ interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
35
35
  */
36
36
  customDomain?: string;
37
37
  }
38
+ /**
39
+ * This component generates a link to the hosted mfe-cart application.
40
+ * In this way you can connect your shop application with our hosted micro-frontend.
41
+ *
42
+ * <span title="Requirement" type="warning">
43
+ * Must be a child of the `<OrderContainer>` component. <br />
44
+ * </span>
45
+ */
38
46
  export declare function CartLink(props: Props): JSX.Element | null;
39
47
  export default CartLink;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CartLink=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),events_1=require("../../utils/events");function CartLink(props){const{label,children,type,customDomain}=props,p=tslib_1.__rest(props,["label","children","type","customDomain"]),{order,createOrder}=(0,react_1.useContext)(OrderContext_1.default),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);if(accessToken==null)throw new Error("Cannot use `CartLink` outside of `CommerceLayer`");if(endpoint==null)throw new Error("Cannot use `CartLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint),href=slug&&order?.id?(0,getApplicationLink_1.getApplicationLink)({slug,orderId:order?.id,accessToken,domain,applicationType:"cart",customDomain}):"",handleClick=event=>tslib_1.__awaiter(this,void 0,void 0,function*(){if(event.preventDefault(),type!=="mini")if(order?.id)location.href=href;else{const orderId=yield createOrder({});slug&&(location.href=(0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain}))}else(0,events_1.publish)("open-cart")}),parentProps=Object.assign({handleClick,label,href,orderId:order?.id,accessToken},p);return accessToken?children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href},p,{onClick:e=>{handleClick(e)},children:label})):null}exports.CartLink=CartLink,exports.default=CartLink;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CartLink=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),events_1=require("../../utils/events");function CartLink(props){const{label,children,type,customDomain}=props,p=tslib_1.__rest(props,["label","children","type","customDomain"]),{order,createOrder}=(0,react_1.useContext)(OrderContext_1.default),{accessToken,endpoint}=(0,react_1.useContext)(CommerceLayerContext_1.default);if(accessToken==null)throw new Error("Cannot use `CartLink` outside of `CommerceLayer`");if(endpoint==null)throw new Error("Cannot use `CartLink` outside of `CommerceLayer`");const{domain,slug}=(0,getDomain_1.getDomain)(endpoint),href=slug&&order?.id?(0,getApplicationLink_1.getApplicationLink)({slug,orderId:order?.id,accessToken,domain,applicationType:"cart",customDomain}):void 0,handleClick=event=>tslib_1.__awaiter(this,void 0,void 0,function*(){if(event.preventDefault(),type!=="mini")if(order?.id)location.href=href??"";else{const orderId=yield createOrder({});slug&&(location.href=(0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain}))}else(0,events_1.publish)("open-cart")}),parentProps=Object.assign({handleClick,label,href,orderId:order?.id,accessToken},p);return accessToken?children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("a",Object.assign({href,onClick:e=>{handleClick(e)}},p,{children:label})):null}exports.CartLink=CartLink,exports.default=CartLink;
@@ -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
  checkoutUrl: string;
@@ -5,8 +6,23 @@ interface ChildrenProps extends Omit<Props, 'children'> {
5
6
  }
6
7
  interface Props extends Omit<JSX.IntrinsicElements['a'], 'children'> {
7
8
  children?: ChildrenFunction<ChildrenProps>;
9
+ /**
10
+ * Label for the checkout link
11
+ */
8
12
  label?: string;
13
+ /**
14
+ * Ignores `order.checkout_url` and redirects to the hosted checkout micro-frontend.
15
+ * @default true
16
+ */
9
17
  hostedCheckout?: boolean;
10
18
  }
19
+ /**
20
+ * This component generates a link to the hosted mfe-checkout application.
21
+ * In this way you can connect your shop application with our hosted micro-frontend.
22
+ *
23
+ * By default it will takes the customer to our hosted checkout micro-frontend,
24
+ * but if `hostedCheckout` is set as `false` it will use the `checkout_url` attribute
25
+ * found in the `order` object.
26
+ */
11
27
  export declare function CheckoutLink(props: Props): JSX.Element;
12
28
  export default CheckoutLink;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function DiscountAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default DiscountAmount;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  export declare function GiftCardAmount(props: BaseAmountComponent): JSX.Element;
3
4
  export default GiftCardAmount;
@@ -7,30 +7,52 @@ interface Styles {
7
7
  iconContainer?: CSSProperties;
8
8
  }
9
9
  interface Props extends Omit<JSX.IntrinsicElements['div'], 'children' | 'style'> {
10
+ /**
11
+ * The style of the cart.
12
+ */
13
+ style?: Styles;
14
+ /**
15
+ * The domain of your forked application.
16
+ */
17
+ customDomain?: string;
10
18
  /**
11
19
  * The type of the cart. Defaults to undefined.
12
20
  */
13
21
  type?: 'mini';
14
22
  /**
15
23
  * If true, the cart will open when a line item is added to the order clicking the add to cart button. Defaults to false.
24
+ * Works only with the `type` prop set to `mini`.
16
25
  */
17
26
  openAdd?: boolean;
18
- /**
19
- * The style of the cart.
20
- */
21
- style?: Styles;
22
27
  /**
23
28
  * If true, the cart will be open. Defaults to false.
29
+ * Works only with the `type` prop set to `mini`.
24
30
  */
25
31
  open?: boolean;
26
32
  /**
27
33
  * A function that will be called when the cart is open and the background is clicked.
34
+ * Works only with the `type` prop set to `mini`.
28
35
  */
29
36
  handleOpen?: () => void;
30
- /**
31
- * The domain of your forked application.
32
- */
33
- customDomain?: string;
34
37
  }
38
+ /**
39
+ * This component allows to embed the cart application in your page as an `<iframe>`.
40
+ *
41
+ * By default, it will be rendered as inline cart and its content will fit the available container width
42
+ * while the height will be automatically adjusted to the content.
43
+ *
44
+ * Or it can work as mini cart - when `type` prop is set to `mini` - and it will be opened in a modal (popup).
45
+ *
46
+ * <span title="Requirement" type="warning">
47
+ * Must be a child of the `<OrderContainer>` component.
48
+ * </span>
49
+ *
50
+ * <span title="Mini cart" type="info">
51
+ * When set as `mini` cart, it requires the `<CartLink type='mini' />` component to be on the same page,
52
+ * to show the cart when clicked. <br />
53
+ * View the `<CartLink />` component documentation for more details and examples.
54
+ * </span>
55
+ *
56
+ */
35
57
  export declare function HostedCart({ type, openAdd, style, open, handleOpen, customDomain, ...props }: Props): JSX.Element | null;
36
58
  export {};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HostedCart=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),OrderStorageContext_1=tslib_1.__importDefault(require("../../context/OrderStorageContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext")),react_1=require("react"),iframe_resizer_1=require("iframe-resizer"),events_1=require("../../utils/events"),defaultIframeStyle={width:"1px",minWidth:"100%",minHeight:"100%",border:"none"},defaultContainerStyle={position:"fixed",top:"0",right:"-25rem",height:"100%",width:"23rem",transition:"right 0.5s ease-in-out",zIndex:"0",overflow:"auto"},defaultBackgroundStyle={opacity:"0",position:"fixed",top:"0",left:"0",height:"100%",width:"100vw",transition:"opacity 0.5s ease-in-out",zIndex:"-10",backgroundColor:"black"},defaultIconStyle={width:"1.25rem",height:"1.25rem"},defaultIconContainer={textAlign:"left",paddingLeft:"20px",paddingTop:"20px",background:"#ffffff",color:"#686E6E"},defaultStyle={cart:defaultIframeStyle,container:defaultContainerStyle,background:defaultBackgroundStyle,icon:defaultIconStyle,iconContainer:defaultIconContainer};function HostedCart(_a){var _b,_c,_d,_e,{type,openAdd=!1,style,open=!1,handleOpen,customDomain}=_a,props=tslib_1.__rest(_a,["type","openAdd","style","open","handleOpen","customDomain"]);const[isOpen,setOpen]=(0,react_1.useState)(!1),ref=(0,react_1.useRef)(null),{accessToken,endpoint}=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"HostedCart",key:"accessToken"}),[src,setSrc]=(0,react_1.useState)();if(accessToken==null||endpoint==null)return null;const{order,createOrder}=(0,react_1.useContext)(OrderContext_1.default),{persistKey}=(0,react_1.useContext)(OrderStorageContext_1.default),{domain,slug}=(0,getDomain_1.getDomain)(endpoint);function setOrder(openCart){var _a2;return tslib_1.__awaiter(this,void 0,void 0,function*(){const orderId=(_a2=localStorage.getItem(persistKey))!==null&&_a2!==void 0?_a2:yield createOrder({});orderId!=null&&accessToken&&(setSrc((0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain})),openCart&&setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300))})}function onMessage(data){var _a2;switch(data.message.type){case"update":break;case"close":type==="mini"&&(handleOpen!=null?handleOpen():setOpen(!1));break;case"blur":type==="mini"&&isOpen&&((_a2=ref.current)===null||_a2===void 0||_a2.focus());break}}(0,react_1.useEffect)(()=>{var _a2;const orderId=localStorage.getItem(persistKey);let ignore=!1;return open!=null&&open!==isOpen&&setOpen(open),openAdd&&type==="mini"&&(0,events_1.subscribe)("open-cart",()=>{window.document.body.style.overflow="hidden",src==null&&order?.id==null&&orderId==null?setOrder(!0):(src!=null&&ref.current!=null&&(ref.current.src=src),setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300))}),src==null&&order?.id==null&&orderId==null&&accessToken!=null&&!ignore&&isOpen?setOrder():src==null&&(order?.id!=null||orderId!=null)&&accessToken&&setSrc((0,getApplicationLink_1.getApplicationLink)({slug,orderId:(_a2=order?.id)!==null&&_a2!==void 0?_a2:orderId,accessToken,domain,applicationType:"cart"})),src!=null&&ref.current!=null&&(ref.current.src=src),()=>{ignore=!0,openAdd&&type==="mini"&&(0,events_1.unsubscribe)("open-cart",()=>{})}},[src,open,order?.id,accessToken]),(0,react_1.useEffect)(()=>{ref.current!=null&&(0,iframe_resizer_1.iframeResizer)({checkOrigin:!1,bodyPadding:"20px",onMessage},ref.current)},[ref.current!=null]);function onCloseCart(){window.document.body.style.removeProperty("overflow"),handleOpen!=null?handleOpen():setOpen(!1)}return src==null?null:type==="mini"?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)("div",{style:Object.assign(Object.assign(Object.assign({},defaultStyle.background),style?.background),{opacity:isOpen?"0.5":(_b=defaultStyle.background)===null||_b===void 0?void 0:_b.opacity,zIndex:isOpen?"1":(_c=defaultStyle.background)===null||_c===void 0?void 0:_c.zIndex}),onClick:onCloseCart}),(0,jsx_runtime_1.jsxs)("div",Object.assign({style:Object.assign(Object.assign(Object.assign({},defaultStyle.container),style?.container),{right:isOpen?"0":(_d=defaultStyle.container)===null||_d===void 0?void 0:_d.right,zIndex:isOpen?"100":(_e=defaultStyle.container)===null||_e===void 0?void 0:_e.zIndex})},props,{children:[(0,jsx_runtime_1.jsx)("div",{style:Object.assign(Object.assign({},defaultStyle.iconContainer),style?.iconContainer),children:(0,jsx_runtime_1.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",style:Object.assign(Object.assign({},defaultStyle.icon),style?.icon),onClick:onCloseCart,children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})]}))]}):(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})}exports.HostedCart=HostedCart;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HostedCart=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),OrderStorageContext_1=tslib_1.__importDefault(require("../../context/OrderStorageContext")),getApplicationLink_1=require("../../utils/getApplicationLink"),getDomain_1=require("../../utils/getDomain"),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext")),react_1=require("react"),iframe_resizer_1=require("iframe-resizer"),events_1=require("../../utils/events"),defaultIframeStyle={width:"1px",minWidth:"100%",minHeight:"100%",border:"none"},defaultContainerStyle={position:"fixed",top:"0",right:"-25rem",height:"100%",width:"23rem",transition:"right 0.5s ease-in-out",pointerEvents:"none",overflow:"auto"},defaultBackgroundStyle={opacity:"0",position:"fixed",top:"0",left:"0",height:"100%",width:"100vw",transition:"opacity 0.5s ease-in-out",pointerEvents:"none",backgroundColor:"black"},defaultIconStyle={width:"1.25rem",height:"1.25rem"},defaultIconContainer={textAlign:"left",paddingLeft:"20px",paddingTop:"20px",background:"#ffffff",color:"#686E6E"},defaultStyle={cart:defaultIframeStyle,container:defaultContainerStyle,background:defaultBackgroundStyle,icon:defaultIconStyle,iconContainer:defaultIconContainer};function HostedCart(_a){var _b,_c,_d,_e,{type,openAdd=!1,style,open=!1,handleOpen,customDomain}=_a,props=tslib_1.__rest(_a,["type","openAdd","style","open","handleOpen","customDomain"]);const[isOpen,setOpen]=(0,react_1.useState)(!1),ref=(0,react_1.useRef)(null),{accessToken,endpoint}=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"HostedCart",key:"accessToken"}),[src,setSrc]=(0,react_1.useState)();if(accessToken==null||endpoint==null)return null;const{order,createOrder,getOrder}=(0,react_1.useContext)(OrderContext_1.default),{persistKey}=(0,react_1.useContext)(OrderStorageContext_1.default),{domain,slug}=(0,getDomain_1.getDomain)(endpoint);function setOrder(openCart){var _a2;return tslib_1.__awaiter(this,void 0,void 0,function*(){const orderId=(_a2=localStorage.getItem(persistKey))!==null&&_a2!==void 0?_a2:yield createOrder({});orderId!=null&&accessToken&&(setSrc((0,getApplicationLink_1.getApplicationLink)({slug,orderId,accessToken,domain,applicationType:"cart",customDomain})),openCart&&setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300))})}function onMessage(data){var _a2;switch(data.message.type){case"update":data.message.payload!=null&&getOrder(data.message.payload.id);break;case"close":type==="mini"&&(handleOpen!=null?handleOpen():setOpen(!1));break;case"blur":type==="mini"&&isOpen&&((_a2=ref.current)===null||_a2===void 0||_a2.focus());break}}(0,react_1.useEffect)(()=>{var _a2;const orderId=localStorage.getItem(persistKey);let ignore=!1;return open!=null&&open!==isOpen&&setOpen(open),openAdd&&type==="mini"&&(0,events_1.subscribe)("open-cart",()=>{window.document.body.style.overflow="hidden",src==null&&order?.id==null&&orderId==null?setOrder(!0):(src!=null&&ref.current!=null&&(ref.current.src=src),setTimeout(()=>{handleOpen!=null?handleOpen():setOpen(!0)},300))}),src==null&&order?.id==null&&orderId==null&&accessToken!=null&&!ignore&&isOpen?setOrder():src==null&&(order?.id!=null||orderId!=null)&&accessToken&&setSrc((0,getApplicationLink_1.getApplicationLink)({slug,orderId:(_a2=order?.id)!==null&&_a2!==void 0?_a2:orderId,accessToken,domain,applicationType:"cart"})),src!=null&&ref.current!=null&&(ref.current.src=src),()=>{ignore=!0,openAdd&&type==="mini"&&(0,events_1.unsubscribe)("open-cart",()=>{})}},[src,open,order?.id,accessToken]),(0,react_1.useEffect)(()=>{ref.current!=null&&(0,iframe_resizer_1.iframeResizer)({checkOrigin:!1,bodyPadding:"20px",onMessage},ref.current)},[ref.current!=null]);function onCloseCart(){window.document.body.style.removeProperty("overflow"),handleOpen!=null?handleOpen():setOpen(!1)}return src==null?null:type==="mini"?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)("div",{"aria-hidden":"true",style:Object.assign(Object.assign(Object.assign({},defaultStyle.background),style?.background),{opacity:isOpen?"0.5":(_b=defaultStyle.background)===null||_b===void 0?void 0:_b.opacity,pointerEvents:isOpen?"initial":(_c=defaultStyle.background)===null||_c===void 0?void 0:_c.pointerEvents}),onClick:onCloseCart}),(0,jsx_runtime_1.jsxs)("div",Object.assign({style:Object.assign(Object.assign(Object.assign({},defaultStyle.container),style?.container),{right:isOpen?"0":(_d=defaultStyle.container)===null||_d===void 0?void 0:_d.right,pointerEvents:isOpen?"initial":(_e=defaultStyle.container)===null||_e===void 0?void 0:_e.pointerEvents})},props,{children:[(0,jsx_runtime_1.jsx)("div",{style:Object.assign(Object.assign({},defaultStyle.iconContainer),style?.iconContainer),children:(0,jsx_runtime_1.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",style:Object.assign(Object.assign({},defaultStyle.icon),style?.icon),onClick:onCloseCart,children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})]}))]}):(0,jsx_runtime_1.jsx)("iframe",{title:"Cart",ref,style:Object.assign(Object.assign({},defaultStyle.cart),style?.cart),src,width:"100%",height:"100%"})}exports.HostedCart=HostedCart;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseMetadataObject } from '../../typings/index';
2
3
  import type { OrderCreate, Order } from '@commercelayer/sdk';
3
4
  import type { DefaultChildrenType } from '../../typings/globals';
@@ -20,5 +21,38 @@ interface Props {
20
21
  */
21
22
  fetchOrder?: (order: Order) => void;
22
23
  }
24
+ /**
25
+ * This component is responsible for fetching the order and store it in its context.
26
+ * It also provides the `fetchOrder` callback that is triggered every time the order is updated (it returns the updated order object as argument).
27
+ * When the order is not placed yet, its possible to pass the `metadata` and `attributes` props to update the order.
28
+ *
29
+ * <span title="Requirement" type="warning">
30
+ * Must be a child of the `<CommerceLayer>` component. <br />
31
+ * Can be a child of the `<OrderStorage>` component and receive the `orderId` from it.
32
+ * </span>
33
+ *
34
+ * <span title="Children" type="info">
35
+ * `<AddToCartButton>`,
36
+ * `<AdjustmentAmount>`,
37
+ * `<CartLink>`,
38
+ * `<CheckoutLink>`,
39
+ * `<DiscountAmount>`,
40
+ * `<GiftCardAmount>`,
41
+ * `<HostedCart>`,
42
+ * `<OrderNumber>`,
43
+ * `<PaymentMethodAmount>`,
44
+ * `<PlaceOrderButton>`,
45
+ * `<PlaceOrderContainer>`,
46
+ * `<PrivacyAndTermsCheckbox>`,
47
+ * `<Shipping Amount>`,
48
+ * `<SubTotalAmount>`,
49
+ * `<TaxesAmount>`,
50
+ * `<TotalAmount>`,
51
+ * </span>
52
+ *
53
+ * <span title="Core API" type="info">
54
+ * Check the `orders` resource from our [Core API documentation](https://docs.commercelayer.io/core/v/api-reference/orders/object).
55
+ * </span>
56
+ */
23
57
  export declare function OrderContainer(props: Props): JSX.Element;
24
58
  export default OrderContainer;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderReducer_1=tslib_1.__importStar(require("../../reducers/OrderReducer")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importStar(require("../../context/OrderContext")),OrderStorageContext_1=tslib_1.__importDefault(require("../../context/OrderStorageContext")),compareObjAttribute_1=tslib_1.__importDefault(require("../../utils/compareObjAttribute")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function OrderContainer(props){var _a,_b,_c;const{orderId,children,metadata,attributes,fetchOrder}=props,[state,dispatch]=(0,react_1.useReducer)(OrderReducer_1.default,OrderReducer_1.orderInitialState),[lock,setLock]=(0,react_1.useState)(!1),[lockOrder,setLockOrder]=(0,react_1.useState)(!0),config=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"OrderContainer",key:"accessToken"}),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=(0,react_1.useContext)(OrderStorageContext_1.default),localOrder=persistKey?getLocalOrder(persistKey):orderId,getOrder=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){const removeOrderPlaced=!!(persistKey&&clearWhenPlaced);localOrder&&(yield(0,OrderReducer_1.getApiOrder)({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:removeOrderPlaced,deleteLocalOrder,state}))});(0,react_1.useEffect)(()=>{state?.orderId&&(localOrder!=null&&state.orderId!==localOrder?getOrder():dispatch({type:"setOrderId",payload:{orderId:void 0,order:void 0}}))},[persistKey]),(0,react_1.useEffect)(()=>{state.withoutIncludes||dispatch({type:"setLoading",payload:{loading:!0}})},[state.withoutIncludes]),(0,react_1.useEffect)(()=>{if(attributes&&state?.order&&!lock){const updateAttributes=(0,compareObjAttribute_1.default)({attributes,object:state.order});Object.keys(updateAttributes).length>0&&((0,OrderReducer_1.updateOrder)({id:state.order.id,attributes:updateAttributes,dispatch,config,include:state.include,state}),setLock(!0))}return()=>{if(attributes&&state?.order){const updateAttributes=(0,compareObjAttribute_1.default)({attributes,object:state.order});state.order&&Object.keys(updateAttributes).length===0&&setLock(!1)}}},[attributes,state?.order,lock]),(0,react_1.useEffect)(()=>{var _a2,_b2;const startRequest=Object.keys(state?.includeLoaded||{}).filter(key=>{var _a3;return((_a3=state?.includeLoaded)===null||_a3===void 0?void 0:_a3[key])===!0});return config.accessToken&&state.loading===!1&&state?.order==null?(localOrder&&!state.order&&((_a2=state.include)===null||_a2===void 0?void 0:_a2.length)===startRequest.length&&!state.withoutIncludes&&!lockOrder||state.withoutIncludes&&!(!((_b2=state.include)===null||_b2===void 0)&&_b2.length)&&startRequest.length===0)&&getOrder():[config.accessToken,state.order==null,state.loading,state.withoutIncludes].every(Boolean)?dispatch({type:"setLoading",payload:{loading:!1}}):[config.accessToken,state.order==null,state.loading,state.withoutIncludes===!1].every(Boolean)&&dispatch({type:"setLoading",payload:{loading:!1}}),()=>{var _a3,_b3;state.order==null&&state.loading&&state.withoutIncludes===!1&&(((_a3=state.include)===null||_a3===void 0?void 0:_a3.length)===0&&startRequest.length>0?dispatch({type:"setLoading",payload:{loading:!1}}):state.include&&((_b3=state.include)===null||_b3===void 0?void 0:_b3.length)>0&&(dispatch({type:"setIncludesResource",payload:{include:[]}}),setLockOrder(!1)))}},[config.accessToken,Object.keys((_a=state.includeLoaded)!==null&&_a!==void 0?_a:{}).length,(_b=state.include)===null||_b===void 0?void 0:_b.length,orderId,Object.keys((_c=state?.order)!==null&&_c!==void 0?_c:{}).length,state.loading,state.withoutIncludes,lockOrder]);const orderValue=(0,react_1.useMemo)(()=>(fetchOrder!=null&&state?.order!=null&&fetchOrder(state.order),Object.assign(Object.assign({},state),{setOrder:order=>{(0,OrderReducer_1.setOrder)(order,dispatch)},getOrder:id=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,OrderReducer_1.getApiOrder)({id,dispatch,config,state})}),setOrderErrors:errors=>(0,OrderReducer_1.setOrderErrors)({dispatch,errors}),createOrder:()=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,OrderReducer_1.createOrder)({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes,setLocalOrder})}),addToCart:params=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,OrderReducer_1.addToCart)(Object.assign(Object.assign({},params),{persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder}))}),saveAddressToCustomerAddressBook:args=>{OrderContext_1.defaultOrderContext.saveAddressToCustomerAddressBook(Object.assign(Object.assign({},args),{dispatch}))},setGiftCardOrCouponCode:({code,codeType})=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield OrderContext_1.defaultOrderContext.setGiftCardOrCouponCode({code,codeType,dispatch,order:state.order,config,include:state.include,state})}),removeGiftCardOrCouponCode:({codeType})=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield OrderContext_1.defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include,state})}),addResourceToInclude:args=>{OrderContext_1.defaultOrderContext.addResourceToInclude(Object.assign(Object.assign({},args),{dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded}))},updateOrder:args=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield OrderContext_1.defaultOrderContext.updateOrder(Object.assign(Object.assign({},args),{dispatch,config,include:state.include,state}))})})),[state,config.accessToken,persistKey]);return(0,jsx_runtime_1.jsx)(OrderContext_1.default.Provider,{value:orderValue,children})}exports.OrderContainer=OrderContainer,exports.default=OrderContainer;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),OrderReducer_1=tslib_1.__importStar(require("../../reducers/OrderReducer")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importStar(require("../../context/OrderContext")),OrderStorageContext_1=tslib_1.__importDefault(require("../../context/OrderStorageContext")),compareObjAttribute_1=tslib_1.__importDefault(require("../../utils/compareObjAttribute")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function OrderContainer(props){var _a,_b,_c;const{orderId,children,metadata,attributes,fetchOrder}=props,[state,dispatch]=(0,react_1.useReducer)(OrderReducer_1.default,OrderReducer_1.orderInitialState),[lock,setLock]=(0,react_1.useState)(!1),[lockOrder,setLockOrder]=(0,react_1.useState)(!0),config=(0,useCustomContext_1.default)({context:CommerceLayerContext_1.default,contextComponentName:"CommerceLayer",currentComponentName:"OrderContainer",key:"accessToken"}),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=(0,react_1.useContext)(OrderStorageContext_1.default),getOrder=localOrder=>tslib_1.__awaiter(this,void 0,void 0,function*(){const removeOrderPlaced=!!(persistKey&&clearWhenPlaced);localOrder&&(yield(0,OrderReducer_1.getApiOrder)({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:removeOrderPlaced,deleteLocalOrder,state}))});(0,react_1.useEffect)(()=>{const localOrder=persistKey?getLocalOrder(persistKey):orderId;state?.orderId&&(localOrder!=null&&state.orderId!==localOrder?getOrder(localOrder):dispatch({type:"setOrderId",payload:{orderId:void 0,order:void 0}}))},[persistKey]),(0,react_1.useEffect)(()=>{state.withoutIncludes||dispatch({type:"setLoading",payload:{loading:!0}})},[state.withoutIncludes]),(0,react_1.useEffect)(()=>{if(attributes&&state?.order&&!lock){const updateAttributes=(0,compareObjAttribute_1.default)({attributes,object:state.order});Object.keys(updateAttributes).length>0&&((0,OrderReducer_1.updateOrder)({id:state.order.id,attributes:updateAttributes,dispatch,config,include:state.include,state}),setLock(!0))}return()=>{if(attributes&&state?.order){const updateAttributes=(0,compareObjAttribute_1.default)({attributes,object:state.order});state.order&&Object.keys(updateAttributes).length===0&&setLock(!1)}}},[attributes,state?.order,lock]),(0,react_1.useEffect)(()=>{var _a2,_b2;const localOrder=persistKey?getLocalOrder(persistKey):orderId,startRequest=Object.keys(state?.includeLoaded||{}).filter(key=>{var _a3;return((_a3=state?.includeLoaded)===null||_a3===void 0?void 0:_a3[key])===!0});return config.accessToken&&state.loading===!1&&state?.order==null?(localOrder&&!state.order&&((_a2=state.include)===null||_a2===void 0?void 0:_a2.length)===startRequest.length&&!state.withoutIncludes&&!lockOrder||state.withoutIncludes&&!(!((_b2=state.include)===null||_b2===void 0)&&_b2.length)&&startRequest.length===0)&&getOrder(localOrder):[config.accessToken,state.order==null,state.loading,state.withoutIncludes].every(Boolean)?dispatch({type:"setLoading",payload:{loading:!1}}):[config.accessToken,state.order==null,state.loading,state.withoutIncludes===!1].every(Boolean)&&dispatch({type:"setLoading",payload:{loading:!1}}),()=>{var _a3,_b3;state.order==null&&state.loading&&state.withoutIncludes===!1&&(((_a3=state.include)===null||_a3===void 0?void 0:_a3.length)===0&&startRequest.length>0?dispatch({type:"setLoading",payload:{loading:!1}}):state.include&&((_b3=state.include)===null||_b3===void 0?void 0:_b3.length)>0&&(dispatch({type:"setIncludesResource",payload:{include:[]}}),setLockOrder(!1)))}},[config.accessToken,Object.keys((_a=state.includeLoaded)!==null&&_a!==void 0?_a:{}).length,(_b=state.include)===null||_b===void 0?void 0:_b.length,orderId,Object.keys((_c=state?.order)!==null&&_c!==void 0?_c:{}).length,state.loading,state.withoutIncludes,lockOrder]);const orderValue=(0,react_1.useMemo)(()=>(fetchOrder!=null&&state?.order!=null&&fetchOrder(state.order),Object.assign(Object.assign({},state),{setOrder:order=>{(0,OrderReducer_1.setOrder)(order,dispatch)},getOrder:id=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,OrderReducer_1.getApiOrder)({id,dispatch,config,state})}),setOrderErrors:errors=>(0,OrderReducer_1.setOrderErrors)({dispatch,errors}),createOrder:()=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,OrderReducer_1.createOrder)({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes,setLocalOrder})}),addToCart:params=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield(0,OrderReducer_1.addToCart)(Object.assign(Object.assign({},params),{persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder}))}),saveAddressToCustomerAddressBook:args=>{OrderContext_1.defaultOrderContext.saveAddressToCustomerAddressBook(Object.assign(Object.assign({},args),{dispatch}))},setGiftCardOrCouponCode:({code,codeType})=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield OrderContext_1.defaultOrderContext.setGiftCardOrCouponCode({code,codeType,dispatch,order:state.order,config,include:state.include,state})}),removeGiftCardOrCouponCode:({codeType})=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield OrderContext_1.defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include,state})}),addResourceToInclude:args=>{OrderContext_1.defaultOrderContext.addResourceToInclude(Object.assign(Object.assign({},args),{dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded}))},updateOrder:args=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield OrderContext_1.defaultOrderContext.updateOrder(Object.assign(Object.assign({},args),{dispatch,config,include:state.include,state}))})})),[state,config.accessToken,persistKey]);return(0,jsx_runtime_1.jsx)(OrderContext_1.default.Provider,{value:orderValue,children})}exports.OrderContainer=OrderContainer,exports.default=OrderContainer;
@@ -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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderList=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderListChildrenContext_1=tslib_1.__importDefault(require("../../context/OrderListChildrenContext")),OrderListPaginationContext_1=tslib_1.__importDefault(require("../../context/OrderListPaginationContext")),react_table_1=require("@tanstack/react-table"),icons_1=require("../../utils/icons"),filterChildren_1=tslib_1.__importDefault(require("../../utils/filterChildren")),rowComponents=["OrderListRow","OrderListEmpty"],paginationComponents=["OrderListPaginationInfo","OrderListPaginationButtons"];function OrderList(_a){var _b,_c,_d,_e,{type="orders",children,columns,loadingElement,showActions=!1,showPagination=!1,sortBy=[{id:"number",desc:!0}],pageSize=10,paginationContainerClassName,actionsComponent,actionsContainerClassName,theadClassName,rowTrClassName}=_a,p=tslib_1.__rest(_a,["type","children","columns","loadingElement","showActions","showPagination","sortBy","pageSize","paginationContainerClassName","actionsComponent","actionsContainerClassName","theadClassName","rowTrClassName"]);const[loading,setLoading]=(0,react_1.useState)(!0),[sorting,setSorting]=(0,react_1.useState)(sortBy),[{pageIndex,pageSize:currentPageSize},setPagination]=(0,react_1.useState)({pageIndex:0,pageSize}),{orders,subscriptions,getCustomerOrders,getCustomerSubscriptions}=(0,react_1.useContext)(CustomerContext_1.default);(0,react_1.useEffect)(()=>{type==="orders"&&getCustomerOrders!=null&&getCustomerOrders({pageNumber:pageIndex,pageSize:currentPageSize}),type==="subscriptions"&&getCustomerSubscriptions!=null&&getCustomerSubscriptions({pageNumber:pageIndex,pageSize:currentPageSize})},[pageIndex,currentPageSize]);const data=(0,react_1.useMemo)(()=>type==="subscriptions"?subscriptions??[]:orders??[],[orders,subscriptions]),cols=(0,react_1.useMemo)(()=>columns,[columns]),pagination=(0,react_1.useMemo)(()=>({pageIndex,pageSize:currentPageSize}),[pageIndex,currentPageSize]),pageCount=(_c=(_b=orders?.pageCount)!==null&&_b!==void 0?_b:subscriptions?.pageCount)!==null&&_c!==void 0?_c:-1,table=(0,react_table_1.useReactTable)({data,columns:cols,getSortedRowModel:(0,react_table_1.getSortedRowModel)(),getCoreRowModel:(0,react_table_1.getCoreRowModel)(),getPaginationRowModel:(0,react_table_1.getPaginationRowModel)(),manualPagination:!0,pageCount,state:{sorting,pagination},onSortingChange:setSorting,onPaginationChange:setPagination}),TableHtmlElement="table",TheadHtmlElement="thead",TbodyHtmlElement="tbody",ThHtmlElement="th",TrHtmlElement="tr";(0,react_1.useEffect)(()=>(type==="orders"&&orders!=null&&setLoading(!1),type==="subscriptions"&&subscriptions!=null&&setLoading(!1),()=>{setLoading(!0)}),[orders,subscriptions]);const LoadingComponent=loadingElement||(0,jsx_runtime_1.jsx)("div",{children:"Loading..."}),headerComponent=table.getHeaderGroups().map(headerGroup=>{const columns2=headerGroup.headers.map((header,k)=>{var _a2;const sortLabel=header.column.getIsSorted()!==!1?header.column.getIsSorted():"";return(0,jsx_runtime_1.jsx)(ThHtmlElement,{"data-testid":`thead-${k}`,"data-sort":`${sortLabel||""}`,children:(0,jsx_runtime_1.jsxs)("span",{className:header.column.getCanSort()?"cursor-pointer select-none":"",onClick:header.column.getToggleSortingHandler(),children:[(0,react_table_1.flexRender)(header.column.columnDef.header,header.getContext()),(_a2={asc:icons_1.sortAscIcon,desc:icons_1.sortDescIcon}[header.column.getIsSorted()])!==null&&_a2!==void 0?_a2:null]})},header.id)});return(0,jsx_runtime_1.jsx)(TrHtmlElement,{children:columns2},headerGroup.id)}),rowsComponents=(0,filterChildren_1.default)({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(0,jsx_runtime_1.jsx)(TrHtmlElement,{className:rowTrClassName,children:(0,jsx_runtime_1.jsx)(OrderListChildrenContext_1.default.Provider,{value:childProps,children:rowsComponents})},row.id)}),pagComponents=(0,filterChildren_1.default)({children,filterBy:paginationComponents,componentName:"OrderList"}),totalRows=(_e=(_d=orders?.meta.recordCount)!==null&&_d!==void 0?_d:subscriptions?.meta.recordCount)!==null&&_e!==void 0?_e:0,Pagination=()=>showPagination?(0,jsx_runtime_1.jsx)(OrderListPaginationContext_1.default.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)?(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:LoadingComponent}):orders?.length===0||subscriptions?.length===0?(0,jsx_runtime_1.jsxs)(OrderListChildrenContext_1.default.Provider,{value:{orders:type==="orders"?orders:subscriptions},children:[rowsComponents,(0,jsx_runtime_1.jsx)(Pagination,{})]}):(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsxs)(TableHtmlElement,Object.assign({},p,{children:[(0,jsx_runtime_1.jsx)(TheadHtmlElement,{className:theadClassName,children:headerComponent}),(0,jsx_runtime_1.jsx)(TbodyHtmlElement,{children:components})]})),totalRows<=pageSize?null:(0,jsx_runtime_1.jsx)("div",{className:paginationContainerClassName,children:(0,jsx_runtime_1.jsx)(Pagination,{})})]})}exports.OrderList=OrderList,exports.default=OrderList;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderList=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderListChildrenContext_1=tslib_1.__importDefault(require("../../context/OrderListChildrenContext")),OrderListPaginationContext_1=tslib_1.__importDefault(require("../../context/OrderListPaginationContext")),react_table_1=require("@tanstack/react-table"),icons_1=require("../../utils/icons"),filterChildren_1=tslib_1.__importDefault(require("../../utils/filterChildren")),rowComponents=["OrderListRow","OrderListEmpty"],paginationComponents=["OrderListPaginationInfo","OrderListPaginationButtons"];function OrderList(_a){var _b,_c,_d,_e,_f,{type="orders",children,columns,loadingElement,showActions=!1,showPagination=!1,sortBy=[{id:"number",desc:!0}],pageSize=10,paginationContainerClassName,actionsComponent,actionsContainerClassName,theadClassName,rowTrClassName}=_a,p=tslib_1.__rest(_a,["type","children","columns","loadingElement","showActions","showPagination","sortBy","pageSize","paginationContainerClassName","actionsComponent","actionsContainerClassName","theadClassName","rowTrClassName"]);const[loading,setLoading]=(0,react_1.useState)(!0),[sorting,setSorting]=(0,react_1.useState)(sortBy),[{pageIndex,pageSize:currentPageSize},setPagination]=(0,react_1.useState)({pageIndex:0,pageSize}),{orders,subscriptions,getCustomerOrders,getCustomerSubscriptions}=(0,react_1.useContext)(CustomerContext_1.default);(0,react_1.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=(0,react_1.useMemo)(()=>type==="subscriptions"?subscriptions??[]:orders??[],[orders,subscriptions]),cols=(0,react_1.useMemo)(()=>columns,[columns]),pagination=(0,react_1.useMemo)(()=>({pageIndex,pageSize:currentPageSize}),[pageIndex,currentPageSize]),pageCount=(_c=(_b=orders?.pageCount)!==null&&_b!==void 0?_b:subscriptions?.pageCount)!==null&&_c!==void 0?_c:-1,table=(0,react_table_1.useReactTable)({data,columns:cols,getSortedRowModel:(0,react_table_1.getSortedRowModel)(),getCoreRowModel:(0,react_table_1.getCoreRowModel)(),getPaginationRowModel:(0,react_table_1.getPaginationRowModel)(),manualPagination:!0,pageCount,state:{sorting,pagination},onSortingChange:setSorting,onPaginationChange:setPagination}),TableHtmlElement="table",TheadHtmlElement="thead",TbodyHtmlElement="tbody",ThHtmlElement="th",TrHtmlElement="tr";(0,react_1.useEffect)(()=>(type==="orders"&&orders!=null&&setLoading(!1),type==="subscriptions"&&subscriptions!=null&&setLoading(!1),()=>{setLoading(!0)}),[orders,subscriptions]);const LoadingComponent=loadingElement||(0,jsx_runtime_1.jsx)("div",{children:"Loading..."}),headerComponent=table.getHeaderGroups().map(headerGroup=>{const columnsComponents=headerGroup.headers.map((header,k)=>{var _a2,_b2,_c2,_d2;const sortLabel=header.column.getIsSorted()!==!1?header.column.getIsSorted():"";return(0,jsx_runtime_1.jsx)(ThHtmlElement,{"data-testid":`thead-${k}`,"data-sort":`${sortLabel||""}`,className:(_a2=columns[k])===null||_a2===void 0?void 0:_a2.className,children:(0,jsx_runtime_1.jsxs)("span",{className:`${(_c2=(_b2=columns[k])===null||_b2===void 0?void 0:_b2.titleClassName)!==null&&_c2!==void 0?_c2:""} ${header.column.getCanSort()?"cursor-pointer select-none":""}`,onClick:header.column.getToggleSortingHandler(),children:[(0,react_table_1.flexRender)(header.column.columnDef.header,header.getContext()),(_d2={asc:icons_1.sortAscIcon,desc:icons_1.sortDescIcon}[header.column.getIsSorted()])!==null&&_d2!==void 0?_d2:null]})},header.id)});return(0,jsx_runtime_1.jsx)(TrHtmlElement,{children:columnsComponents},headerGroup.id)}),rowsComponents=(0,filterChildren_1.default)({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(0,jsx_runtime_1.jsx)(TrHtmlElement,{className:rowTrClassName,children:(0,jsx_runtime_1.jsx)(OrderListChildrenContext_1.default.Provider,{value:childProps,children:rowsComponents})},row.id)}),pagComponents=(0,filterChildren_1.default)({children,filterBy:paginationComponents,componentName:"OrderList"}),totalRows=(_e=(_d=orders?.meta.recordCount)!==null&&_d!==void 0?_d:subscriptions?.meta.recordCount)!==null&&_e!==void 0?_e:0,Pagination=()=>showPagination?(0,jsx_runtime_1.jsx)(OrderListPaginationContext_1.default.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)?(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:LoadingComponent}):((_f=type==="orders"?orders:subscriptions)===null||_f===void 0?void 0:_f.length)===0?(0,jsx_runtime_1.jsxs)(OrderListChildrenContext_1.default.Provider,{value:{orders:type==="orders"?orders:subscriptions},children:[rowsComponents,(0,jsx_runtime_1.jsx)(Pagination,{})]}):(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsxs)(TableHtmlElement,Object.assign({},p,{children:[(0,jsx_runtime_1.jsx)(TheadHtmlElement,{className:theadClassName,children:headerComponent}),(0,jsx_runtime_1.jsx)(TbodyHtmlElement,{children:components})]})),totalRows<=pageSize?null:(0,jsx_runtime_1.jsx)("div",{className:paginationContainerClassName,children:(0,jsx_runtime_1.jsx)(Pagination,{})})]})}exports.OrderList=OrderList,exports.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,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderListRow=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),react_2=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderListChildrenContext_1=tslib_1.__importDefault(require("../../context/OrderListChildrenContext")),isDate_1=tslib_1.__importDefault(require("../../utils/isDate")),last_1=tslib_1.__importDefault(require("lodash/last")),react_table_1=require("@tanstack/react-table");function OrderListRow(_a){var _b,{field,children}=_a,p=tslib_1.__rest(_a,["field","children"]);const{order,row,showActions,actionsComponent,actionsContainerClassName}=(0,react_2.useContext)(OrderListChildrenContext_1.default),cell=row?.getVisibleCells().filter(cell2=>cell2.column.id===field),isLastRow=((_b=(0,last_1.default)(row?.getVisibleCells()))===null||_b===void 0?void 0:_b.column.id)===field,As="td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&(0,jsx_runtime_1.jsx)(As,Object.assign({"data-testid":"action-cell"},p,{className:actionsContainerClassName,children:(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:actionsComponent}))}))||null,parentProps=Object.assign(Object.assign({},p),{field,order,row,cell});return children?(0,jsx_runtime_1.jsxs)(As,{children:[(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})),(0,jsx_runtime_1.jsx)(ActionRow,{})]}):(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.getValue(),value=(0,isDate_1.default)(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():(0,react_table_1.flexRender)(cell2.column.columnDef.cell,cell2.getContext());return(0,react_1.createElement)(As,Object.assign({"data-testid":`cell-${k}`},p,{key:cell2.id}),value)}),(0,jsx_runtime_1.jsx)(ActionRow,{})]})}exports.OrderListRow=OrderListRow,OrderListRow.displayName="OrderListRow",exports.default=OrderListRow;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrderListRow=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),react_2=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderListChildrenContext_1=tslib_1.__importDefault(require("../../context/OrderListChildrenContext")),isDate_1=tslib_1.__importDefault(require("../../utils/isDate")),last_1=tslib_1.__importDefault(require("lodash/last")),react_table_1=require("@tanstack/react-table");function OrderListRow(_a){var _b,{field,children}=_a,p=tslib_1.__rest(_a,["field","children"]);const{order,row,showActions,actionsComponent,actionsContainerClassName}=(0,react_2.useContext)(OrderListChildrenContext_1.default),cell=row?.getVisibleCells().filter(cell2=>cell2.column.id===field),isLastRow=((_b=(0,last_1.default)(row?.getVisibleCells()))===null||_b===void 0?void 0:_b.column.id)===field,As="td",ActionRow=()=>showActions&&isLastRow&&actionsComponent&&(0,jsx_runtime_1.jsx)(As,Object.assign({"data-testid":"action-cell"},p,{className:actionsContainerClassName,children:(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children:actionsComponent}))}))||null,parentProps=Object.assign(Object.assign({},p),{field,order,row,cell});return children?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(As,{children:(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children}))}),(0,jsx_runtime_1.jsx)(ActionRow,{})]}):(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[cell?.map((cell2,k)=>{const cellValue=cell2.getValue(),value=(0,isDate_1.default)(cellValue)?new Date(Date.parse(cellValue)).toLocaleString():(0,react_table_1.flexRender)(cell2.column.columnDef.cell,cell2.getContext());return(0,react_1.createElement)(As,Object.assign({"data-testid":`cell-${k}`},p,{key:cell2.id}),value)}),(0,jsx_runtime_1.jsx)(ActionRow,{})]})}exports.OrderListRow=OrderListRow,OrderListRow.displayName="OrderListRow",exports.default=OrderListRow;
@@ -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']>;