@commercelayer/react-components 4.0.0-alpha.9 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/lib/cjs/components/auth/CommerceLayer.d.ts +2 -2
  2. package/lib/cjs/components/line_items/LineItem.d.ts +4 -11
  3. package/lib/cjs/components/line_items/LineItem.js +1 -1
  4. package/lib/cjs/components/line_items/LineItemAmount.d.ts +0 -13
  5. package/lib/cjs/components/line_items/LineItemAmount.js +1 -1
  6. package/lib/cjs/components/line_items/LineItemCode.d.ts +6 -11
  7. package/lib/cjs/components/line_items/LineItemCode.js +1 -1
  8. package/lib/cjs/components/line_items/LineItemField.d.ts +14 -0
  9. package/lib/cjs/components/line_items/LineItemField.js +1 -0
  10. package/lib/cjs/components/line_items/LineItemImage.d.ts +4 -11
  11. package/lib/cjs/components/line_items/LineItemImage.js +1 -1
  12. package/lib/cjs/components/line_items/LineItemName.d.ts +6 -11
  13. package/lib/cjs/components/line_items/LineItemName.js +1 -1
  14. package/lib/cjs/components/line_items/LineItemOption.d.ts +5 -16
  15. package/lib/cjs/components/line_items/LineItemOption.js +1 -1
  16. package/lib/cjs/components/line_items/LineItemOptions.d.ts +2 -5
  17. package/lib/cjs/components/line_items/LineItemOptions.js +1 -1
  18. package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
  19. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +2 -14
  20. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
  21. package/lib/cjs/components/orders/AddToCartButton.d.ts +34 -9
  22. package/lib/cjs/components/orders/AddToCartButton.js +1 -1
  23. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +2 -2
  24. package/lib/cjs/components/orders/AdjustmentAmount.js +1 -1
  25. package/lib/cjs/components/orders/CartLink.js +1 -1
  26. package/lib/cjs/components/orders/CheckoutLink.js +1 -1
  27. package/lib/cjs/components/orders/DiscountAmount.d.ts +0 -14
  28. package/lib/cjs/components/orders/DiscountAmount.js +1 -1
  29. package/lib/cjs/components/orders/GiftCardAmount.d.ts +0 -11
  30. package/lib/cjs/components/orders/GiftCardAmount.js +1 -1
  31. package/lib/cjs/components/orders/OrderContainer.js +1 -1
  32. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +4 -0
  33. package/lib/cjs/components/orders/PaymentMethodAmount.js +1 -0
  34. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
  35. package/lib/cjs/components/orders/PlaceOrderContainer.d.ts +2 -8
  36. package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -1
  37. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -6
  38. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -1
  39. package/lib/cjs/components/orders/ShippingAmount.d.ts +0 -11
  40. package/lib/cjs/components/orders/ShippingAmount.js +1 -1
  41. package/lib/cjs/components/orders/SubTotalAmount.d.ts +0 -14
  42. package/lib/cjs/components/orders/SubTotalAmount.js +1 -1
  43. package/lib/cjs/components/orders/TaxesAmount.d.ts +0 -14
  44. package/lib/cjs/components/orders/TaxesAmount.js +1 -1
  45. package/lib/cjs/components/orders/TotalAmount.d.ts +0 -14
  46. package/lib/cjs/components/orders/TotalAmount.js +1 -1
  47. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +18 -0
  48. package/lib/cjs/components/parcels/ParcelLineItemsCount.js +1 -0
  49. package/lib/cjs/components/parcels/ParcelsCount.js +1 -1
  50. package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -1
  51. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -7
  52. package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -1
  53. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +6 -11
  54. package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -1
  55. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +2 -14
  56. package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -1
  57. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.d.ts +4 -9
  58. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -1
  59. package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -1
  60. package/lib/cjs/components/payment_source/AdyenPayment.d.ts +5 -5
  61. package/lib/cjs/components/payment_source/AdyenPayment.js +1 -1
  62. package/lib/cjs/components/prices/Price.js +1 -1
  63. package/lib/cjs/components/prices/PricesContainer.js +1 -1
  64. package/lib/cjs/components/shipments/ShipmentsCount.js +1 -1
  65. package/lib/cjs/components/skus/AvailabilityContainer.d.ts +3 -9
  66. package/lib/cjs/components/skus/AvailabilityContainer.js +1 -1
  67. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +23 -4
  68. package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -1
  69. package/lib/cjs/components/skus/SkuField.js +1 -1
  70. package/lib/cjs/components/skus/SkusContainer.d.ts +2 -2
  71. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +3 -4
  72. package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
  73. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +3 -3
  74. package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
  75. package/lib/cjs/components/utils/GenericFieldComponent.d.ts +4 -4
  76. package/lib/cjs/components/utils/GenericFieldComponent.js +1 -1
  77. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +3 -3
  78. package/lib/cjs/context/CommerceLayerContext.d.ts +2 -2
  79. package/lib/cjs/context/CommerceLayerContext.js +1 -1
  80. package/lib/cjs/context/ExternalFunctionContext.d.ts +2 -2
  81. package/lib/cjs/context/ExternalFunctionContext.js +1 -1
  82. package/lib/cjs/context/LineItemContext.d.ts +1 -1
  83. package/lib/cjs/context/OrderContext.d.ts +2 -3
  84. package/lib/cjs/context/OrderContext.js +1 -1
  85. package/lib/cjs/context/PaymentMethodContext.d.ts +2 -11
  86. package/lib/cjs/context/PaymentMethodContext.js +1 -1
  87. package/lib/cjs/index.d.ts +5 -16
  88. package/lib/cjs/index.js +1 -1
  89. package/lib/cjs/reducers/AvailabilityReducer.d.ts +13 -23
  90. package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
  91. package/lib/cjs/reducers/OrderReducer.d.ts +36 -22
  92. package/lib/cjs/reducers/OrderReducer.js +1 -1
  93. package/lib/cjs/reducers/PaymentMethodReducer.d.ts +9 -11
  94. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
  95. package/lib/cjs/reducers/PriceReducer.d.ts +12 -19
  96. package/lib/cjs/reducers/PriceReducer.js +1 -1
  97. package/lib/cjs/reducers/SkuReducer.d.ts +3 -3
  98. package/lib/cjs/typings/errors.d.ts +4 -4
  99. package/lib/cjs/typings/index.d.ts +3 -3
  100. package/lib/cjs/utils/browserInfo.d.ts +5 -2
  101. package/lib/cjs/utils/browserInfo.js +1 -1
  102. package/lib/cjs/utils/getSdk.js +1 -1
  103. package/lib/cjs/utils/hooks/useCustomContext.d.ts +21 -0
  104. package/lib/cjs/utils/hooks/useCustomContext.js +1 -0
  105. package/lib/esm/components/auth/CommerceLayer.d.ts +2 -2
  106. package/lib/esm/components/line_items/LineItem.d.ts +4 -11
  107. package/lib/esm/components/line_items/LineItem.js +1 -1
  108. package/lib/esm/components/line_items/LineItemAmount.d.ts +0 -13
  109. package/lib/esm/components/line_items/LineItemAmount.js +1 -1
  110. package/lib/esm/components/line_items/LineItemCode.d.ts +6 -11
  111. package/lib/esm/components/line_items/LineItemCode.js +1 -1
  112. package/lib/esm/components/line_items/LineItemField.d.ts +14 -0
  113. package/lib/esm/components/line_items/LineItemField.js +1 -0
  114. package/lib/esm/components/line_items/LineItemImage.d.ts +4 -11
  115. package/lib/esm/components/line_items/LineItemImage.js +1 -1
  116. package/lib/esm/components/line_items/LineItemName.d.ts +6 -11
  117. package/lib/esm/components/line_items/LineItemName.js +1 -1
  118. package/lib/esm/components/line_items/LineItemOption.d.ts +5 -16
  119. package/lib/esm/components/line_items/LineItemOption.js +1 -1
  120. package/lib/esm/components/line_items/LineItemOptions.d.ts +2 -5
  121. package/lib/esm/components/line_items/LineItemOptions.js +1 -1
  122. package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -1
  123. package/lib/esm/components/line_items/LineItemsContainer.d.ts +2 -14
  124. package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
  125. package/lib/esm/components/orders/AddToCartButton.d.ts +34 -9
  126. package/lib/esm/components/orders/AddToCartButton.js +1 -1
  127. package/lib/esm/components/orders/AdjustmentAmount.d.ts +2 -2
  128. package/lib/esm/components/orders/AdjustmentAmount.js +1 -1
  129. package/lib/esm/components/orders/CartLink.js +1 -1
  130. package/lib/esm/components/orders/CheckoutLink.js +1 -1
  131. package/lib/esm/components/orders/DiscountAmount.d.ts +0 -14
  132. package/lib/esm/components/orders/DiscountAmount.js +1 -1
  133. package/lib/esm/components/orders/GiftCardAmount.d.ts +0 -11
  134. package/lib/esm/components/orders/GiftCardAmount.js +1 -1
  135. package/lib/esm/components/orders/OrderContainer.js +1 -1
  136. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +4 -0
  137. package/lib/esm/components/orders/PaymentMethodAmount.js +1 -0
  138. package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
  139. package/lib/esm/components/orders/PlaceOrderContainer.d.ts +2 -8
  140. package/lib/esm/components/orders/PlaceOrderContainer.js +1 -1
  141. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -6
  142. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.js +1 -1
  143. package/lib/esm/components/orders/ShippingAmount.d.ts +0 -11
  144. package/lib/esm/components/orders/ShippingAmount.js +1 -1
  145. package/lib/esm/components/orders/SubTotalAmount.d.ts +0 -14
  146. package/lib/esm/components/orders/SubTotalAmount.js +1 -1
  147. package/lib/esm/components/orders/TaxesAmount.d.ts +0 -14
  148. package/lib/esm/components/orders/TaxesAmount.js +1 -1
  149. package/lib/esm/components/orders/TotalAmount.d.ts +0 -14
  150. package/lib/esm/components/orders/TotalAmount.js +1 -1
  151. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +18 -0
  152. package/lib/esm/components/parcels/ParcelLineItemsCount.js +1 -0
  153. package/lib/esm/components/parcels/ParcelsCount.js +1 -1
  154. package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -1
  155. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -7
  156. package/lib/esm/components/payment_methods/PaymentMethod.js +1 -1
  157. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +6 -11
  158. package/lib/esm/components/payment_methods/PaymentMethodName.js +1 -1
  159. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +2 -14
  160. package/lib/esm/components/payment_methods/PaymentMethodPrice.js +1 -1
  161. package/lib/esm/components/payment_methods/PaymentMethodRadioButton.d.ts +4 -9
  162. package/lib/esm/components/payment_methods/PaymentMethodRadioButton.js +1 -1
  163. package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -1
  164. package/lib/esm/components/payment_source/AdyenPayment.d.ts +5 -5
  165. package/lib/esm/components/payment_source/AdyenPayment.js +1 -1
  166. package/lib/esm/components/prices/Price.js +1 -1
  167. package/lib/esm/components/prices/PricesContainer.js +1 -1
  168. package/lib/esm/components/shipments/ShipmentsCount.js +1 -1
  169. package/lib/esm/components/skus/AvailabilityContainer.d.ts +3 -9
  170. package/lib/esm/components/skus/AvailabilityContainer.js +1 -1
  171. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +23 -4
  172. package/lib/esm/components/skus/AvailabilityTemplate.js +1 -1
  173. package/lib/esm/components/skus/SkuField.js +1 -1
  174. package/lib/esm/components/skus/SkusContainer.d.ts +2 -2
  175. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +3 -4
  176. package/lib/esm/components/utils/BaseInput.d.ts +1 -1
  177. package/lib/esm/components/utils/BaseOrderPrice.d.ts +3 -3
  178. package/lib/esm/components/utils/BaseOrderPrice.js +1 -1
  179. package/lib/esm/components/utils/GenericFieldComponent.d.ts +4 -4
  180. package/lib/esm/components/utils/GenericFieldComponent.js +1 -1
  181. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +3 -3
  182. package/lib/esm/context/CommerceLayerContext.d.ts +2 -2
  183. package/lib/esm/context/CommerceLayerContext.js +1 -1
  184. package/lib/esm/context/ExternalFunctionContext.d.ts +2 -2
  185. package/lib/esm/context/ExternalFunctionContext.js +1 -1
  186. package/lib/esm/context/LineItemContext.d.ts +1 -1
  187. package/lib/esm/context/OrderContext.d.ts +2 -3
  188. package/lib/esm/context/OrderContext.js +1 -1
  189. package/lib/esm/context/PaymentMethodContext.d.ts +2 -11
  190. package/lib/esm/context/PaymentMethodContext.js +1 -1
  191. package/lib/esm/index.d.ts +5 -16
  192. package/lib/esm/index.js +1 -1
  193. package/lib/esm/reducers/AvailabilityReducer.d.ts +13 -23
  194. package/lib/esm/reducers/AvailabilityReducer.js +1 -1
  195. package/lib/esm/reducers/OrderReducer.d.ts +36 -22
  196. package/lib/esm/reducers/OrderReducer.js +1 -1
  197. package/lib/esm/reducers/PaymentMethodReducer.d.ts +9 -11
  198. package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
  199. package/lib/esm/reducers/PriceReducer.d.ts +12 -19
  200. package/lib/esm/reducers/PriceReducer.js +1 -1
  201. package/lib/esm/reducers/SkuReducer.d.ts +3 -3
  202. package/lib/esm/typings/errors.d.ts +4 -4
  203. package/lib/esm/typings/index.d.ts +3 -3
  204. package/lib/esm/utils/browserInfo.d.ts +5 -2
  205. package/lib/esm/utils/browserInfo.js +1 -1
  206. package/lib/esm/utils/getSdk.js +1 -1
  207. package/lib/esm/utils/hooks/useCustomContext.d.ts +21 -0
  208. package/lib/esm/utils/hooks/useCustomContext.js +1 -0
  209. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  210. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  211. package/package.json +9 -8
  212. package/lib/cjs/components/orders/ItemContainer.d.ts +0 -11
  213. package/lib/cjs/components/orders/ItemContainer.js +0 -1
  214. package/lib/cjs/components/payment_methods/PaymentMethodAmount.d.ts +0 -18
  215. package/lib/cjs/components/payment_methods/PaymentMethodAmount.js +0 -1
  216. package/lib/cjs/components/skus/QuantitySelector.d.ts +0 -17
  217. package/lib/cjs/components/skus/QuantitySelector.js +0 -1
  218. package/lib/cjs/components/skus/SkuOption.d.ts +0 -14
  219. package/lib/cjs/components/skus/SkuOption.js +0 -1
  220. package/lib/cjs/components/skus/SkuOptionInput.d.ts +0 -15
  221. package/lib/cjs/components/skus/SkuOptionInput.js +0 -1
  222. package/lib/cjs/components/skus/SkuOptionsContainer.d.ts +0 -14
  223. package/lib/cjs/components/skus/SkuOptionsContainer.js +0 -1
  224. package/lib/cjs/components/skus/VariantSelector.d.ts +0 -29
  225. package/lib/cjs/components/skus/VariantSelector.js +0 -1
  226. package/lib/cjs/components/skus/VariantsContainer.d.ts +0 -20
  227. package/lib/cjs/components/skus/VariantsContainer.js +0 -1
  228. package/lib/cjs/components/utils/VariantTemplate.d.ts +0 -36
  229. package/lib/cjs/components/utils/VariantTemplate.js +0 -1
  230. package/lib/cjs/context/ItemContext.d.ts +0 -13
  231. package/lib/cjs/context/ItemContext.js +0 -1
  232. package/lib/cjs/context/SkuOptionChildrenContext.d.ts +0 -8
  233. package/lib/cjs/context/SkuOptionChildrenContext.js +0 -1
  234. package/lib/cjs/context/SkuOptionsContext.d.ts +0 -3
  235. package/lib/cjs/context/SkuOptionsContext.js +0 -1
  236. package/lib/cjs/context/VariantsContext.d.ts +0 -3
  237. package/lib/cjs/context/VariantsContext.js +0 -1
  238. package/lib/cjs/reducers/ItemReducer.d.ts +0 -69
  239. package/lib/cjs/reducers/ItemReducer.js +0 -1
  240. package/lib/cjs/reducers/SkuOptionsReducer.d.ts +0 -26
  241. package/lib/cjs/reducers/SkuOptionsReducer.js +0 -1
  242. package/lib/cjs/reducers/VariantReducer.d.ts +0 -72
  243. package/lib/cjs/reducers/VariantReducer.js +0 -1
  244. package/lib/cjs/utils/getCurrentItemKey.d.ts +0 -6
  245. package/lib/cjs/utils/getCurrentItemKey.js +0 -1
  246. package/lib/esm/components/orders/ItemContainer.d.ts +0 -11
  247. package/lib/esm/components/orders/ItemContainer.js +0 -1
  248. package/lib/esm/components/payment_methods/PaymentMethodAmount.d.ts +0 -18
  249. package/lib/esm/components/payment_methods/PaymentMethodAmount.js +0 -1
  250. package/lib/esm/components/skus/QuantitySelector.d.ts +0 -17
  251. package/lib/esm/components/skus/QuantitySelector.js +0 -1
  252. package/lib/esm/components/skus/SkuOption.d.ts +0 -14
  253. package/lib/esm/components/skus/SkuOption.js +0 -1
  254. package/lib/esm/components/skus/SkuOptionInput.d.ts +0 -15
  255. package/lib/esm/components/skus/SkuOptionInput.js +0 -1
  256. package/lib/esm/components/skus/SkuOptionsContainer.d.ts +0 -14
  257. package/lib/esm/components/skus/SkuOptionsContainer.js +0 -1
  258. package/lib/esm/components/skus/VariantSelector.d.ts +0 -29
  259. package/lib/esm/components/skus/VariantSelector.js +0 -1
  260. package/lib/esm/components/skus/VariantsContainer.d.ts +0 -20
  261. package/lib/esm/components/skus/VariantsContainer.js +0 -1
  262. package/lib/esm/components/utils/VariantTemplate.d.ts +0 -36
  263. package/lib/esm/components/utils/VariantTemplate.js +0 -1
  264. package/lib/esm/context/ItemContext.d.ts +0 -13
  265. package/lib/esm/context/ItemContext.js +0 -1
  266. package/lib/esm/context/SkuOptionChildrenContext.d.ts +0 -8
  267. package/lib/esm/context/SkuOptionChildrenContext.js +0 -1
  268. package/lib/esm/context/SkuOptionsContext.d.ts +0 -3
  269. package/lib/esm/context/SkuOptionsContext.js +0 -1
  270. package/lib/esm/context/VariantsContext.d.ts +0 -3
  271. package/lib/esm/context/VariantsContext.js +0 -1
  272. package/lib/esm/reducers/ItemReducer.d.ts +0 -69
  273. package/lib/esm/reducers/ItemReducer.js +0 -1
  274. package/lib/esm/reducers/SkuOptionsReducer.d.ts +0 -26
  275. package/lib/esm/reducers/SkuOptionsReducer.js +0 -1
  276. package/lib/esm/reducers/VariantReducer.d.ts +0 -72
  277. package/lib/esm/reducers/VariantReducer.js +0 -1
  278. package/lib/esm/utils/getCurrentItemKey.d.ts +0 -6
  279. package/lib/esm/utils/getCurrentItemKey.js +0 -1
