@commercelayer/react-components 4.1.1 → 4.2.0

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 (239) hide show
  1. package/lib/cjs/components/MetadataInput.d.ts +0 -1
  2. package/lib/cjs/components/addresses/Address.d.ts +0 -1
  3. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +0 -1
  4. package/lib/cjs/components/addresses/AddressInput.d.ts +0 -1
  5. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +0 -1
  6. package/lib/cjs/components/addresses/AddressesEmpty.d.ts +0 -1
  7. package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +0 -1
  8. package/lib/cjs/components/auth/CommerceLayer.d.ts +0 -1
  9. package/lib/cjs/components/customers/CustomerField.d.ts +0 -1
  10. package/lib/cjs/components/customers/CustomerInput.d.ts +0 -1
  11. package/lib/cjs/components/errors/Errors.d.ts +0 -1
  12. package/lib/cjs/components/gift_cards/GiftCard.d.ts +0 -1
  13. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -1
  14. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +0 -1
  15. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +0 -1
  16. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +0 -1
  17. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +2 -2
  18. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
  19. package/lib/cjs/components/line_items/LineItem.d.ts +0 -1
  20. package/lib/cjs/components/line_items/LineItemAmount.d.ts +0 -1
  21. package/lib/cjs/components/line_items/LineItemCode.d.ts +0 -1
  22. package/lib/cjs/components/line_items/LineItemField.d.ts +0 -1
  23. package/lib/cjs/components/line_items/LineItemImage.d.ts +0 -1
  24. package/lib/cjs/components/line_items/LineItemName.d.ts +0 -1
  25. package/lib/cjs/components/line_items/LineItemsCount.d.ts +0 -1
  26. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +0 -1
  27. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +0 -1
  28. package/lib/cjs/components/orders/CheckoutLink.d.ts +0 -1
  29. package/lib/cjs/components/orders/DiscountAmount.d.ts +0 -1
  30. package/lib/cjs/components/orders/GiftCardAmount.d.ts +0 -1
  31. package/lib/cjs/components/orders/OrderContainer.d.ts +0 -1
  32. package/lib/cjs/components/orders/OrderList.d.ts +0 -1
  33. package/lib/cjs/components/orders/OrderListEmpty.d.ts +0 -1
  34. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +0 -1
  35. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +0 -1
  36. package/lib/cjs/components/orders/OrderListRow.d.ts +0 -1
  37. package/lib/cjs/components/orders/OrderNumber.d.ts +0 -1
  38. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +0 -1
  39. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -1
  40. package/lib/cjs/components/orders/ShippingAmount.d.ts +0 -1
  41. package/lib/cjs/components/orders/SubTotalAmount.d.ts +0 -1
  42. package/lib/cjs/components/orders/TaxesAmount.d.ts +0 -1
  43. package/lib/cjs/components/orders/TotalAmount.d.ts +0 -1
  44. package/lib/cjs/components/parcels/ParcelField.d.ts +0 -1
  45. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +0 -1
  46. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +0 -1
  47. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +0 -1
  48. package/lib/cjs/components/parcels/Parcels.d.ts +0 -1
  49. package/lib/cjs/components/parcels/ParcelsCount.d.ts +0 -1
  50. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +0 -1
  51. package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -1
  52. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +0 -1
  53. package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -1
  54. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +0 -1
  55. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +4 -0
  56. package/lib/cjs/components/payment_gateways/ExternalGateway.js +1 -0
  57. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +0 -1
  58. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +0 -1
  59. package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
  60. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +0 -1
  61. package/lib/cjs/components/payment_gateways/PaypalGateway.js +1 -1
  62. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +0 -1
  63. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +0 -1
  64. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +2 -2
  65. package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -1
  66. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +0 -1
  67. package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -1
  68. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +0 -1
  69. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +5 -6
  70. package/lib/cjs/components/payment_source/BraintreePayment.js +1 -1
  71. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +0 -1
  72. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +23 -0
  73. package/lib/cjs/components/payment_source/ExternalPayment.js +1 -0
  74. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +0 -1
  75. package/lib/cjs/components/payment_source/PaymentSource.d.ts +0 -1
  76. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +0 -1
  77. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +0 -1
  78. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +0 -1
  79. package/lib/cjs/components/payment_source/StripePayment.d.ts +2 -3
  80. package/lib/cjs/components/payment_source/StripePayment.js +1 -1
  81. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +3 -4
  82. package/lib/cjs/components/payment_source/WireTransferPayment.js +1 -1
  83. package/lib/cjs/components/prices/Price.d.ts +0 -1
  84. package/lib/cjs/components/prices/PricesContainer.d.ts +0 -1
  85. package/lib/cjs/components/shipments/ShipmentField.d.ts +0 -1
  86. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +0 -1
  87. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +0 -1
  88. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +0 -1
  89. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -1
  90. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +0 -1
  91. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +0 -1
  92. package/lib/cjs/components/skus/SkuField.d.ts +0 -1
  93. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +0 -1
  94. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +0 -1
  95. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +0 -1
  96. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +0 -1
  97. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +0 -1
  98. package/lib/cjs/components/utils/PriceTemplate.d.ts +0 -1
  99. package/lib/cjs/components/utils/getAllErrors.d.ts +0 -1
  100. package/lib/cjs/reducers/OrderReducer.js +1 -1
  101. package/lib/cjs/reducers/PaymentMethodReducer.d.ts +8 -5
  102. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
  103. package/lib/cjs/utils/filterChildren.d.ts +0 -1
  104. package/lib/cjs/utils/getLoaderComponent.d.ts +0 -1
  105. package/lib/cjs/utils/getPaymentAttributes.d.ts +15 -0
  106. package/lib/cjs/utils/getPaymentAttributes.js +1 -0
  107. package/lib/cjs/utils/getPrices.d.ts +0 -1
  108. package/lib/cjs/utils/icons.d.ts +0 -1
  109. package/lib/cjs/utils/pick.d.ts +1 -0
  110. package/lib/cjs/utils/pick.js +1 -0
  111. package/lib/cjs/utils/replace.d.ts +2 -0
  112. package/lib/cjs/utils/replace.js +1 -0
  113. package/lib/cjs/utils/snakeToCamelCase.d.ts +5 -0
  114. package/lib/cjs/utils/snakeToCamelCase.js +1 -0
  115. package/lib/esm/components/MetadataInput.d.ts +0 -1
  116. package/lib/esm/components/addresses/Address.d.ts +0 -1
  117. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +0 -1
  118. package/lib/esm/components/addresses/AddressInput.d.ts +0 -1
  119. package/lib/esm/components/addresses/AddressStateSelector.d.ts +0 -1
  120. package/lib/esm/components/addresses/AddressesEmpty.d.ts +0 -1
  121. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +0 -1
  122. package/lib/esm/components/auth/CommerceLayer.d.ts +0 -1
  123. package/lib/esm/components/customers/CustomerField.d.ts +0 -1
  124. package/lib/esm/components/customers/CustomerInput.d.ts +0 -1
  125. package/lib/esm/components/errors/Errors.d.ts +0 -1
  126. package/lib/esm/components/gift_cards/GiftCard.d.ts +0 -1
  127. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -1
  128. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +0 -1
  129. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +0 -1
  130. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +0 -1
  131. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +2 -2
  132. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
  133. package/lib/esm/components/line_items/LineItem.d.ts +0 -1
  134. package/lib/esm/components/line_items/LineItemAmount.d.ts +0 -1
  135. package/lib/esm/components/line_items/LineItemCode.d.ts +0 -1
  136. package/lib/esm/components/line_items/LineItemField.d.ts +0 -1
  137. package/lib/esm/components/line_items/LineItemImage.d.ts +0 -1
  138. package/lib/esm/components/line_items/LineItemName.d.ts +0 -1
  139. package/lib/esm/components/line_items/LineItemsCount.d.ts +0 -1
  140. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +0 -1
  141. package/lib/esm/components/orders/AdjustmentAmount.d.ts +0 -1
  142. package/lib/esm/components/orders/CheckoutLink.d.ts +0 -1
  143. package/lib/esm/components/orders/DiscountAmount.d.ts +0 -1
  144. package/lib/esm/components/orders/GiftCardAmount.d.ts +0 -1
  145. package/lib/esm/components/orders/OrderContainer.d.ts +0 -1
  146. package/lib/esm/components/orders/OrderList.d.ts +0 -1
  147. package/lib/esm/components/orders/OrderListEmpty.d.ts +0 -1
  148. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +0 -1
  149. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +0 -1
  150. package/lib/esm/components/orders/OrderListRow.d.ts +0 -1
  151. package/lib/esm/components/orders/OrderNumber.d.ts +0 -1
  152. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +0 -1
  153. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -1
  154. package/lib/esm/components/orders/ShippingAmount.d.ts +0 -1
  155. package/lib/esm/components/orders/SubTotalAmount.d.ts +0 -1
  156. package/lib/esm/components/orders/TaxesAmount.d.ts +0 -1
  157. package/lib/esm/components/orders/TotalAmount.d.ts +0 -1
  158. package/lib/esm/components/parcels/ParcelField.d.ts +0 -1
  159. package/lib/esm/components/parcels/ParcelLineItem.d.ts +0 -1
  160. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +0 -1
  161. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +0 -1
  162. package/lib/esm/components/parcels/Parcels.d.ts +0 -1
  163. package/lib/esm/components/parcels/ParcelsCount.d.ts +0 -1
  164. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +0 -1
  165. package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -1
  166. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +0 -1
  167. package/lib/esm/components/payment_gateways/BraintreeGateway.js +1 -1
  168. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +0 -1
  169. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +4 -0
  170. package/lib/esm/components/payment_gateways/ExternalGateway.js +1 -0
  171. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +0 -1
  172. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +0 -1
  173. package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
  174. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +0 -1
  175. package/lib/esm/components/payment_gateways/PaypalGateway.js +1 -1
  176. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +0 -1
  177. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +0 -1
  178. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +2 -2
  179. package/lib/esm/components/payment_methods/PaymentMethod.js +1 -1
  180. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +0 -1
  181. package/lib/esm/components/payment_methods/PaymentMethodName.js +1 -1
  182. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +0 -1
  183. package/lib/esm/components/payment_source/BraintreePayment.d.ts +5 -6
  184. package/lib/esm/components/payment_source/BraintreePayment.js +1 -1
  185. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +0 -1
  186. package/lib/esm/components/payment_source/ExternalPayment.d.ts +23 -0
  187. package/lib/esm/components/payment_source/ExternalPayment.js +1 -0
  188. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +0 -1
  189. package/lib/esm/components/payment_source/PaymentSource.d.ts +0 -1
  190. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +0 -1
  191. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +0 -1
  192. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +0 -1
  193. package/lib/esm/components/payment_source/StripePayment.d.ts +2 -3
  194. package/lib/esm/components/payment_source/StripePayment.js +1 -1
  195. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +3 -4
  196. package/lib/esm/components/payment_source/WireTransferPayment.js +1 -1
  197. package/lib/esm/components/prices/Price.d.ts +0 -1
  198. package/lib/esm/components/prices/PricesContainer.d.ts +0 -1
  199. package/lib/esm/components/shipments/ShipmentField.d.ts +0 -1
  200. package/lib/esm/components/shipments/ShipmentsCount.d.ts +0 -1
  201. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +0 -1
  202. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +0 -1
  203. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -1
  204. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +0 -1
  205. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +0 -1
  206. package/lib/esm/components/skus/SkuField.d.ts +0 -1
  207. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +0 -1
  208. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +0 -1
  209. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +0 -1
  210. package/lib/esm/components/utils/BaseOrderPrice.d.ts +0 -1
  211. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +0 -1
  212. package/lib/esm/components/utils/PriceTemplate.d.ts +0 -1
  213. package/lib/esm/components/utils/getAllErrors.d.ts +0 -1
  214. package/lib/esm/reducers/OrderReducer.js +1 -1
  215. package/lib/esm/reducers/PaymentMethodReducer.d.ts +8 -5
  216. package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
  217. package/lib/esm/utils/filterChildren.d.ts +0 -1
  218. package/lib/esm/utils/getLoaderComponent.d.ts +0 -1
  219. package/lib/esm/utils/getPaymentAttributes.d.ts +15 -0
  220. package/lib/esm/utils/getPaymentAttributes.js +1 -0
  221. package/lib/esm/utils/getPrices.d.ts +0 -1
  222. package/lib/esm/utils/icons.d.ts +0 -1
  223. package/lib/esm/utils/pick.d.ts +1 -0
  224. package/lib/esm/utils/pick.js +1 -0
  225. package/lib/esm/utils/replace.d.ts +2 -0
  226. package/lib/esm/utils/replace.js +1 -0
  227. package/lib/esm/utils/snakeToCamelCase.d.ts +5 -0
  228. package/lib/esm/utils/snakeToCamelCase.js +1 -0
  229. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  230. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  231. package/package.json +23 -25
  232. package/lib/cjs/components/gift_cards/GiftCardRecipient.d.ts +0 -0
  233. package/lib/cjs/components/gift_cards/GiftCardRecipient.js +0 -1
  234. package/lib/cjs/utils/paypalPayment.d.ts +0 -3
  235. package/lib/cjs/utils/paypalPayment.js +0 -1
  236. package/lib/esm/components/gift_cards/GiftCardRecipient.d.ts +0 -0
  237. package/lib/esm/components/gift_cards/GiftCardRecipient.js +0 -1
  238. package/lib/esm/utils/paypalPayment.d.ts +0 -3
  239. package/lib/esm/utils/paypalPayment.js +0 -1
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseInputComponentProps } from '../typings/index';
3
2
  type Props = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