@@ -10,14 +10,14 @@ import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, Braint
10
10
  import { Dispatch, MutableRefObject } from 'react';
11
11
  import { CheckoutComConfig } from '../components/payment_source/CheckoutComPayment';
12
12
  export declare type PaymentSourceType = AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
13
- declare type Card = {
13
+ interface Card {
14
14
  type: string;
15
15
  brand: string;
16
16
  last4: string;
17
17
  exp_year: number;
18
18
  exp_month: number;
19
- };
20
- export declare type PaymentSourceObject = {
19
+ }
20
+ export interface PaymentSourceObject {
21
21
  adyen_payments: AdyenPayment & {
22
22
  payment_request_data?: {
23
23
  payment_method?: Card;
@@ -51,7 +51,7 @@ export declare type PaymentSourceObject = {
51
51
  };
52
52
  };
53
53
  klarna_payments: KlarnaPayment;
54
- };
54
+ }
55
55
  export declare type PaymentMethodActionType = 'setErrors' | 'setPaymentMethods' | 'setPaymentMethodConfig' | 'setPaymentSource' | 'setPaymentRef' | 'setLoading';
56
56
  export declare type PaymentRef = MutableRefObject<null | HTMLFormElement>;
57
57
  export interface PaymentMethodActionPayload {
@@ -64,7 +64,7 @@ export interface PaymentMethodActionPayload {
64
64
  paymentSource: PaymentSourceTypes;
65
65
  loading: boolean;
66
66
  }
67
- export declare function setLoading({ loading, dispatch, }: {
67
+ export declare function setLoading({ loading, dispatch }: {
68
68
  loading: boolean;
69
69
  dispatch?: Dispatch<PaymentMethodAction>;
70
70
  }): void;
@@ -79,9 +79,7 @@ export interface PaymentMethodAction {
79
79
  payload: Partial<PaymentMethodActionPayload>;
80
80
  }
81
81
  export declare const paymentMethodInitialState: PaymentMethodState;
82
- export interface SetPaymentMethodErrors {
83
- <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PaymentMethodAction>): void;
84
- }
82
+ export declare type SetPaymentMethodErrors = <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PaymentMethodAction>) => void;
85
83
  export declare const setPaymentMethodErrors: SetPaymentMethodErrors;
86
84
  declare type GetPaymentMethods = (args: {
87
85
  order: Order;
@@ -118,7 +116,7 @@ export declare type SetPaymentSource = (args: {
118
116
  paymentSourceId?: string;
119
117
  customerPaymentSourceId?: string;
120
118
  updateOrder?: typeof updateOrder;
121
- } & PaymentMethodState) => Promise<PaymentSourceType | void>;
119
+ } & PaymentMethodState) => Promise<PaymentSourceType | undefined>;
122
120
  export declare const setPaymentSource: SetPaymentSource;
123
121
  export declare type UpdatePaymentSource = (args: {
124
122
  id: string;
@@ -136,7 +134,7 @@ export declare type DestroyPaymentSource = (args: {
136
134
  orderId?: string;
137
135
  }) => Promise<void>;
138
136
  export declare const destroyPaymentSource: DestroyPaymentSource;
139
- export declare type PaymentMethodConfig = {
137
+ export interface PaymentMethodConfig {
140
138
  stripePayment?: StripeConfig;
141
139
  braintreePayment?: BraintreeConfig;
142
140
  wireTransfer?: Partial<WireTransferConfig>;
@@ -144,7 +142,7 @@ export declare type PaymentMethodConfig = {
144
142
  adyenPayment?: AdyenPaymentConfig;
145
143
  checkoutComPayment?: CheckoutComConfig;
146
144
  klarnaPayment?: Pick<AdyenPaymentConfig, 'placeOrderCallback'> & Pick<StripeConfig, 'containerClassName'>;
147
- };
145
+ }
148
146
  declare type SetPaymentMethodConfig = (config: PaymentMethodConfig, dispatch: Dispatch<PaymentMethodAction>) => void;
149
147
  export declare const setPaymentMethodConfig: SetPaymentMethodConfig;
150
148
  export declare function getPaymentConfig<K extends PaymentResourceKey>(paymentResource: PaymentResource, config: PaymentMethodConfig): PaymentMethodConfig[K];
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPaymentConfig=exports.setPaymentMethodConfig=exports.destroyPaymentSource=exports.updatePaymentSource=exports.setPaymentSource=exports.setPaymentMethod=exports.getPaymentMethods=exports.setPaymentMethodErrors=exports.paymentMethodInitialState=exports.setPaymentRef=exports.setLoading=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),camelCase_1=tslib_1.__importDefault(require("lodash/camelCase")),has_1=tslib_1.__importDefault(require("lodash/has")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}exports.setLoading=setLoading;const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})};exports.setPaymentRef=setPaymentRef,exports.paymentMethodInitialState={errors:[]};const setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})};exports.setPaymentMethodErrors=setPaymentMethodErrors;const getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})};exports.getPaymentMethods=getPaymentMethods;const setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:(0,getSdk_1.default)(config).payment_methods.relationship(paymentMethodId)};updateOrder&&await updateOrder({id:order.id,attributes}),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",paymentResource);console.error("Set payment method",errors)}};exports.setPaymentMethod=setPaymentMethod;const setPaymentSource=async({config,dispatch,getOrder,attributes={},order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=(0,getSdk_1.default)(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=await sdk[paymentResource].update(attrs)}else{const attrs={...attributes,order:sdk.orders.relationship(order.id)};paymentSource=await sdk[paymentResource].create(attrs)}return getOrder&&await getOrder(order.id),dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),paymentSource}}}catch(error){const errors=(0,getErrors_1.default)(error,"payment_methods",paymentResource);console.error("Set payment source:",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors,newErrors:errors,dispatch})}};exports.setPaymentSource=setPaymentSource;const updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await(0,getSdk_1.default)(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}};exports.updatePaymentSource=updatePaymentSource;const destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})};exports.destroyPaymentSource=destroyPaymentSource;const setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};exports.setPaymentMethodConfig=setPaymentMethodConfig;function getPaymentConfig(paymentResource,config){const resource=(0,camelCase_1.default)(paymentResource).replace("Payments","Payment").replace("Transfers","Transfer");return!(0,isEmpty_1.default)(config)&&(0,has_1.default)(config,resource)?config[resource]:void 0}exports.getPaymentConfig=getPaymentConfig;const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=paymentMethodReducer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPaymentConfig=exports.setPaymentMethodConfig=exports.destroyPaymentSource=exports.updatePaymentSource=exports.setPaymentSource=exports.setPaymentMethod=exports.getPaymentMethods=exports.setPaymentMethodErrors=exports.paymentMethodInitialState=exports.setPaymentRef=exports.setLoading=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),camelCase_1=tslib_1.__importDefault(require("lodash/camelCase")),has_1=tslib_1.__importDefault(require("lodash/has")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}exports.setLoading=setLoading;const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})};exports.setPaymentRef=setPaymentRef,exports.paymentMethodInitialState={errors:[],paymentMethods:void 0};const setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})};exports.setPaymentMethodErrors=setPaymentMethodErrors;const getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})};exports.getPaymentMethods=getPaymentMethods;const setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:(0,getSdk_1.default)(config).payment_methods.relationship(paymentMethodId)};updateOrder&&await updateOrder({id:order.id,attributes}),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",paymentResource);console.error("Set payment method",errors)}};exports.setPaymentMethod=setPaymentMethod;const setPaymentSource=async({config,dispatch,getOrder,attributes,order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=(0,getSdk_1.default)(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=attributes!=null?await sdk[paymentResource].update(attrs):sdk[paymentResource].retrieve(paymentSourceId)}else{const attrs={...attributes,order:sdk.orders.relationship(order.id)};paymentSource=await sdk[paymentResource].create(attrs)}return getOrder&&await getOrder(order.id),dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),paymentSource}}}catch(error){const errors=(0,getErrors_1.default)(error,"payment_methods",paymentResource);console.error("Set payment source:",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors,newErrors:errors,dispatch})}};exports.setPaymentSource=setPaymentSource;const updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await(0,getSdk_1.default)(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}};exports.updatePaymentSource=updatePaymentSource;const destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})};exports.destroyPaymentSource=destroyPaymentSource;const setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};exports.setPaymentMethodConfig=setPaymentMethodConfig;function getPaymentConfig(paymentResource,config){const resource=(0,camelCase_1.default)(paymentResource).replace("Payments","Payment").replace("Transfers","Transfer");return!(0,isEmpty_1.default)(config)&&(0,has_1.default)(config,resource)?config[resource]:void 0}exports.getPaymentConfig=getPaymentConfig;const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=paymentMethodReducer;
@@ -2,42 +2,35 @@ import { BaseAction, LoaderType } from '../typings/index';
2
2
  import { Price } from '@commercelayer/sdk';
3
3
  import { CommerceLayerConfig } from '../context/CommerceLayerContext';
4
4
  import { Dispatch } from 'react';
5
- import { ItemPrices } from './ItemReducer';
6
5
  import { BaseError } from '../typings/errors';
7
6
  export interface Prices {
8
7
  [key: string]: Price | Price[];
9
8
  }
10
9
  declare type SkuCodesPrice = string[];
11
- export interface SetSkuCodesPrice {
12
- (skuCodes: SkuCodesPrice): void;
13
- }
14
10
  export interface PriceState {
15
11
  loading: boolean;
16
12
  prices: Prices;
17
13
  skuCodes: SkuCodesPrice;
18
14
  errors?: BaseError[];
19
15
  skuCode?: string;
20
- setSkuCodes?: SetSkuCodesPrice;
16
+ setSkuCodes?: typeof setSkuCodes;
21
17
  loader?: LoaderType;
22
18
  }
23
19
  export interface PriceAction extends BaseAction {
24
20
  type: PriceActionType;
25
21
  }
26
22
  export declare const priceInitialState: PriceState;
27
- export interface GetSkusPrice {
28
- (skuCodes: SkuCodesPrice, options: {
29
- config: CommerceLayerConfig;
30
- dispatch: Dispatch<PriceAction>;
31
- setPrices: ((item: ItemPrices) => void) | undefined;
32
- prices: ItemPrices;
33
- perPage: number;
34
- filters: Record<string, any>;
35
- }): void;
36
- }
37
- export declare const getSkusPrice: GetSkusPrice;
38
- export interface UnsetPriceState {
39
- (dispatch: Dispatch<PriceAction>): void;
40
- }
23
+ export declare function setSkuCodes({ skuCodes, dispatch }: {
24
+ skuCodes: SkuCodesPrice;
25
+ dispatch?: Dispatch<PriceAction>;
26
+ }): void;
27
+ export declare function getSkusPrice(skuCodes: SkuCodesPrice, { config, dispatch, perPage, filters }: {
28
+ config: CommerceLayerConfig;
29
+ dispatch: Dispatch<PriceAction>;
30
+ perPage: number;
31
+ filters: Record<string, any>;
32
+ }): void;
33
+ export declare type UnsetPriceState = (dispatch: Dispatch<PriceAction>) => void;
41
34
  export declare const unsetPriceState: UnsetPriceState;