4
3
  export declare function MetadataInput(props: Props): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Address as AddressType } from '@commercelayer/sdk';
3
2
  import { AddressCardsTemplateChildren } from '../utils/AddressCardsTemplate';
4
3
  interface Props extends Omit<JSX.IntrinsicElements['div'], 'children' | 'onSelect'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AddressCountrySelectName, BaseSelectComponentProps } from '../../typings/index';
3
2
  import { AddressValuesKeys } from '../../context/BillingAddressFormContext';
4
3
  type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseInputComponentProps, AddressInputName } from '../../typings/index';
3
2
  import { AddressValuesKeys } from '../../context/BillingAddressFormContext';
4
3
  type Props = {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AddressStateSelectName, BaseSelectComponentProps } from '../../typings/index';
3
2
  type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
4
3
  name: AddressStateSelectName;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  children: JSX.Element[] | JSX.Element;
4
3
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  children: JSX.Element[] | JSX.Element;
4
3
  accessToken: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ConditionalElement } from '../../typings/index';
3
2
  import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
4
3
  type StockTransferFieldChildrenProps = TGenericChildrenProps<TResources['Customer']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseInputComponentProps } from '../../typings/index';
3
2
  type Props = {
4
3
  name?: 'customer_email' | string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ErrorComponentProps } from '../../typings/errors';