42
35
  export declare type PriceActionType = 'setLoading' | 'setPrices' | 'setSkuCodes' | 'setErrors';
43
36
  declare const priceReducer: (state: PriceState, reducer: PriceAction) => PriceState;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unsetPriceState=exports.getSkusPrice=exports.priceInitialState=void 0;const tslib_1=require("tslib"),getPrices_1=tslib_1.__importDefault(require("../utils/getPrices")),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors"));exports.priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]};const getSkusPrice=(skuCodes,{config,dispatch,setPrices,prices,perPage,filters})=>{let allPrices={};const sdk=(0,getSdk_1.default)(config);sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage}).then(async response=>{const pricesObj=(0,getPrices_1.default)(response);allPrices={...allPrices,...prices,...pricesObj},setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}}),dispatch({type:"setLoading",payload:{loading:!1}});const meta=response.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const pageResponse=await sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage,pageNumber}),pricesObj2=(0,getPrices_1.default)(pageResponse);allPrices={...allPrices,...pricesObj2},setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=(0,getErrors_1.default)(error,"prices");dispatch({type:"setErrors",payload:{errors}})})};exports.getSkusPrice=getSkusPrice;const unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};exports.unsetPriceState=unsetPriceState;const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,typeAction);exports.default=priceReducer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unsetPriceState=exports.getSkusPrice=exports.setSkuCodes=exports.priceInitialState=void 0;const tslib_1=require("tslib"),getPrices_1=tslib_1.__importDefault(require("../utils/getPrices")),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors"));exports.priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]};function setSkuCodes({skuCodes,dispatch}){dispatch&&dispatch({type:"setSkuCodes",payload:{skuCodes}})}exports.setSkuCodes=setSkuCodes;function getSkusPrice(skuCodes,{config,dispatch,perPage,filters}){let allPrices={};const sdk=(0,getSdk_1.default)(config);sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage}).then(async response=>{const pricesObj=(0,getPrices_1.default)(response);allPrices={...allPrices,...pricesObj},dispatch({type:"setPrices",payload:{prices:allPrices}}),dispatch({type:"setLoading",payload:{loading:!1}});const meta=response.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const pageResponse=await sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage,pageNumber}),pricesObj2=(0,getPrices_1.default)(pageResponse);allPrices={...allPrices,...pricesObj2},dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=(0,getErrors_1.default)(error,"prices");dispatch({type:"setErrors",payload:{errors}})})}exports.getSkusPrice=getSkusPrice;const unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};exports.unsetPriceState=unsetPriceState;const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,typeAction);exports.default=priceReducer;