3
2
  type Props = ErrorComponentProps & Omit<JSX.IntrinsicElements['span'], 'children'>;
4
3
  export declare function Errors(props: Props): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseState } from '../../typings/index';
3
2
  interface Props extends Omit<JSX.IntrinsicElements['form'], 'children'> {
4
3
  children: JSX.Element[] | JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseSelectComponentProps } from '../../typings/index';
3
2
  type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
4
3
  required?: boolean;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseInputComponentProps, GiftCardInputName } from '../../typings/index';
3
2
  type Props = {
4
3
  name: GiftCardInputName;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  import type { CodeType } from '../../reducers/OrderReducer';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseInputComponentProps } from '../../typings/index';
3
2
  import { OrderCodeType } from '../../reducers/OrderReducer';
4
3
  type Props = {
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { ChildrenFunction } from '../../typings/index';
3
3
  import { CodeType, OrderCodeType } from '../../reducers/OrderReducer';
4
- interface ChildrenProps extends Omit<Props, 'children'> {
4
+ interface ChildrenProps extends Omit<Props, 'children' | 'onClick'> {
5
5
  codeType?: OrderCodeType;
6
6
  hide?: boolean;
7
7
  handleClick?: () => void;
@@ -13,6 +13,6 @@ type Props = {
13
13
  onClick?: (response: {
14
14
  success: boolean;
15
15
  }) => void;
16
- } & Omit<JSX.IntrinsicElements['button'], 'type'>;
16
+ } & Omit<JSX.IntrinsicElements['button'], 'type' | 'onClick'>;
17
17
  export declare function GiftCardOrCouponRemoveButton(props: Props): JSX.Element | null;
18
18
  export default GiftCardOrCouponRemoveButton;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GiftCardOrCouponRemoveButton=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")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),lodash_1=require("lodash");function GiftCardOrCouponRemoveButton(props){const{children,label="Remove",onClick,type,...p}=props,{order,removeGiftCardOrCouponCode}=(0,react_1.useContext)(OrderContext_1.default);let codeType=type?`${type}_code`:void 0;!type&&order&&(0,lodash_1.has)(order,"coupon_code")&&!(0,lodash_1.isEmpty)(order.coupon_code)?codeType="coupon_code":type||(codeType="gift_card_code");const code=order&&codeType?order[codeType]:"",hide=!(order&&code),handleClick=async()=>{const response=removeGiftCardOrCouponCode&&codeType&&await removeGiftCardOrCouponCode({codeType});onClick&&response&&onClick(response)},parentProps={...p,label,handleClick,codeType};return children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children}):hide?null:(0,jsx_runtime_1.jsx)("button",{type:"button",onClick:()=>{handleClick()},...p,children:label})}exports.GiftCardOrCouponRemoveButton=GiftCardOrCouponRemoveButton,exports.default=GiftCardOrCouponRemoveButton;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GiftCardOrCouponRemoveButton=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")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext"));function GiftCardOrCouponRemoveButton(props){const{children,label="Remove",onClick,type,...p}=props,{order,removeGiftCardOrCouponCode}=(0,react_1.useContext)(OrderContext_1.default);let codeType=type?`${type}_code`:void 0;!type&&order&&"coupon_code"in order&&order.coupon_code!=null?codeType="coupon_code":type||(codeType="gift_card_code");const code=order&&codeType?order[codeType]:"",hide=!(order&&code),handleClick=async()=>{const response=removeGiftCardOrCouponCode&&codeType&&await removeGiftCardOrCouponCode({codeType});onClick&&response&&onClick(response)},parentProps={...p,label,handleClick,codeType};return children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children}):hide?null:(0,jsx_runtime_1.jsx)("button",{type:"button",onClick:()=>{handleClick()},...p,children:label})}exports.GiftCardOrCouponRemoveButton=GiftCardOrCouponRemoveButton,exports.default=GiftCardOrCouponRemoveButton;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { LineItemType } from '../../typings/index';
3
2
  interface Props {
4
3
  children: JSX.Element | JSX.Element[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent, BasePriceType } from '../../typings/index';
3
2
  type Props = BaseAmountComponent & {
4
3
  type?: BasePriceType;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { LineItem } from '@commercelayer/sdk';
3
2
  import { ChildrenFunction } from '../../typings/index';
4
3
  export interface TLineItemCode extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ConditionalElement } from '../../typings/index';
3
2
  import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
4
3
  type LineItemFieldChildrenProps = TGenericChildrenProps<TResources['LineItem']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { LineItem } from '@commercelayer/sdk';
3
2
  import { ChildrenFunction, LineItemType } from '../../typings/index';
4
3
  export interface TLineItemImage extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { LineItem } from '@commercelayer/sdk';
3
2
  import { ChildrenFunction } from '../../typings/index';
4
3
  export interface TLineItemName extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type TypeAccepted } from '../../utils/getLineItemsCount';
3
2
  import { ChildrenFunction } from '../../typings/index';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  interface ChildrenProps extends Omit<Props, 'children'> {
4
3
  quantity: number;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function AdjustmentAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default AdjustmentAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  interface ChildrenProps extends Omit<Props, 'children'> {
4
3
  checkoutUrl: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function DiscountAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default DiscountAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function GiftCardAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default GiftCardAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseMetadataObject } from '../../typings/index';
3
2
  import type { OrderCreate, Order } from '@commercelayer/sdk';
4
3
  interface Props {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { InitialOrderListContext } from '../../context/OrderListChildrenContext';
3
2
  import { Column } from 'react-table';
4
3
  import type { Order } from '@commercelayer/sdk';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type OrderListPaginationContext as TOrderListPaginationContext } from '../../context/OrderListPaginationContext';
3
2
  import { ChildrenFunction } from '../../typings/index';
4
3
  interface PaginationButton extends Omit<JSX.IntrinsicElements['button'], 'children' | 'disabled'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  type TAsComponent = keyof Pick<JSX.IntrinsicElements, 'p' | 'span' | 'div'>;
4
3
  type ChildrenProps<A extends TAsComponent> = Omit<Props<A>, 'children'> & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Cell, Row } from 'react-table';
3
2
  import type { Order } from '@commercelayer/sdk';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseFieldProps } from '../utils/BaseField';
3
2
  type Props = Omit<BaseFieldProps, 'attribute'>;
4
3
  export declare function OrderNumber(props: Props): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function PaymentMethodAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default PaymentMethodAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseInputProps } from '../utils/BaseInput';
3
2
  export declare function PrivacyAndTermsCheckbox(props: Partial<BaseInputProps>): JSX.Element;
4
3
  export default PrivacyAndTermsCheckbox;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function ShippingAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default ShippingAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function SubTotalAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default SubTotalAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function TaxesAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default TaxesAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  export declare function TotalAmount(props: BaseAmountComponent): JSX.Element;
4
3
  export default TotalAmount;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ConditionalElement } from '../../typings/index';
3
2
  import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
4
3
  type ParcelFieldChildrenProps = TGenericChildrenProps<TResources['Parcel']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  children: JSX.Element[] | JSX.Element;
4
3
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ConditionalElement } from '../../typings/index';
3
2
  import { TGenericChildrenProps, TResources } from '../utils/GenericFieldComponent';
4
3
  type ParcelLineItemFieldChildrenProps = TGenericChildrenProps<TResources['ParcelLineItem']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  import type { Parcel } from '@commercelayer/sdk';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  children: JSX.Element | JSX.Element[];
4
3
  filterBy?: string[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  import type { Parcel } from '@commercelayer/sdk';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function AdyenGateway(props: Props): JSX.Element | null;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AdyenGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),PaymentMethodReducer_1=require("../../reducers/PaymentMethodReducer"),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=require("react"),AdyenPayment_1=tslib_1.__importDefault(require("../payment_source/AdyenPayment")),PaymentCardsTemplate_1=tslib_1.__importDefault(require("../utils/PaymentCardsTemplate")),jwt_1=tslib_1.__importDefault(require("../../utils/jwt")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails"));function AdyenGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=(0,react_1.useContext)(OrderContext_1.default),{accessToken}=(0,react_1.useContext)(CommerceLayerContext_1.default),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{payments,isGuest}=(0,react_1.useContext)(CustomerContext_1.default),{currentPaymentMethodId,config,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource="adyen_payments",locale=order?.language_code,paymentMethods=paymentSource?.payment_methods;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientKey=paymentSource?.public_key,environment=accessToken&&(0,jwt_1.default)(accessToken).test?"test":"live",adyenConfig=config?(0,PaymentMethodReducer_1.getPaymentConfig)(paymentResource,config):{},customerPayments=!(0,isEmpty_1.default)(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="adyen_payments"):[];if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return(0,isEmpty_1.default)(card)?null:(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children})}return!isGuest&&templateCustomerCards?clientKey&&!loading&&paymentMethods?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,isEmpty_1.default)(customerPayments)?null:(0,jsx_runtime_1.jsx)("div",{className:p.className,children:(0,jsx_runtime_1.jsx)(PaymentCardsTemplate_1.default,{paymentResource,customerPayments,children:templateCustomerCards})}),(0,jsx_runtime_1.jsx)(AdyenPayment_1.default,{templateCustomerSaveToWallet,clientKey,locale,environment,config:adyenConfig})]}):loaderComponent:clientKey&&!loading&&paymentMethods?(0,jsx_runtime_1.jsx)(AdyenPayment_1.default,{clientKey,locale,config:adyenConfig,environment}):loaderComponent}exports.AdyenGateway=AdyenGateway,exports.default=AdyenGateway;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AdyenGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=require("react"),AdyenPayment_1=tslib_1.__importDefault(require("../payment_source/AdyenPayment")),PaymentCardsTemplate_1=tslib_1.__importDefault(require("../utils/PaymentCardsTemplate")),jwt_1=tslib_1.__importDefault(require("../../utils/jwt")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),getPaymentAttributes_1=require("../../utils/getPaymentAttributes");function AdyenGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=(0,react_1.useContext)(OrderContext_1.default),{accessToken}=(0,react_1.useContext)(CommerceLayerContext_1.default),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{payments,isGuest}=(0,react_1.useContext)(CustomerContext_1.default),{currentPaymentMethodId,config,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource="adyen_payments",locale=order?.language_code,paymentMethods=paymentSource?.payment_methods;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientKey=paymentSource?.public_key,environment=accessToken&&(0,jwt_1.default)(accessToken).test?"test":"live",paymentConfig=(0,getPaymentAttributes_1.getPaymentAttributes)({resource:paymentResource,config:config??{},keys:["adyen_payments"]})?.adyenPayment,customerPayments=!(0,isEmpty_1.default)(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="adyen_payments"):[];if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return(0,isEmpty_1.default)(card)?null:(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children})}return!isGuest&&templateCustomerCards?clientKey&&!loading&&paymentMethods?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,isEmpty_1.default)(customerPayments)?null:(0,jsx_runtime_1.jsx)("div",{className:p.className,children:(0,jsx_runtime_1.jsx)(PaymentCardsTemplate_1.default,{paymentResource,customerPayments,children:templateCustomerCards})}),(0,jsx_runtime_1.jsx)(AdyenPayment_1.default,{templateCustomerSaveToWallet,clientKey,locale,environment,config:paymentConfig})]}):loaderComponent:clientKey&&!loading&&paymentMethods?(0,jsx_runtime_1.jsx)(AdyenPayment_1.default,{clientKey,locale,config:paymentConfig,environment}):loaderComponent}exports.AdyenGateway=AdyenGateway,exports.default=AdyenGateway;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function BraintreeGateway(props: Props): JSX.Element | null;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BraintreeGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),BraintreePayment_1=tslib_1.__importDefault(require("../payment_source/BraintreePayment")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),PaymentMethodReducer_1=require("../../reducers/PaymentMethodReducer"),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=require("react"),PaymentCardsTemplate_1=tslib_1.__importDefault(require("../utils/PaymentCardsTemplate"));function BraintreeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=(0,react_1.useContext)(OrderContext_1.default),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{payments,isGuest}=(0,react_1.useContext)(CustomerContext_1.default),{currentPaymentMethodId,config,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource="braintree_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const authorization=paymentSource?.client_token,braintreeConfig=config?(0,PaymentMethodReducer_1.getPaymentConfig)(paymentResource,config):{},customerPayments=!(0,isEmpty_1.default)(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="braintree_payments"):[];if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return(0,isEmpty_1.default)(card)?null:(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children})}return!isGuest&&templateCustomerCards?authorization&&!loading?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,isEmpty_1.default)(customerPayments)?null:(0,jsx_runtime_1.jsx)("div",{className:p.className,children:(0,jsx_runtime_1.jsx)(PaymentCardsTemplate_1.default,{paymentResource,customerPayments,children:templateCustomerCards})}),(0,jsx_runtime_1.jsx)(BraintreePayment_1.default,{templateCustomerSaveToWallet,authorization,locale,config:braintreeConfig})]}):loaderComponent:authorization&&!loading?(0,jsx_runtime_1.jsx)(BraintreePayment_1.default,{locale,authorization,config:braintreeConfig}):loaderComponent}exports.BraintreeGateway=BraintreeGateway,exports.default=BraintreeGateway;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BraintreeGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),BraintreePayment_1=tslib_1.__importDefault(require("../payment_source/BraintreePayment")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=require("react"),PaymentCardsTemplate_1=tslib_1.__importDefault(require("../utils/PaymentCardsTemplate")),getPaymentAttributes_1=require("../../utils/getPaymentAttributes");function BraintreeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=(0,react_1.useContext)(OrderContext_1.default),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{payments,isGuest}=(0,react_1.useContext)(CustomerContext_1.default),{currentPaymentMethodId,config,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource="braintree_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const authorization=paymentSource?.client_token,paymentConfig=(0,getPaymentAttributes_1.getPaymentAttributes)({resource:paymentResource,config:config??{},keys:["braintree_payments"]})?.braintreePayment,customerPayments=!(0,isEmpty_1.default)(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="braintree_payments"):[];if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return(0,isEmpty_1.default)(card)?null:(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children})}return!isGuest&&templateCustomerCards?authorization&&!loading?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,isEmpty_1.default)(customerPayments)?null:(0,jsx_runtime_1.jsx)("div",{className:p.className,children:(0,jsx_runtime_1.jsx)(PaymentCardsTemplate_1.default,{paymentResource,customerPayments,children:templateCustomerCards})}),(0,jsx_runtime_1.jsx)(BraintreePayment_1.default,{templateCustomerSaveToWallet,authorization,locale,config:paymentConfig})]}):loaderComponent:authorization&&!loading?(0,jsx_runtime_1.jsx)(BraintreePayment_1.default,{locale,authorization,config:paymentConfig}):loaderComponent}exports.BraintreeGateway=BraintreeGateway,exports.default=BraintreeGateway;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function CheckoutComGateway(props: Props): JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
+ type Props = GatewayBaseType;
3
+ export declare function ExternalGateway(props: Props): JSX.Element | null;
4
+ export default ExternalGateway;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExternalGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),ExternalPayment_1=tslib_1.__importDefault(require("../payment_source/ExternalPayment")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),PaymentMethodReducer_1=require("../../reducers/PaymentMethodReducer"),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=tslib_1.__importDefault(require("react")),PaymentCardsTemplate_1=tslib_1.__importDefault(require("../utils/PaymentCardsTemplate"));function ExternalGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=react_1.default.useContext(OrderContext_1.default),{payment}=react_1.default.useContext(PaymentMethodChildrenContext_1.default),{payments,isGuest}=react_1.default.useContext(CustomerContext_1.default),{currentPaymentMethodId,config,paymentSource}=react_1.default.useContext(PaymentMethodContext_1.default),paymentResource="external_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const paymentSourceToken=paymentSource?.payment_source_token,paymentSourceId=order?.payment_source?.id||paymentSource?.id,paymentConfig=(config?(0,PaymentMethodReducer_1.getPaymentConfig)(paymentResource,config):{})?.externalPayment,customerPayments=!(0,isEmpty_1.default)(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return(0,isEmpty_1.default)(card)?null:(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children})}return!isGuest&&templateCustomerCards?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,isEmpty_1.default)(customerPayments)?null:(0,jsx_runtime_1.jsx)("div",{className:p.className,children:(0,jsx_runtime_1.jsx)(PaymentCardsTemplate_1.default,{paymentResource,customerPayments,children:templateCustomerCards})}),(0,jsx_runtime_1.jsx)(ExternalPayment_1.default,{show,templateCustomerSaveToWallet,paymentSourceToken,locale,...paymentConfig})]}):paymentSourceToken&&!loading&&paymentSourceId?(0,jsx_runtime_1.jsx)(ExternalPayment_1.default,{show,paymentSourceToken,locale,...paymentConfig}):loaderComponent}exports.ExternalGateway=ExternalGateway,exports.default=ExternalGateway;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function KlarnaGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { LoaderType } from '../../typings/index';
3
2
  import { PaymentSourceProps } from '../payment_source/PaymentSource';
4
3
  export type GatewayBaseType = Props & {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),paypalPayment_1=tslib_1.__importDefault(require("../../utils/paypalPayment")),react_1=require("react"),getLoaderComponent_1=tslib_1.__importDefault(require("../../utils/getLoaderComponent")),AdyenGateway_1=tslib_1.__importDefault(require("./AdyenGateway")),StripeGateway_1=tslib_1.__importDefault(require("./StripeGateway")),BraintreeGateway_1=tslib_1.__importDefault(require("./BraintreeGateway")),PaypalGateway_1=tslib_1.__importDefault(require("./PaypalGateway")),WireTransferGateway_1=tslib_1.__importDefault(require("./WireTransferGateway")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),CheckoutComGateway_1=tslib_1.__importDefault(require("./CheckoutComGateway")),KlarnaGateway_1=tslib_1.__importDefault(require("./KlarnaGateway"));function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=(0,getLoaderComponent_1.default)(loader),[loading,setLoading]=(0,react_1.useState)(!0),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),{getCustomerPaymentSources}=(0,react_1.useContext)(CustomerContext_1.default),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;(0,react_1.useEffect)(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?(0,paypalPayment_1.default)(paymentResource,config):{},setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"stripe_payments":return(0,jsx_runtime_1.jsx)(StripeGateway_1.default,{...gatewayConfig,children});case"klarna_payments":return(0,jsx_runtime_1.jsx)(KlarnaGateway_1.default,{...gatewayConfig,children});case"adyen_payments":return(0,jsx_runtime_1.jsx)(AdyenGateway_1.default,{...gatewayConfig,children});case"braintree_payments":return(0,jsx_runtime_1.jsx)(BraintreeGateway_1.default,{...gatewayConfig,children});case"wire_transfers":return(0,jsx_runtime_1.jsx)(WireTransferGateway_1.default,{...gatewayConfig,children});case"paypal_payments":return(0,jsx_runtime_1.jsx)(PaypalGateway_1.default,{...gatewayConfig,children});case"checkout_com_payments":return(0,jsx_runtime_1.jsx)(CheckoutComGateway_1.default,{...gatewayConfig,children});default:return null}}exports.PaymentGateway=PaymentGateway,exports.default=PaymentGateway;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),react_1=require("react"),getLoaderComponent_1=tslib_1.__importDefault(require("../../utils/getLoaderComponent")),AdyenGateway_1=tslib_1.__importDefault(require("./AdyenGateway")),StripeGateway_1=tslib_1.__importDefault(require("./StripeGateway")),BraintreeGateway_1=tslib_1.__importDefault(require("./BraintreeGateway")),PaypalGateway_1=tslib_1.__importDefault(require("./PaypalGateway")),WireTransferGateway_1=tslib_1.__importDefault(require("./WireTransferGateway")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),CheckoutComGateway_1=tslib_1.__importDefault(require("./CheckoutComGateway")),KlarnaGateway_1=tslib_1.__importDefault(require("./KlarnaGateway")),getPaymentAttributes_1=require("../../utils/getPaymentAttributes"),ExternalGateway_1=tslib_1.__importDefault(require("./ExternalGateway"));function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=(0,getLoaderComponent_1.default)(loader),[loading,setLoading]=(0,react_1.useState)(!0),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),{getCustomerPaymentSources}=(0,react_1.useContext)(CustomerContext_1.default),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;(0,react_1.useEffect)(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=(0,getPaymentAttributes_1.getPaypalAttributes)(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=(0,getPaymentAttributes_1.getExternalPaymentAttributes)(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return(0,jsx_runtime_1.jsx)(AdyenGateway_1.default,{...gatewayConfig,children});case"braintree_payments":return(0,jsx_runtime_1.jsx)(BraintreeGateway_1.default,{...gatewayConfig,children});case"checkout_com_payments":return(0,jsx_runtime_1.jsx)(CheckoutComGateway_1.default,{...gatewayConfig,children});case"external_payments":return(0,jsx_runtime_1.jsx)(ExternalGateway_1.default,{...gatewayConfig,children});case"klarna_payments":return(0,jsx_runtime_1.jsx)(KlarnaGateway_1.default,{...gatewayConfig,children});case"stripe_payments":return(0,jsx_runtime_1.jsx)(StripeGateway_1.default,{...gatewayConfig,children});case"wire_transfers":return(0,jsx_runtime_1.jsx)(WireTransferGateway_1.default,{...gatewayConfig,children});case"paypal_payments":return(0,jsx_runtime_1.jsx)(PaypalGateway_1.default,{...gatewayConfig,children});default:return null}}exports.PaymentGateway=PaymentGateway,exports.default=PaymentGateway;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = Partial<GatewayBaseType>;
4
3
  export declare function PaypalGateway(props: Props): JSX.Element | null;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaypalGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),PaypalPayment_1=tslib_1.__importDefault(require("../payment_source/PaypalPayment")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),PaymentMethodReducer_1=require("../../reducers/PaymentMethodReducer"),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=require("react");function PaypalGateway(props){const{readonly,showCard,handleEditClick,children,...p}=props,{order}=(0,react_1.useContext)(OrderContext_1.default),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{currentPaymentMethodId,config,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource="paypal_payments";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:order?.payment_source||paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return(0,isEmpty_1.default)(card)?null:(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children})}const paypalConfig=config&&(0,PaymentMethodReducer_1.getPaymentConfig)(paymentResource,config);return delete p.show,delete p.templateCustomerCards,delete p.templateCustomerSaveToWallet,delete p.loading,delete p.loaderComponent,delete p.onClickCustomerCards,(0,jsx_runtime_1.jsx)(PaypalPayment_1.default,{...p,infoMessage:paypalConfig?.infoMessage})}exports.PaypalGateway=PaypalGateway,exports.default=PaypalGateway;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaypalGateway=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),PaypalPayment_1=tslib_1.__importDefault(require("../payment_source/PaypalPayment")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),getPaymentAttributes_1=require("../../utils/getPaymentAttributes"),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=require("react");function PaypalGateway(props){const{readonly,showCard,handleEditClick,children,...p}=props,{order}=(0,react_1.useContext)(OrderContext_1.default),{payment}=(0,react_1.useContext)(PaymentMethodChildrenContext_1.default),{currentPaymentMethodId,config,paymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),paymentResource="paypal_payments";if(!readonly&&payment?.id!==currentPaymentMethodId)return null;if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:order?.payment_source||paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return(0,isEmpty_1.default)(card)?null:(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children})}const infoMessage=(0,getPaymentAttributes_1.getPaymentAttributes)({resource:paymentResource,config:config??{},keys:["paypal_payments"]})?.paypalPayment?.infoMessage;return delete p.show,delete p.templateCustomerCards,delete p.templateCustomerSaveToWallet,delete p.loading,delete p.loaderComponent,delete p.onClickCustomerCards,(0,jsx_runtime_1.jsx)(PaypalPayment_1.default,{...p,infoMessage})}exports.PaypalGateway=PaypalGateway,exports.default=PaypalGateway;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function StripeGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function WireTransferGateway(props: Props): JSX.Element | null;