@@ -10,12 +10,12 @@ export declare type SkuState = Partial<{
10
10
  skuCodes: string[];
11
11
  }>;
12
12
  export declare const skuInitialState: SkuState;
13
- declare type GetSku = {
13
+ interface GetSku {
14
14
  config: CommerceLayerConfig;
15
15
  skus: string[];
16
16
  dispatch: Dispatch<SkuAction>;
17
17
  queryParams?: QueryParamsList;
18
- };
19
- export declare function getSku<T extends GetSku>({ config, skus, dispatch, queryParams, }: T): Promise<void>;
18
+ }
19
+ export declare function getSku<T extends GetSku>({ config, skus, dispatch, queryParams }: T): Promise<void>;
20
20
  export default function skuReducer(state: SkuState, reducer: SkuAction): SkuState;
21
21
  export {};
@@ -27,7 +27,7 @@ export declare const ErrorPropTypes: {
27
27
  declare type ErrorChildrenComponentProps = ChildrenFunction<Omit<ErrorComponentProps, 'children'> & {
28
28
  errors: string[];
29
29
  }>;
30
- export declare type ErrorComponentProps = {
30
+ export interface ErrorComponentProps {
31
31
  /**
32
32
  * Resource which caused the error
33
33
  */
@@ -40,12 +40,12 @@ export declare type ErrorComponentProps = {
40
40
  /**
41
41
  * Error message which you can translate
42
42
  */
43
- messages?: {
43
+ messages?: Array<{
44
44
  code: CodeErrorType;
45
45
  message: string;
46
46
  resource?: ResourceErrorType;
47
47
  field?: string;
48
48
  id?: string;
49
- }[];
50
- };
49
+ }>;
50
+ }
51
51
  export {};
@@ -109,13 +109,13 @@ export declare const baseOrderComponentPricePropTypes: {
109
109
  export declare type BasePriceType = 'total' | 'option' | 'unit';
110
110
  export declare type BaseSelectorType = 'select' | 'radio';
111
111
  export declare type BaseAmountComponentChildren = Omit<BaseAmountComponent, 'children'>;
112
- export declare type BaseAmountComponent = {
113
- children?: (props: BaseAmountComponentChildren) => JSX.Element;
112
+ export interface BaseAmountComponent extends Omit<JSX.IntrinsicElements['span'], 'children'> {
113
+ children?: ChildrenFunction<BaseAmountComponentChildren>;
114
114
  format?: BaseFormatPrice;
115
115
  price?: string;
116
116
  priceCents?: number;
117
117
  labelFree?: string;
118
- } & JSX.IntrinsicElements['span'];
118
+ }
119
119
  export declare type ChildrenFunction<P = Record<string, any>> = (props: P) => JSX.Element;
120
120
  export declare type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JSX.IntrinsicElements, T>;
121
121
  export declare type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
@@ -1,4 +1,4 @@
1
- export default function getBrowserInfo(): {
1
+ interface TReturn {
2
2
  screenWidth: string | number;
3
3
  screenHeight: string | number;
4
4
  colorDepth: string | number;
@@ -6,4 +6,7 @@ export default function getBrowserInfo(): {
6
6
  timeZoneOffset: number;
7
7
  language: string;
8
8
  javaEnabled: boolean;
9
- };
9
+ }
10
+ export default function getBrowserInfo(): TReturn;
11
+ export declare function cleanUrlBy(symbol?: string): string;
12
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});function getBrowserInfo(){const screenWidth=window&&window.screen?window.screen.width:"",screenHeight=window&&window.screen?window.screen.height:"",colorDepth=window&&window.screen?window.screen.colorDepth:"",userAgent=window&&window.navigator?window.navigator.userAgent:"",javaEnabled=window&&window.navigator?navigator.javaEnabled():!1;let language="";window&&window.navigator&&(language=window.navigator.language);const timeZoneOffset=new Date().getTimezoneOffset();return{screenWidth,screenHeight,colorDepth,userAgent,timeZoneOffset,language,javaEnabled}}exports.default=getBrowserInfo;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanUrlBy=void 0;function getBrowserInfo(){const screenWidth=window?.screen?window.screen.width:"",screenHeight=window?.screen?window.screen.height:"",colorDepth=window?.screen?window.screen.colorDepth:"",userAgent=window?.navigator?window.navigator.userAgent:"",javaEnabled=window?.navigator?navigator.javaEnabled():!1;let language="";window?.navigator&&(language=window.navigator.language);const timeZoneOffset=new Date().getTimezoneOffset();return{screenWidth,screenHeight,colorDepth,userAgent,timeZoneOffset,language,javaEnabled}}exports.default=getBrowserInfo;function cleanUrlBy(symbol="&"){const currentLocation=window?.location.href,[splitLocation]=currentLocation.split(symbol);return splitLocation??currentLocation}exports.cleanUrlBy=cleanUrlBy;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),organization_1=tslib_1.__importDefault(require("./organization")),sdk_1=tslib_1.__importDefault(require("@commercelayer/sdk"));function getSdk({endpoint,accessToken}){const org=(0,organization_1.default)(endpoint);return(0,sdk_1.default)({accessToken,...org})}exports.default=getSdk;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),organization_1=tslib_1.__importDefault(require("./organization")),sdk_1=tslib_1.__importDefault(require("@commercelayer/sdk"));function getSdk({endpoint,accessToken}){if(accessToken==null||endpoint==null)throw new Error("accessToken and endpoint are required parameters");const org=(0,organization_1.default)(endpoint);return(0,sdk_1.default)({accessToken,...org})}exports.default=getSdk;
@@ -0,0 +1,21 @@
1
+ import { Context } from 'react';
2
+ interface TParams<C> {
3
+ /**
4
+ * Context to check
5
+ */
6
+ context: Context<C>;
7
+ /**
8
+ * Name of the component has the context
9
+ */
10
+ contextComponentName: string;
11
+ /**
12
+ * Name of the current component
13
+ */
14
+ currentComponentName: string;
15
+ /**
16
+ * Key of the context to check
17
+ */
18
+ key?: string;
19
+ }
20
+ export default function useCustomContext<T>({ context, key, currentComponentName, contextComponentName }: TParams<T>): T;
21
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const react_1=require("react");function useCustomContext({context,key,currentComponentName,contextComponentName}){const currentContext=(0,react_1.useContext)(context),isProduction=process.env.NODE_ENV==="production",msg=`Cannot use <${currentComponentName}/> outside of <${contextComponentName}/>`;if(key!=null&&key in currentContext||key==null&&currentContext!=null)return currentContext;if(isProduction)console.error(msg);else throw new Error(msg);return currentContext}exports.default=useCustomContext;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
- declare type Props = {
2
+ interface Props {
3
3
  children: JSX.Element[] | JSX.Element;
4
4
  accessToken: string;
5
5
  endpoint: string;
6
- };
6
+ }
7
7
  export declare function CommerceLayer(props: Props): JSX.Element;
8
8
  export default CommerceLayer;
@@ -1,15 +1,8 @@
1
- import { ReactNode } from 'react';
1
+ /// <reference types="react" />
2
2
  import { LineItemType } from '../../typings/index';
3
- declare type Props = {
4
- children: ReactNode;
3
+ interface Props {
4
+ children: JSX.Element | JSX.Element[];
5
5
  type?: LineItemType;
6
- };
7
- export declare function LineItem(props: Props): JSX.Element;
8
- export declare namespace LineItem {
9
- var propTypes: {
10
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
11
- type: import("prop-types").Requireable<LineItemType>;
12
- };
13
- var displayName: string;
14
6
  }
7
+ export declare function LineItem(props: Props): JSX.Element;
15
8
  export default LineItem;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import components from"../../config/components";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";const propTypes=components.LineItem.propTypes,displayName=components.LineItem.displayName;export function LineItem(props){const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),items=shipmentLineItems&&shipmentLineItems?.length>0?shipmentLineItems:lineItems,components2=items&&items.filter(l=>l.item_type===type).map((lineItem,k,check)=>{if(lineItem.item_type==="bundles"&&k>0&&check[k-1]?.bundle_code===lineItem.bundle_code||lineItem.item_type==="gift_cards"&&lineItem?.total_amount_cents&&lineItem?.total_amount_cents<=0)return null;const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,{value:lineProps,children},k)});return _jsx(_Fragment,{children:components2})}LineItem.propTypes=propTypes,LineItem.displayName=displayName;export default LineItem;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function LineItem(props){const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),components=(shipmentLineItems&&shipmentLineItems?.length>0?shipmentLineItems:lineItems)?.filter(l=>l.item_type===type).map((lineItem,k,check)=>{if(lineItem.item_type==="bundles"&&k>0&&check[k-1]?.bundle_code===lineItem.bundle_code||lineItem.item_type==="gift_cards"&&lineItem?.total_amount_cents&&lineItem?.total_amount_cents<=0)return null;const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,{value:lineProps,children},k)});return _jsx(_Fragment,{children:components})}export default LineItem;
@@ -4,17 +4,4 @@ declare type Props = BaseAmountComponent & {
4
4
  type?: BasePriceType;
5
5
  };
6
6
  export declare function LineItemAmount(props: Props): JSX.Element;
7
- export declare namespace LineItemAmount {
8
- var propTypes: {
9
- type: import("prop-types").Requireable<BasePriceType>;
10
- id: import("prop-types").Requireable<string>;
11
- className: import("prop-types").Requireable<string>;
12
- style: import("prop-types").Requireable<object>;
13
- name: import("prop-types").Requireable<string>;
14
- children: import("prop-types").Requireable<(...args: any[]) => any>;
15
- format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
16
- };
17
- var defaultProps: Props;
18
- var displayName: string;
19
- }
20
7
  export default LineItemAmount;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";import components from"../../config/components";const propTypes=components.LineItemAmount.propTypes,defaultProps=components.LineItemAmount.defaultProps,displayName=components.LineItemAmount.displayName;export function LineItemAmount(props){const{format="formatted",type="total",...p}=props,{lineItem}=useContext(LineItemChildrenContext),[price,setPrice]=useState("");useEffect(()=>{if(lineItem){const p2=getAmount({base:"amount",type,format,obj:lineItem});setPrice(p2)}return()=>{setPrice("")}},[lineItem]);const parentProps={price,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:price})}LineItemAmount.propTypes=propTypes,LineItemAmount.defaultProps=defaultProps,LineItemAmount.displayName=displayName;export default LineItemAmount;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemAmount(props){const{format="formatted",type="total",...p}=props,{lineItem}=useContext(LineItemChildrenContext),[price,setPrice]=useState("");useEffect(()=>{if(lineItem){const p2=getAmount({base:"amount",type,format,obj:lineItem});setPrice(p2)}return()=>{setPrice("")}},[lineItem]);const parentProps={price,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:price})}export default LineItemAmount;
@@ -1,18 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { LineItem } from '@commercelayer/sdk';
3
- export declare type LineItemCodeType = Omit<Props, 'children'> & {
3
+ import { ChildrenFunction } from '../../typings/index';
4
+ export interface TLineItemCode extends Omit<Props, 'children'> {
4
5
  lineItem: LineItem;
5
6
  skuCode: string;
6
- };
7
- declare type Props = {
8
- children?: (props: LineItemCodeType) => JSX.Element;
7
+ }
8
+ interface Props extends Omit<JSX.IntrinsicElements['p'], 'children'> {
9
+ children?: ChildrenFunction<TLineItemCode>;
9
10
  type?: 'sku_code' | 'bundle_code';
10
- } & JSX.IntrinsicElements['p'];
11
- export declare function LineItemCode({ type, children, ...p }: Props): JSX.Element;
12
- export declare namespace LineItemCode {
13
- var propTypes: {
14
- children: import("prop-types").Requireable<(...args: any[]) => any>;
15
- };
16
- var displayName: string;
17
11
  }
12
+ export declare function LineItemCode({ type, children, ...p }: Props): JSX.Element;
18
13
  export default LineItemCode;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";import components from"../../config/components";const propTypes=components.LineItemCode.propTypes,displayName=components.LineItemCode.displayName;export function LineItemCode({type="sku_code",children,...p}){const{lineItem}=useContext(LineItemChildrenContext),labelName=lineItem?.[type],parentProps={lineItem,skuCode:labelName,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("p",{...p,children:labelName})}LineItemCode.propTypes=propTypes,LineItemCode.displayName=displayName;export default LineItemCode;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemCode({type="sku_code",children,...p}){const{lineItem}=useContext(LineItemChildrenContext),labelName=lineItem?.[type],parentProps={lineItem,skuCode:labelName,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("p",{...p,children:labelName})}export default LineItemCode;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { ConditionalElement } from '../../typings/index';
3
+ import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
4
+ declare type LineItemFieldChildrenProps = TGenericChildrenProps<TResources['LineItem']>;
5
+ declare type TCondition = ConditionalElement<Exclude<TResources['LineItem'], 'resource'>>;
6
+ declare type Props = {
7
+ children?: (props: LineItemFieldChildrenProps) => JSX.Element;
8
+ } & TCondition;
9
+ /**
10
+ * @param props {@link Props}
11
+ * @returns
12
+ */
13
+ export declare function LineItemField<P extends Props>(props: P): JSX.Element;
14
+ export default LineItemField;
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function LineItemField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"lineItem",attribute,tagElement,context:LineItemChildrenContext,...p,children})}export default LineItemField;
@@ -1,23 +1,16 @@
1
1
  /// <reference types="react" />