@@ -4,9 +4,9 @@ import { PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
4
4
  import { PaymentResource } from '../../reducers/PaymentMethodReducer';
5
5
  type Props = {
6
6
  /**
7
- * Hide payment methods by an array of strings
7
+ * Hide payment methods by an array of strings or a function that returns a boolean
8
8
  */
9
- hide?: PaymentResource[];
9
+ hide?: PaymentResource[] | ((payment: PaymentMethodType) => boolean);
10
10
  children: ReactNode;
11
11
  activeClass?: string;
12
12
  loader?: LoaderType;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentMethod=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),getLoaderComponent_1=tslib_1.__importDefault(require("../../utils/getLoaderComponent")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,hide,onClick,...p}){const[loading,setLoading]=(0,react_1.useState)(!0),[paymentSelected,setPaymentSelected]=(0,react_1.useState)(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=(0,useCustomContext_1.default)({context:PaymentMethodContext_1.default,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"});(0,react_1.useEffect)(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(hide){const source=payment?.payment_source_type;return!hide?.includes(source)}return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return(0,jsx_runtime_1.jsx)("div",{"data-test-id":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:(0,jsx_runtime_1.jsx)(PaymentMethodChildrenContext_1.default.Provider,{value:paymentMethodProps,children})},k)});return loading?(0,getLoaderComponent_1.default)(loader):(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:components})}exports.PaymentMethod=PaymentMethod,exports.default=PaymentMethod;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentMethod=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),getLoaderComponent_1=tslib_1.__importDefault(require("../../utils/getLoaderComponent")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,hide,onClick,...p}){const[loading,setLoading]=(0,react_1.useState)(!0),[paymentSelected,setPaymentSelected]=(0,react_1.useState)(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=(0,useCustomContext_1.default)({context:PaymentMethodContext_1.default,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"});(0,react_1.useEffect)(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return(0,jsx_runtime_1.jsx)("div",{"data-test-id":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:(0,jsx_runtime_1.jsx)(PaymentMethodChildrenContext_1.default.Provider,{value:paymentMethodProps,children})},k)});return loading?(0,getLoaderComponent_1.default)(loader):(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:components})}exports.PaymentMethod=PaymentMethod,exports.default=PaymentMethod;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChildrenFunction } from '../../typings/index';