2
2
  import { LineItem } from '@commercelayer/sdk';
3
- import { LineItemType } from '../../typings/index';
4
- export declare type LineItemImageType = Omit<Props, 'children'> & {
3
+ import { ChildrenFunction, LineItemType } from '../../typings/index';
4
+ export interface TLineItemImage extends Omit<Props, 'children'> {
5
5
  src: string;
6
6
  lineItem: LineItem;
7
- };
7
+ }
8
8
  declare type Props = {
9
- children?: (props: LineItemImageType) => JSX.Element;
9
+ children?: ChildrenFunction<TLineItemImage>;
10
10
  width?: number;
11
11
  placeholder?: {
12
12
  [K in LineItemType]?: string;
13
13
  };
14
14
  } & Omit<JSX.IntrinsicElements['img'], 'src' | 'srcSet' | 'placeholder'>;
15
15
  export declare function LineItemImage(props: Props): JSX.Element | null;
16
- export declare namespace LineItemImage {
17
- var propTypes: {
18
- width: import("prop-types").Requireable<number>;
19
- children: import("prop-types").Requireable<(...args: any[]) => any>;
20
- };
21
- var displayName: string;
22
- }
23
16
  export default LineItemImage;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import components from"../../config/components";import{defaultGiftCardImgUrl,defaultImgUrl}from"../../utils/placeholderImages";const propTypes=components.LineItemImage.propTypes,displayName=components.LineItemImage.displayName;export function LineItemImage(props){const{placeholder,children,...p}=props,{lineItem}=useContext(LineItemChildrenContext),itemType=lineItem?.item_type;let src=lineItem?.image_url;src||(placeholder?.[itemType]?src=placeholder?.[itemType]:src=itemType==="gift_cards"?defaultGiftCardImgUrl:defaultImgUrl);const parenProps={lineItem,src,placeholder,...p};return children?_jsx(Parent,{...parenProps,children}):src?_jsx("img",{alt:"",src,...p}):null}LineItemImage.propTypes=propTypes,LineItemImage.displayName=displayName;export default LineItemImage;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import{defaultGiftCardImgUrl,defaultImgUrl}from"../../utils/placeholderImages";import Parent from"../utils/Parent";export function LineItemImage(props){const{placeholder,children,...p}=props,{lineItem}=useContext(LineItemChildrenContext),itemType=lineItem?.item_type;let src=lineItem?.image_url;src||(placeholder?.[itemType]?src=placeholder?.[itemType]:src=itemType==="gift_cards"?defaultGiftCardImgUrl:defaultImgUrl);const parenProps={lineItem,src,placeholder,...p};return children?_jsx(Parent,{...parenProps,children}):src?_jsx("img",{"data-testid":`line-item-image-${lineItem?.sku_code??""}`,alt:lineItem?.name,src,...p}):null}export default LineItemImage;