3
2
  interface ChildrenProps extends Omit<Props, 'children'> {
4
3
  labelName: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentMethodName=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function PaymentMethodName(props){const{payment}=(0,useCustomContext_1.default)({context:PaymentMethodChildrenContext_1.default,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodName",key:"payment"}),labelName=payment?.name,htmlFor=payment?.payment_source_type,parentProps={htmlFor,labelName,...props};return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("label",{htmlFor,...props,children:labelName})}exports.PaymentMethodName=PaymentMethodName,exports.default=PaymentMethodName;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaymentMethodName=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function PaymentMethodName(props){const{payment}=(0,useCustomContext_1.default)({context:PaymentMethodChildrenContext_1.default,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodName",key:"payment"}),labelName=payment?.name,htmlFor=payment?.payment_source_type,paymentGateway=payment?.payment_gateway,parentProps={htmlFor,labelName,paymentGateway,...props};return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("label",{htmlFor,...props,children:labelName})}exports.PaymentMethodName=PaymentMethodName,exports.default=PaymentMethodName;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BaseAmountComponent } from '../../typings/index';
3
2
  interface Props extends BaseAmountComponent {
4
3
  type?: 'amount';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { HostedFieldFieldOptions } from 'braintree-web/modules/hosted-fields';
3
2
  import { PaymentSourceProps } from './PaymentSource';
4
3
  type BraintreeHostedFields<Type> = {
@@ -6,7 +5,7 @@ type BraintreeHostedFields<Type> = {
6
5
  label?: string;
7
6
  } & Type[Property];
8
7
  };
9
- export type BraintreeConfig = {
8
+ export interface BraintreeConfig {
10
9
  containerClassName?: string;
11
10
  cardContainerClassName?: string;
12
11
  expDateContainerClassName?: string;
@@ -19,12 +18,12 @@ export type BraintreeConfig = {
19
18
  styles?: {
20
19
  [key: string]: Record<string, string>;
21
20
  };
22
- };
23
- type Props = {
21
+ }
22
+ interface Props {
24
23
  authorization: string;
25
24
  config?: BraintreeConfig;
26
25
  templateCustomerSaveToWallet?: PaymentSourceProps['templateCustomerSaveToWallet'];
27
26
  locale?: string;
28
- };
29
- export declare function BraintreePayment({ authorization, config, templateCustomerSaveToWallet, }: Props): JSX.Element | null;
27
+ }
28
+ export declare function BraintreePayment({ authorization, config, templateCustomerSaveToWallet }: Props): JSX.Element | null;
30
29
  export default BraintreePayment;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BraintreePayment=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),localStorage_1=require("../../utils/localStorage"),promisify_1=tslib_1.__importDefault(require("../../utils/promisify")),defaultConfig={styles:{input:{"font-size":"16px",color:"#3A3A3A"},".number":{"font-family":"monospace"},":focus":{color:"blue"},".valid":{color:"green"},".invalid":{color:"red"},"@media screen and (max-width: 700px)":{input:{"font-size":"14px"}}},fields:{number:{label:"Card Number",selector:"#card-number",placeholder:"4111 1111 1111 1111"},cvv:{label:"CVV",selector:"#cvv",placeholder:"123"},expirationDate:{label:"Expiration Date",selector:"#expiration-date",placeholder:"10/2022"}},submitLabel:"Set payment method"};function BraintreePayment({authorization,config,templateCustomerSaveToWallet}){const{fields,styles,containerClassName,cardContainerClassName,fieldsContainerClassName,expDateContainerClassName,fieldLabelClassName,cvvContainerClassName,inputWrapperClassName,cardDetailsContainerClassName}={...defaultConfig,...config},[loadBraintree,setLoadBraintree]=(0,react_1.useState)(!1),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),ref=(0,react_1.useRef)(null),handleSubmitForm=async({event,hostedFieldsInstance,threeDSInstance})=>{const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),hostedFieldsInstance)try{const payload=await(0,promisify_1.default)(hostedFieldsInstance).then(payload2=>payload2),billingAddress=order?.billing_address,verifyCardOptions={nonce:payload.nonce,bin:payload.details.bin,amount:order?.total_amount_with_taxes_float,email:order?.customer_email,billingAddress:{givenName:billingAddress?.first_name,surname:billingAddress?.last_name,phoneNumber:billingAddress?.phone,streetAddress:billingAddress?.line_1,countryCodeAlpha2:billingAddress?.country_code,postalCode:billingAddress?.zip_code,region:billingAddress?.state_code,locality:billingAddress?.city},onLookupComplete:(_data,next)=>{next()}},response=await threeDSInstance.verifyCard(verifyCardOptions);return response.rawCardinalSDKVerificationData.Validated&&paymentSource?(paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"braintree_payments",attributes:{payment_method_nonce:response.nonce,options:{id:response.nonce,card:{last4:response.details.lastFour,exp_year:response.details.expirationYear,exp_month:response.details.expirationMonth,brand:response.details.cardType.toLowerCase()}}}}),!0):!1}catch(error){return console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}return!1};return(0,react_1.useEffect)(()=>{if(!ref&&authorization&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet","false"),authorization&&!loadBraintree&&!(0,isEmpty_1.default)(window)){const braintreeClient=require("braintree-web/client"),hostedFields=require("braintree-web/hosted-fields"),threeDSecure=require("braintree-web/three-d-secure");braintreeClient.create({authorization},(clientErr,clientInstance)=>{if(clientErr){console.error(clientErr);return}hostedFields.create({client:clientInstance,fields,styles},(hostedFieldsErr,hostedFieldsInstance)=>{if(hostedFieldsErr){console.error(hostedFieldsErr);return}setLoadBraintree(!0),threeDSecure.create({authorization,version:2},(threeDSecureErr,threeDSInstance)=>{threeDSecureErr&&(console.error("3DSecure error",threeDSecureErr),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:threeDSecureErr.message}])),ref.current&&(ref.current.onsubmit=paymentSource2=>handleSubmitForm({event:ref.current,hostedFieldsInstance,threeDSInstance,paymentSource:paymentSource2}),setPaymentRef({ref}))})})})}return()=>{setPaymentRef({ref:{current:null}}),setLoadBraintree(!1)}},[authorization,ref]),!authorization&&!loadBraintree?null:(0,jsx_runtime_1.jsx)("div",{className:containerClassName,children:(0,jsx_runtime_1.jsxs)("form",{ref,id:"braintree-form",onSubmit:handleSubmitForm,className:containerClassName,children:[(0,jsx_runtime_1.jsxs)("div",{className:fieldsContainerClassName,children:[(0,jsx_runtime_1.jsxs)("div",{className:cardContainerClassName,children:[(0,jsx_runtime_1.jsx)("label",{className:fieldLabelClassName,htmlFor:"card-number",children:fields?.number?.label}),(0,jsx_runtime_1.jsx)("div",{className:inputWrapperClassName,id:"card-number"})]}),(0,jsx_runtime_1.jsxs)("div",{className:cardDetailsContainerClassName,children:[(0,jsx_runtime_1.jsxs)("div",{className:expDateContainerClassName,children:[(0,jsx_runtime_1.jsx)("label",{className:fieldLabelClassName,htmlFor:"expiration-date",children:fields?.expirationDate?.label}),(0,jsx_runtime_1.jsx)("div",{className:inputWrapperClassName,id:"expiration-date"})]}),(0,jsx_runtime_1.jsxs)("div",{className:cvvContainerClassName,children:[(0,jsx_runtime_1.jsx)("label",{className:fieldLabelClassName,htmlFor:"cvv",children:fields?.cvv?.label}),(0,jsx_runtime_1.jsx)("div",{className:inputWrapperClassName,id:"cvv"})]})]})]}),(0,jsx_runtime_1.jsx)("div",{className:fieldsContainerClassName,children:templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})})]})})}exports.BraintreePayment=BraintreePayment,exports.default=BraintreePayment;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BraintreePayment=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),localStorage_1=require("../../utils/localStorage"),promisify_1=tslib_1.__importDefault(require("../../utils/promisify")),defaultConfig={styles:{input:{"font-size":"16px",color:"#3A3A3A"},".number":{"font-family":"monospace"},":focus":{color:"blue"},".valid":{color:"green"},".invalid":{color:"red"},"@media screen and (max-width: 700px)":{input:{"font-size":"14px"}}},fields:{number:{label:"Card Number",selector:"#card-number",placeholder:"4111 1111 1111 1111"},cvv:{label:"CVV",selector:"#cvv",placeholder:"123"},expirationDate:{label:"Expiration Date",selector:"#expiration-date",placeholder:"10/2022"}},submitLabel:"Set payment method"};function BraintreePayment({authorization,config,templateCustomerSaveToWallet}){const{fields,styles,containerClassName,cardContainerClassName,fieldsContainerClassName,expDateContainerClassName,fieldLabelClassName,cvvContainerClassName,inputWrapperClassName,cardDetailsContainerClassName}={...defaultConfig,...config},[loadBraintree,setLoadBraintree]=(0,react_1.useState)(!1),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),ref=(0,react_1.useRef)(null),handleSubmitForm=async({event,hostedFieldsInstance,threeDSInstance})=>{const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),hostedFieldsInstance)try{const payload=await(0,promisify_1.default)(hostedFieldsInstance).then(payload2=>payload2),billingAddress=order?.billing_address,verifyCardOptions={nonce:payload.nonce,bin:payload.details.bin,amount:order?.total_amount_with_taxes_float,email:order?.customer_email,billingAddress:{givenName:billingAddress?.first_name,surname:billingAddress?.last_name,phoneNumber:billingAddress?.phone,streetAddress:billingAddress?.line_1,countryCodeAlpha2:billingAddress?.country_code,postalCode:billingAddress?.zip_code,region:billingAddress?.state_code,locality:billingAddress?.city},onLookupComplete:(_data,next)=>{next()}},response=await threeDSInstance.verifyCard(verifyCardOptions);return response.rawCardinalSDKVerificationData.Validated&&paymentSource?(paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"braintree_payments",attributes:{payment_method_nonce:response.nonce,options:{id:response.nonce,card:{last4:response.details.lastFour,exp_year:response.details.expirationYear,exp_month:response.details.expirationMonth,brand:response.details.cardType.toLowerCase()}}}}),!0):!1}catch(error){return console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}return!1};return(0,react_1.useEffect)(()=>{if(!ref&&authorization&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet","false"),authorization&&!loadBraintree&&!(0,isEmpty_1.default)(window)){const braintreeClient=require("braintree-web/client"),hostedFields=require("braintree-web/hosted-fields"),threeDSecure=require("braintree-web/three-d-secure");braintreeClient.create({authorization},(clientErr,clientInstance)=>{if(clientErr){console.error(clientErr);return}hostedFields.create({client:clientInstance,fields,styles},(hostedFieldsErr,hostedFieldsInstance)=>{if(hostedFieldsErr){console.error(hostedFieldsErr);return}setLoadBraintree(!0),threeDSecure.create({authorization,version:2},(threeDSecureErr,threeDSInstance)=>{threeDSecureErr&&(console.error("3DSecure error",threeDSecureErr),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:threeDSecureErr.message}])),ref.current&&(ref.current.onsubmit=async paymentSource2=>await handleSubmitForm({event:ref.current,hostedFieldsInstance,threeDSInstance,paymentSource:paymentSource2}),setPaymentRef({ref}))})})})}return()=>{setPaymentRef({ref:{current:null}}),setLoadBraintree(!1)}},[authorization,ref]),!authorization&&!loadBraintree?null:(0,jsx_runtime_1.jsx)("div",{className:containerClassName,children:(0,jsx_runtime_1.jsxs)("form",{ref,id:"braintree-form",onSubmit:handleSubmitForm,className:containerClassName,children:[(0,jsx_runtime_1.jsxs)("div",{className:fieldsContainerClassName,children:[(0,jsx_runtime_1.jsxs)("div",{className:cardContainerClassName,children:[(0,jsx_runtime_1.jsx)("label",{className:fieldLabelClassName,htmlFor:"card-number",children:fields?.number?.label}),(0,jsx_runtime_1.jsx)("div",{className:inputWrapperClassName,id:"card-number"})]}),(0,jsx_runtime_1.jsxs)("div",{className:cardDetailsContainerClassName,children:[(0,jsx_runtime_1.jsxs)("div",{className:expDateContainerClassName,children:[(0,jsx_runtime_1.jsx)("label",{className:fieldLabelClassName,htmlFor:"expiration-date",children:fields?.expirationDate?.label}),(0,jsx_runtime_1.jsx)("div",{className:inputWrapperClassName,id:"expiration-date"})]}),(0,jsx_runtime_1.jsxs)("div",{className:cvvContainerClassName,children:[(0,jsx_runtime_1.jsx)("label",{className:fieldLabelClassName,htmlFor:"cvv",children:fields?.cvv?.label}),(0,jsx_runtime_1.jsx)("div",{className:inputWrapperClassName,id:"cvv"})]})]})]}),(0,jsx_runtime_1.jsx)("div",{className:fieldsContainerClassName,children:templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})})]})})}exports.BraintreePayment=BraintreePayment,exports.default=BraintreePayment;