@@ -1,17 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import type { LineItem } from '@commercelayer/sdk';
3
- export declare type LineItemNameType = Omit<Props, 'children'> & {
3
+ import { ChildrenFunction } from '../../typings/index';
4
+ export interface TLineItemName extends Omit<Props, 'children'> {
4
5
  label: string;
5
6
  lineItem: LineItem;
6
- };
7
- declare type Props = {
8
- children?: (props: LineItemNameType) => JSX.Element;
9
- } & JSX.IntrinsicElements['p'];
10
- export declare function LineItemName(props: Props): JSX.Element;
11
- export declare namespace LineItemName {
12
- var propTypes: {
13
- children: import("prop-types").Requireable<(...args: any[]) => any>;
14
- };
15
- var displayName: string;
16
7
  }
8
+ interface Props extends Omit<JSX.IntrinsicElements['p'], 'children'> {
9
+ children?: ChildrenFunction<TLineItemName>;
10
+ }
11
+ export declare function LineItemName(props: Props): JSX.Element;
17
12
  export default LineItemName;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";import components from"../../config/components";const propTypes=components.LineItemName.propTypes,displayName=components.LineItemName.displayName;export function LineItemName(props){const{lineItem}=useContext(LineItemChildrenContext),label=lineItem?.name,parentProps={label,lineItem,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("p",{...props,children:label})}LineItemName.propTypes=propTypes,LineItemName.displayName=displayName;export default LineItemName;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemName(props){const{lineItem}=useContext(LineItemChildrenContext),label=lineItem?.name,parentProps={label,lineItem,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("p",{"data-testid":`line-item-name-${lineItem?.sku_code??""}`,...props,children:label})}export default LineItemName;
@@ -1,30 +1,19 @@
1
1
  import { CSSProperties } from 'react';
2
2
  import { LineItemOption as LineItemOptionType } from '@commercelayer/sdk';
3
3
  import { ChildrenFunction } from '../../typings/index';
4
- declare type LineItemOptionChildrenProps = ChildrenFunction<Omit<Props, 'children'> & {
4
+ export interface TLineItemOption extends Omit<Props, 'children'> {
5
5
  lineItemOption: LineItemOptionType;
6
- }>;
7
- declare type Props = {
6
+ }
7
+ interface Props {
8
8
  id?: string;
9
9
  className?: string;
10
10
  key?: string;
11
11
  style?: CSSProperties;
12
- children?: LineItemOptionChildrenProps;
12
+ children?: ChildrenFunction<TLineItemOption>;
13
13
  name?: string;
14
14
  valueClassName?: string;
15
15
  tagElement?: keyof JSX.IntrinsicElements;
16
16
  tagContainer?: keyof JSX.IntrinsicElements;
17
- };
18
- export declare function LineItemOption(props: Props): JSX.Element;
19
- export declare namespace LineItemOption {
20
- var propTypes: {
21
- name: import("prop-types").Requireable<string>;
22
- children: import("prop-types").Requireable<(...args: any[]) => any>;
23
- valueClassName: import("prop-types").Requireable<string>;
24
- className: import("prop-types").Requireable<string>;
25
- id: import("prop-types").Requireable<string>;
26
- style: import("prop-types").Requireable<object>;
27
- };
28
- var displayName: string;
29
17
  }
18
+ export declare function LineItemOption(props: Props): JSX.Element;
30
19
  export default LineItemOption;
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext}from"react";import LineItemOptionChildrenContext from"../../context/LineItemOptionChildrenContext";import get from"lodash/get";import has from"lodash/has";import map from"lodash/map";import Parent from"../utils/Parent";import components from"../../config/components";import isJSON from"../../utils/isJSON";const propTypes=components.LineItemOption.propTypes,displayName=components.LineItemOption.displayName;export function LineItemOption(props){const{name,children,valueClassName,key,tagElement="li",tagContainer="ul",...p}=props,{lineItemOption,showAll}=useContext(LineItemOptionChildrenContext),parentProps={...props,lineItemOption},TagElement=tagElement,TagContainer=tagContainer,components2=showAll&&isJSON(JSON.stringify(lineItemOption?.options))?map(lineItemOption?.options,(value,key2)=>_jsxs(TagElement,{...p,children:[`${key2}:`,_jsx("span",{className:valueClassName,children:`${value}`})]},key2)):has(lineItemOption,`options.${name}`)?_jsxs(TagElement,{...p,children:[`${name}:`,_jsx("span",{className:valueClassName,...p,children:`${get(lineItemOption,`options.${name}`)}`})]},key):null;return children?_jsx(Parent,{...parentProps,children:props.children}):_jsx(TagContainer,{children:components2})}LineItemOption.propTypes=propTypes,LineItemOption.displayName=displayName;export default LineItemOption;
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext}from"react";import LineItemOptionChildrenContext from"../../context/LineItemOptionChildrenContext";import get from"lodash/get";import has from"lodash/has";import map from"lodash/map";import Parent from"../utils/Parent";import isJSON from"../../utils/isJSON";export function LineItemOption(props){const{name,children,valueClassName,key,tagElement="li",tagContainer="ul",...p}=props,{lineItemOption,showAll}=useContext(LineItemOptionChildrenContext),parentProps={...props,lineItemOption},TagElement=tagElement,TagContainer=tagContainer,components=showAll&&isJSON(JSON.stringify(lineItemOption?.options))?map(lineItemOption?.options,(value,key2)=>_jsxs(TagElement,{...p,children:[`${key2}:`,_jsx("span",{className:valueClassName,children:`${value}`})]},key2)):has(lineItemOption,`options.${name}`)?_jsxs(TagElement,{...p,children:[`${name}:`,_jsx("span",{className:valueClassName,...p,children:`${get(lineItemOption,`options.${name}`)}`})]},key):null;return children?_jsx(Parent,{...parentProps,children:props.children}):_jsx(TagContainer,{children:components})}export default LineItemOption;
@@ -1,11 +1,11 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = JSX.IntrinsicElements['div'] & {
2
+ declare type Props = {
3
3
  children: ReactNode;
4
4
  title?: string;
5
5
  showName?: boolean;
6
6
  titleTagElement?: keyof JSX.IntrinsicElements;
7
7
  titleClassName?: string;
8
- } & ({
8
+ } & Omit<JSX.IntrinsicElements['div'], 'children'> & ({
9
9
  skuOptionId: string;
10
10
  showAll?: never;
11
11
  } | {
@@ -13,7 +13,4 @@ declare type Props = JSX.IntrinsicElements['div'] & {
13
13
  showAll: true;
14
14
  });
15
15
  export declare function LineItemOptions(props: Props): JSX.Element;
16
- export declare namespace LineItemOptions {
17
- var displayName: string;
18
- }
19
16
  export default LineItemOptions;
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemOptionChildrenContext from"../../context/LineItemOptionChildrenContext";import{isEmpty}from"lodash";import components from"../../config/components";const displayName=components.LineItemOptions.displayName;export function LineItemOptions(props){const{skuOptionId,title,children,showName=!0,showAll,className,titleTagElement="h6",titleClassName,...p}=props,{lineItem}=useContext(LineItemChildrenContext),lineItemOptions=isEmpty(lineItem)?[]:lineItem?.line_item_options||[],TitleTagElement=titleTagElement,options=lineItemOptions.filter(o=>showAll?!0:o.skuOption().id===skuOptionId).map((o,k)=>{const showTitle=showName?_jsx(TitleTagElement,{className:titleClassName,children:title||o.name}):null,valueProps={lineItemOption:o,showAll};return _jsxs("div",{className,...p,children:[showTitle,_jsx(LineItemOptionChildrenContext.Provider,{value:valueProps,children})]},k)});return _jsx(_Fragment,{children:options})}LineItemOptions.displayName=displayName;export default LineItemOptions;
1
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemOptionChildrenContext from"../../context/LineItemOptionChildrenContext";export function LineItemOptions(props){const{skuOptionId,title,children,showName=!0,showAll,className,titleTagElement="h6",titleClassName,...p}=props,{lineItem}=useContext(LineItemChildrenContext),lineItemOptions=lineItem!=null?lineItem?.line_item_options||[]:[],TitleTagElement=titleTagElement,options=lineItemOptions.filter(o=>showAll?!0:o.skuOption().id===skuOptionId).map((o,k)=>{const showTitle=showName?_jsx(TitleTagElement,{className:titleClassName,children:title||o.name}):null,valueProps={lineItemOption:o,showAll};return _jsxs("div",{className,...p,children:[showTitle,_jsx(LineItemOptionChildrenContext.Provider,{value:valueProps,children})]},k)});return _jsx(_Fragment,{children:options})}export default LineItemOptions;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";export function LineItemRemoveLink(props){const{label="Remove"}=props,{lineItem}=useContext(LineItemChildrenContext),{deleteLineItem}=useContext(LineItemContext),handleRemove=e=>{e.preventDefault(),deleteLineItem&&lineItem&&deleteLineItem(lineItem.id)},parentProps={handleRemove,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("a",{...props,href:"#",onClick:handleRemove,children:label})}export default LineItemRemoveLink;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import LineItemContext from"../../context/LineItemContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function LineItemRemoveLink(props){const{label="Remove",onClick}=props,{lineItem}=useCustomContext({context:LineItemChildrenContext,contextComponentName:"LineItem",currentComponentName:"LineItemRemoveLink",key:"lineItem"}),{deleteLineItem}=useContext(LineItemContext),handleRemove=e=>{e.preventDefault(),deleteLineItem!=null&&lineItem!=null&&deleteLineItem(lineItem.id),onClick?.(e)},parentProps={handleRemove,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("a",{"data-testid":`line-item-remove-link-${lineItem?.sku_code??""}`,...props,href:"#",onClick:handleRemove,children:label})}export default LineItemRemoveLink;
@@ -1,20 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props {
3
3
  children: ReactNode;
4
4
  filters?: Record<string, any>;
5
5
  loader?: ReactNode;
6
- };
7
- export declare function LineItemsContainer(props: Props): JSX.Element;
8
- export declare namespace LineItemsContainer {
9
- var propTypes: {
10
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
11
- filters: import("prop-types").Requireable<object>;
12
- loader: import("prop-types").Requireable<NonNullable<string | import("prop-types").ReactElementLike | null | undefined>>;
13
- };
14
- var defaultProps: {
15
- filters: {};
16
- loader: string;
17
- };
18
- var displayName: string;
19
6
  }
7
+ export declare function LineItemsContainer(props: Props): JSX.Element;
20
8
  export default LineItemsContainer;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../../reducers/LineItemReducer";import OrderContext from"../../context/OrderContext";import LineItemContext from"../../context/LineItemContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import components from"../../config/components";const propTypes=components.LineItemsContainer.propTypes,defaultProps=components.LineItemsContainer.defaultProps,displayName=components.LineItemsContainer.displayName;export function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),useEffect(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue={...state,loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})};return _jsx(LineItemContext.Provider,{value:lineItemValue,children:state.loading?loader:children})}LineItemsContainer.propTypes=propTypes,LineItemsContainer.defaultProps=defaultProps,LineItemsContainer.displayName=displayName;export default LineItemsContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../../reducers/LineItemReducer";import OrderContext from"../../context/OrderContext";import LineItemContext from"../../context/LineItemContext";import CommerceLayerContext from"../../context/CommerceLayerContext";export function LineItemsContainer(props){const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>{include?.includes("line_items.line_item_options.sku_option")?includeLoaded?.["line_items.line_item_options.sku_option"]||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:["line_items.line_item_options.sku_option"]}),include?.includes("line_items.item")?includeLoaded?.["line_items.item"]||addResourceToInclude({newResourceLoaded:{"line_items.item":!0}}):addResourceToInclude({newResource:["line_items.item"]})},[include,includeLoaded]),useEffect(()=>{order?.line_items&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}})},[order?.line_items]);const lineItemValue={...state,loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})};return _jsx(LineItemContext.Provider,{value:lineItemValue,children:state.loading?loader:children})}export default LineItemsContainer;