@commercelayer/react-components 4.5.2-beta.2 → 4.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) 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 +17 -2
  9. package/lib/cjs/components/auth/CommerceLayer.js +1 -1
  10. package/lib/cjs/components/customers/CustomerContainer.d.ts +3 -1
  11. package/lib/cjs/components/customers/CustomerContainer.js +1 -1
  12. package/lib/cjs/components/customers/CustomerField.d.ts +0 -1
  13. package/lib/cjs/components/customers/CustomerInput.d.ts +0 -1
  14. package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +0 -1
  15. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +0 -1
  16. package/lib/cjs/components/customers/MyAccountLink.d.ts +0 -1
  17. package/lib/cjs/components/customers/MyIdentityLink.d.ts +0 -1
  18. package/lib/cjs/components/errors/Errors.d.ts +0 -1
  19. package/lib/cjs/components/gift_cards/GiftCard.d.ts +0 -1
  20. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -1
  21. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +0 -1
  22. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +0 -1
  23. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -1
  24. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +0 -1
  25. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +0 -1
  26. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +0 -1
  27. package/lib/cjs/components/line_items/LineItem.d.ts +0 -1
  28. package/lib/cjs/components/line_items/LineItemAmount.d.ts +0 -1
  29. package/lib/cjs/components/line_items/LineItemCode.d.ts +0 -1
  30. package/lib/cjs/components/line_items/LineItemField.d.ts +0 -1
  31. package/lib/cjs/components/line_items/LineItemImage.d.ts +0 -1
  32. package/lib/cjs/components/line_items/LineItemName.d.ts +0 -1
  33. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +0 -1
  34. package/lib/cjs/components/line_items/LineItemsCount.d.ts +0 -1
  35. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +0 -1
  36. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +0 -1
  37. package/lib/cjs/components/orders/CheckoutLink.d.ts +0 -1
  38. package/lib/cjs/components/orders/DiscountAmount.d.ts +0 -1
  39. package/lib/cjs/components/orders/GiftCardAmount.d.ts +0 -1
  40. package/lib/cjs/components/orders/OrderContainer.d.ts +0 -1
  41. package/lib/cjs/components/orders/OrderList.d.ts +0 -1
  42. package/lib/cjs/components/orders/OrderListEmpty.d.ts +0 -1
  43. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +0 -1
  44. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +0 -1
  45. package/lib/cjs/components/orders/OrderListRow.d.ts +0 -1
  46. package/lib/cjs/components/orders/OrderNumber.d.ts +0 -1
  47. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +0 -1
  48. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -1
  49. package/lib/cjs/components/orders/ShippingAmount.d.ts +0 -1
  50. package/lib/cjs/components/orders/SubTotalAmount.d.ts +0 -1
  51. package/lib/cjs/components/orders/TaxesAmount.d.ts +0 -1
  52. package/lib/cjs/components/orders/TotalAmount.d.ts +0 -1
  53. package/lib/cjs/components/parcels/ParcelField.d.ts +0 -1
  54. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +0 -1
  55. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +0 -1
  56. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +0 -1
  57. package/lib/cjs/components/parcels/Parcels.d.ts +0 -1
  58. package/lib/cjs/components/parcels/ParcelsCount.d.ts +0 -1
  59. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +0 -1
  60. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +0 -1
  61. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +0 -1
  62. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +0 -1
  63. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +0 -1
  64. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +0 -1
  65. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +0 -1
  66. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +0 -1
  67. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +0 -1
  68. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +0 -1
  69. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +0 -1
  70. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +0 -1
  71. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +0 -1
  72. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +0 -1
  73. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +0 -1
  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/StripeExpressPayment.d.ts +0 -1
  80. package/lib/cjs/components/payment_source/StripePayment.d.ts +0 -1
  81. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +0 -1
  82. package/lib/cjs/components/prices/Price.d.ts +19 -1
  83. package/lib/cjs/components/prices/PricesContainer.d.ts +0 -1
  84. package/lib/cjs/components/shipments/ShipmentField.d.ts +0 -1
  85. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +0 -1
  86. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +0 -1
  87. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +0 -1
  88. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -1
  89. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +0 -1
  90. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +0 -1
  91. package/lib/cjs/components/skus/SkuField.d.ts +0 -1
  92. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +0 -1
  93. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +0 -1
  94. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +0 -1
  95. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +0 -1
  96. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +0 -1
  97. package/lib/cjs/components/utils/PriceTemplate.d.ts +0 -1
  98. package/lib/cjs/components/utils/getAllErrors.d.ts +0 -1
  99. package/lib/cjs/context/BillingAddressFormContext.d.ts +1 -1
  100. package/lib/cjs/reducers/AddressReducer.d.ts +1 -1
  101. package/lib/cjs/reducers/AddressReducer.js +1 -1
  102. package/lib/cjs/reducers/CustomerReducer.d.ts +3 -2
  103. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  104. package/lib/cjs/typings/globals.d.ts +0 -1
  105. package/lib/cjs/typings/index.d.ts +1 -1
  106. package/lib/cjs/utils/filterChildren.d.ts +0 -1
  107. package/lib/cjs/utils/getCustomerIdByToken.d.ts +6 -0
  108. package/lib/cjs/utils/getCustomerIdByToken.js +2 -0
  109. package/lib/cjs/utils/getLoaderComponent.d.ts +0 -1
  110. package/lib/cjs/utils/getPrices.d.ts +0 -1
  111. package/lib/cjs/utils/isGuestToken.d.ts +6 -0
  112. package/lib/cjs/utils/isGuestToken.js +2 -0
  113. package/lib/esm/components/MetadataInput.d.ts +0 -1
  114. package/lib/esm/components/addresses/Address.d.ts +0 -1
  115. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +0 -1
  116. package/lib/esm/components/addresses/AddressInput.d.ts +0 -1
  117. package/lib/esm/components/addresses/AddressStateSelector.d.ts +0 -1
  118. package/lib/esm/components/addresses/AddressesEmpty.d.ts +0 -1
  119. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +0 -1
  120. package/lib/esm/components/auth/CommerceLayer.d.ts +17 -2
  121. package/lib/esm/components/auth/CommerceLayer.js +1 -1
  122. package/lib/esm/components/customers/CustomerContainer.d.ts +3 -1
  123. package/lib/esm/components/customers/CustomerContainer.js +1 -1
  124. package/lib/esm/components/customers/CustomerField.d.ts +0 -1
  125. package/lib/esm/components/customers/CustomerInput.d.ts +0 -1
  126. package/lib/esm/components/customers/CustomerPaymentSource.d.ts +0 -1
  127. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +0 -1
  128. package/lib/esm/components/customers/MyAccountLink.d.ts +0 -1
  129. package/lib/esm/components/customers/MyIdentityLink.d.ts +0 -1
  130. package/lib/esm/components/errors/Errors.d.ts +0 -1
  131. package/lib/esm/components/gift_cards/GiftCard.d.ts +0 -1
  132. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -1
  133. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +0 -1
  134. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +0 -1
  135. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -1
  136. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +0 -1
  137. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +0 -1
  138. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +0 -1
  139. package/lib/esm/components/line_items/LineItem.d.ts +0 -1
  140. package/lib/esm/components/line_items/LineItemAmount.d.ts +0 -1
  141. package/lib/esm/components/line_items/LineItemCode.d.ts +0 -1
  142. package/lib/esm/components/line_items/LineItemField.d.ts +0 -1
  143. package/lib/esm/components/line_items/LineItemImage.d.ts +0 -1
  144. package/lib/esm/components/line_items/LineItemName.d.ts +0 -1
  145. package/lib/esm/components/line_items/LineItemsContainer.d.ts +0 -1
  146. package/lib/esm/components/line_items/LineItemsCount.d.ts +0 -1
  147. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +0 -1
  148. package/lib/esm/components/orders/AdjustmentAmount.d.ts +0 -1
  149. package/lib/esm/components/orders/CheckoutLink.d.ts +0 -1
  150. package/lib/esm/components/orders/DiscountAmount.d.ts +0 -1
  151. package/lib/esm/components/orders/GiftCardAmount.d.ts +0 -1
  152. package/lib/esm/components/orders/OrderContainer.d.ts +0 -1
  153. package/lib/esm/components/orders/OrderList.d.ts +0 -1
  154. package/lib/esm/components/orders/OrderListEmpty.d.ts +0 -1
  155. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +0 -1
  156. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +0 -1
  157. package/lib/esm/components/orders/OrderListRow.d.ts +0 -1
  158. package/lib/esm/components/orders/OrderNumber.d.ts +0 -1
  159. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +0 -1
  160. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -1
  161. package/lib/esm/components/orders/ShippingAmount.d.ts +0 -1
  162. package/lib/esm/components/orders/SubTotalAmount.d.ts +0 -1
  163. package/lib/esm/components/orders/TaxesAmount.d.ts +0 -1
  164. package/lib/esm/components/orders/TotalAmount.d.ts +0 -1
  165. package/lib/esm/components/parcels/ParcelField.d.ts +0 -1
  166. package/lib/esm/components/parcels/ParcelLineItem.d.ts +0 -1
  167. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +0 -1
  168. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +0 -1
  169. package/lib/esm/components/parcels/Parcels.d.ts +0 -1
  170. package/lib/esm/components/parcels/ParcelsCount.d.ts +0 -1
  171. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +0 -1
  172. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +0 -1
  173. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +0 -1
  174. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +0 -1
  175. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +0 -1
  176. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +0 -1
  177. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +0 -1
  178. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +0 -1
  179. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +0 -1
  180. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +0 -1
  181. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +0 -1
  182. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +0 -1
  183. package/lib/esm/components/payment_source/BraintreePayment.d.ts +0 -1
  184. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +0 -1
  185. package/lib/esm/components/payment_source/ExternalPayment.d.ts +0 -1
  186. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +0 -1
  187. package/lib/esm/components/payment_source/PaymentSource.d.ts +0 -1
  188. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +0 -1
  189. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +0 -1
  190. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +0 -1
  191. package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +0 -1
  192. package/lib/esm/components/payment_source/StripePayment.d.ts +0 -1
  193. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +0 -1
  194. package/lib/esm/components/prices/Price.d.ts +19 -1
  195. package/lib/esm/components/prices/PricesContainer.d.ts +0 -1
  196. package/lib/esm/components/shipments/ShipmentField.d.ts +0 -1
  197. package/lib/esm/components/shipments/ShipmentsCount.d.ts +0 -1
  198. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +0 -1
  199. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +0 -1
  200. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -1
  201. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +0 -1
  202. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +0 -1
  203. package/lib/esm/components/skus/SkuField.d.ts +0 -1
  204. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +0 -1
  205. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +0 -1
  206. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +0 -1
  207. package/lib/esm/components/utils/BaseOrderPrice.d.ts +0 -1
  208. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +0 -1
  209. package/lib/esm/components/utils/PriceTemplate.d.ts +0 -1
  210. package/lib/esm/components/utils/getAllErrors.d.ts +0 -1
  211. package/lib/esm/context/BillingAddressFormContext.d.ts +1 -1
  212. package/lib/esm/reducers/AddressReducer.d.ts +1 -1
  213. package/lib/esm/reducers/AddressReducer.js +1 -1
  214. package/lib/esm/reducers/CustomerReducer.d.ts +3 -2
  215. package/lib/esm/reducers/CustomerReducer.js +1 -1
  216. package/lib/esm/typings/globals.d.ts +0 -1
  217. package/lib/esm/typings/index.d.ts +1 -1
  218. package/lib/esm/utils/filterChildren.d.ts +0 -1
  219. package/lib/esm/utils/getCustomerIdByToken.d.ts +6 -0
  220. package/lib/esm/utils/getCustomerIdByToken.js +2 -0
  221. package/lib/esm/utils/getLoaderComponent.d.ts +0 -1
  222. package/lib/esm/utils/getPrices.d.ts +0 -1
  223. package/lib/esm/utils/isGuestToken.d.ts +6 -0
  224. package/lib/esm/utils/isGuestToken.js +2 -0
  225. package/package.json +21 -21
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type TOrderList, type OrderListContent, type TableAccessor } from '../../context/OrderListChildrenContext';
3
2
  import { type Row } from '@tanstack/react-table';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type 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 { type 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 { type 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 { type 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 { type 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 { type 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 { type 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 { type ConditionalElement } from '../../typings/index';
3
2
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
4
3
  type ParcelFieldChildrenProps = TGenericChildrenProps<TResources['Parcel']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { DefaultChildrenType } from '../../typings/globals';
3
2
  interface Props {
4
3
  children: DefaultChildrenType;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ConditionalElement } from '../../typings/index';
3
2
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
4
3
  type ParcelLineItemFieldChildrenProps = TGenericChildrenProps<TResources['ParcelLineItem']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type 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 { type 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 { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function AdyenGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function BraintreeGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function CheckoutComGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function ExternalGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type 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 { type LoaderType } from '../../typings/index';
3
2
  import { type PaymentSourceProps } from '../payment_source/PaymentSource';
4
3
  export type GatewayBaseType = Props & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = Partial<GatewayBaseType>;
4
3
  export declare function PaypalGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type 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 { type GatewayBaseType } from '../payment_gateways/PaymentGateway';
3
2
  type Props = GatewayBaseType;
4
3
  export declare function WireTransferGateway(props: Props): JSX.Element | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { LoaderType } from '../../typings/index';
3
2
  import type { Order, PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
4
3
  import type { PaymentResource } from '../../reducers/PaymentMethodReducer';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildrenFunction } from '../../typings/index';
3
2
  interface ChildrenProps extends Omit<Props, 'children'> {
4
3
  labelName: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type 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 { type PaymentSourceProps } from './PaymentSource';
3
2
  import { type HostedFieldFieldOptions } from 'braintree-web';
4
3
  type BraintreeHostedFields<Type> = {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
3
2
  import { type PaymentSourceProps } from './PaymentSource';
4
3
  import { type FramesStyle } from 'frames-react';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildrenFunction } from '../../typings/index';
3
2
  import type { StripeElementLocale } from '@stripe/stripe-js';
4
3
  import { type PaymentSourceProps } from './PaymentSource';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
3
2
  import { type PaymentSourceProps } from './PaymentSource';
4
3
  type KlarnaPaymentProps = PaymentMethodConfig['klarnaPayment'] & JSX.IntrinsicElements['div'] & Partial<PaymentSourceProps['templateCustomerSaveToWallet']> & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type LoaderType } from '../../typings/index';
3
2
  import { type CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
4
3
  export interface CustomerCardsProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type IconBrand } from '../../context/PaymentSourceContext';
3
2
  import { type ChildrenFunction } from '../../typings/index';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type IconBrand } from '../../context/PaymentSourceContext';
3
2
  import { type ChildrenFunction } from '../../typings/index';
4
3
  interface CustomComponent extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ChildrenFunction } from '../../typings/index';
3
2
  export type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  clientSecret: string;
4
3
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type StripeElementLocale, type StripeElementsOptions, type StripePaymentElementOptions } from '@stripe/stripe-js';
3
2
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
4
3
  import { type PaymentSourceProps } from './PaymentSource';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface WireTransferConfig {
3
2
  infoMessage?: {
4
3
  text?: string | JSX.Element[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type Price as PriceType } from '@commercelayer/sdk';
3
2
  import { type ChildrenFunction, type LoaderType } from '../../typings/index';
4
3
  interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
@@ -8,9 +7,28 @@ interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
8
7
  }
9
8
  export interface PriceProps extends Omit<JSX.IntrinsicElements['span'], 'children'> {
10
9
  children?: ChildrenFunction<PriceChildrenProps>;
10
+ /**
11
+ * CSS class name to be added for the compare price
12
+ */
11
13
  compareClassName?: string;
14
+ /**
15
+ * When `false` the compare_at price will not be displayed
16
+ * @default true
17
+ */
12
18
  showCompare?: boolean;
19
+ /**
20
+ * The `sku_code` of the price to be fetched
21
+ */
13
22
  skuCode?: string | null;
14
23
  }
24
+ /**
25
+ * To display the price of your products with localized currency, discounts, and personalization rules, as shown in the code snippets below.
26
+ *
27
+ * Each price has an amount (the actual selling price) and an optional compare-at amount (the full price that you want to display to the customer — typically with a strikethrough).
28
+ * This component is the owner of the price information. It fetches the price of the specified SKU and dispatches it to the cl-price-amount children.
29
+ * <span type='info'>
30
+ * By default it shows the `formatted_amount` and `formatted_compare_at_amount` of the first price object, but it also allows to access to the full `Price`object via children props.
31
+ * </span>
32
+ */
15
33
  export declare function Price(props: PriceProps): JSX.Element;
16
34
  export default Price;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type LoaderType } 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 { type Shipment } from '@commercelayer/sdk';
3
2
  type ShipmentFieldChildrenProps = Omit<Props, 'children'> & {
4
3
  shipment: Shipment;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ChildrenFunction } from '../../typings/index';
3
2
  import type { Shipment } from '@commercelayer/sdk';
4
3
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ShippingMethod } from '@commercelayer/sdk';
3
2
  type ChildrenProps = Omit<Props, 'children'> & {
4
3
  label: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type BaseAmountComponent } from '../../typings/index';
3
2
  type Props = BaseAmountComponent & {
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Order, ShippingMethod } from '@commercelayer/sdk';
3
2
  interface ShippingMethodRadioButtonType extends Omit<Props, 'children'> {
4
3
  shippingMethod: ShippingMethod;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type TimeFormat, type ChildrenFunction } from '../../typings/index';
3
2
  import { type DeliveryLeadTime } from '../../reducers/AvailabilityReducer';
4
3
  interface AvailabilityTemplateChildrenProps extends Omit<Props, 'children'>, DeliveryLeadTime {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export type DeliveryLeadTimeField = 'min_hours' | 'max_hours' | 'min_days' | 'max_days';
3
2
  export type DeliveryLeadTimeComponentChildren = Omit<Props, 'children'>;
4
3
  type Props = Partial<JSX.IntrinsicElements['span']> & {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ConditionalElement } from '../../typings/index';
3
2
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
4
3
  type SkuFieldChildrenProps = TGenericChildrenProps<TResources['Sku']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { DefaultChildrenType } from '../../typings/globals';
3
2
  interface Props {
4
3
  children: DefaultChildrenType;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ConditionalElement } from '../../typings/index';
3
2
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
4
3
  type StockTransferFieldChildrenProps = TGenericChildrenProps<TResources['StockTransfer']>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Address } from '@commercelayer/sdk';
3
2
  import AddressChildrenContext from '../../context/AddressChildrenContext';
4
3
  import { type ChildrenFunction } from '../../typings/index';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PropsType } from '../../utils/PropsType';
3
2
  import { type baseOrderPricePropTypes } from '../../typings/index';
4
3
  export type BaseOrderPriceProps = PropsType<typeof baseOrderPricePropTypes, unknown> & Omit<JSX.IntrinsicElements['span'], 'children'>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PaymentResource } from '../../reducers/PaymentMethodReducer';
3
2
  import PaymentSourceContext, { type IconBrand } from '../../context/PaymentSourceContext';
4
3
  import { type ChildrenFunction } from '../../typings/index';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type PriceProps } from '../prices/Price';
3
2
  export type PTemplateProps = {
4
3
  formattedAmount?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type LineItem } from '@commercelayer/sdk';
3
2
  import { type BaseError } from '../../typings/errors';
4
3
  import { type TResourceError } from '../errors/Errors';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { Address } from '@commercelayer/sdk';
3
- export type AddressValuesKeys = `${keyof Address}` | `billing_address_${keyof Address}` | `shipping_address_${keyof Address}`;
3
+ export type AddressValuesKeys = `${keyof Address}` | `billing_address_${keyof Address}` | `shipping_address_${keyof Address}` | `billing_address_${`metadata_${string}`}`;
4
4
  export interface DefaultContextAddress {
5
5
  validation?: void;
6
6
  setValue?: (name: AddressValuesKeys, value: string | number | readonly string[]) => void;
@@ -14,7 +14,7 @@ export type AddressSchema = Omit<Address, 'created_at' | 'updated_at' | 'id' | '
14
14
  export interface AddressActionPayload {
15
15
  errors: BaseError[];
16
16
  billing_address: TCustomerAddress;
17
- shipping_address: AddressCreate;
17
+ shipping_address: AddressCreate & Record<string, string | null | undefined>;
18
18
  shipToDifferentAddress: boolean;
19
19
  billingAddressId: string;
20
20
  shippingAddressId: string;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";export const addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],addressInitialState={errors:[]},setAddressErrors=({errors,dispatch,currentErrors=[],resource})=>{const billingErrors=resource==="billing_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="billing_address"),shippingErrors=resource==="shipping_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="shipping_address"),finalErrors=[...billingErrors,...shippingErrors];dispatch&&dispatch({type:"setErrors",payload:{errors:finalErrors}})},setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})},setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${camelCase(resource)}Id`]:id}})};export async function saveAddresses({config,updateOrder,order,state,customerEmail}){const{shipToDifferentAddress,billing_address:billingAddress,shipping_address:shippingAddress,billingAddressId,shippingAddressId}=state;try{const sdk=getSdk(config);if(order){const currentBillingAddressRef=order?.billing_address?.reference;console.log("billingAddress",billingAddress),console.log("shippingAddress",shippingAddress);const orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId,customer_email:customerEmail};if(currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),!isEmpty(billingAddress)&&billingAddress){delete orderAttributes._billing_address_clone_id,delete orderAttributes._shipping_address_clone_id,orderAttributes._shipping_address_same_as_billing=!0;const address=await sdk.addresses.create(billingAddress);orderAttributes.billing_address=sdk.addresses.relationship(address.id)}if(shipToDifferentAddress&&(delete orderAttributes._shipping_address_same_as_billing,shippingAddressId&&(orderAttributes._shipping_address_clone_id=shippingAddressId),!isEmpty(shippingAddress)&&shippingAddress)){delete orderAttributes._shipping_address_clone_id;const address=await sdk.addresses.create(shippingAddress);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}if(!isEmpty(orderAttributes)&&updateOrder)return{success:!0,order:(await updateOrder({id:order.id,attributes:orderAttributes}))?.order}}return{success:!1}}catch(error){return console.error(error),{success:!1,error}}}const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default addressReducer;
2
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";export const addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],addressInitialState={errors:[]},setAddressErrors=({errors,dispatch,currentErrors=[],resource})=>{const billingErrors=resource==="billing_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="billing_address"),shippingErrors=resource==="shipping_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="shipping_address"),finalErrors=[...billingErrors,...shippingErrors];dispatch&&dispatch({type:"setErrors",payload:{errors:finalErrors}})},setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})},setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${camelCase(resource)}Id`]:id}})};export async function saveAddresses({config,updateOrder,order,state,customerEmail}){const{shipToDifferentAddress,billing_address:billingAddress,shipping_address:shippingAddress,billingAddressId,shippingAddressId}=state;try{const sdk=getSdk(config);if(order){const currentBillingAddressRef=order?.billing_address?.reference,orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId,customer_email:customerEmail};if(currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),billingAddress!=null&&Object.keys(billingAddress).length>0){delete orderAttributes._billing_address_clone_id,delete orderAttributes._shipping_address_clone_id,orderAttributes._shipping_address_same_as_billing=!0;const hasMetadata=Object.keys(billingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");billingAddress.metadata={...billingAddress.metadata||{},[metadataKey]:billingAddress[key]},delete billingAddress[key]});const address=await sdk.addresses.create(billingAddress);orderAttributes.billing_address=sdk.addresses.relationship(address.id)}if(shipToDifferentAddress&&(delete orderAttributes._shipping_address_same_as_billing,shippingAddressId&&(orderAttributes._shipping_address_clone_id=shippingAddressId),shippingAddress!=null&&Object.keys(shippingAddress).length>0)){delete orderAttributes._shipping_address_clone_id;const hasMetadata=Object.keys(shippingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");shippingAddress.metadata={...shippingAddress.metadata||{},[metadataKey]:shippingAddress[key]},delete shippingAddress[key]});const address=await sdk.addresses.create(shippingAddress);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}if(orderAttributes!=null&&updateOrder)return{success:!0,order:(await updateOrder({id:order.id,attributes:orderAttributes}))?.order}}return{success:!1}}catch(error){return console.error(error),{success:!1,error}}}const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default addressReducer;
@@ -4,7 +4,7 @@ import type { Address, AddressCreate, AddressUpdate, Customer, CustomerPaymentSo
4
4
  import { type CommerceLayerConfig } from '../context/CommerceLayerContext';
5
5
  import { type updateOrder } from './OrderReducer';
6
6
  import { type ListResponse } from '@commercelayer/sdk/lib/cjs/resource';
7
- export type CustomerActionType = 'setErrors' | 'setCustomerEmail' | 'setAddresses' | 'setPayments' | 'setOrders' | 'setSubscriptions';
7
+ export type CustomerActionType = 'setErrors' | 'setCustomerEmail' | 'setAddresses' | 'setPayments' | 'setOrders' | 'setSubscriptions' | 'setCustomers';
8
8
  export interface CustomerActionPayload {
9
9
  addresses: Address[] | null;
10
10
  payments: CustomerPaymentSource[] | null;
@@ -119,7 +119,7 @@ interface GetCustomerOrdersProps {
119
119
  }
120
120
  export declare function getCustomerOrders({ config, dispatch, pageSize, pageNumber }: GetCustomerOrdersProps): Promise<void>;
121
121
  export declare function getCustomerSubscriptions({ config, dispatch, pageSize, pageNumber }: GetCustomerOrdersProps): Promise<void>;
122
- export type TCustomerAddress = AddressCreate & AddressUpdate;
122
+ export type TCustomerAddress = AddressCreate & AddressUpdate & Record<string, string | null | undefined>;
123
123
  interface TCreateCustomerAddress {
124
124
  /**
125
125
  * Customer address dispatch function
@@ -142,6 +142,7 @@ export declare function createCustomerAddress({ address, config, dispatch, state
142
142
  interface GetCustomerPaymentsParams extends GetCustomerOrdersProps {
143
143
  }
144
144
  export declare function getCustomerPayments({ config, dispatch }: GetCustomerPaymentsParams): Promise<void>;
145
+ export declare function getCustomerInfo({ config, dispatch }: GetCustomerPaymentsParams): Promise<void>;
145
146
  export declare const customerInitialState: CustomerState;
146
147
  declare const customerReducer: (state: CustomerState, reducer: CustomerAction) => CustomerState;
147
148
  export default customerReducer;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";import jwtDecode from"../utils/jwt";export async function saveCustomerUser({customerEmail,order,updateOrder}){if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}}export function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}export function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}export async function getCustomerAddresses({config,dispatch,isOrderAvailable}){try{const addresses=[];(await getSdk(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&(customerAddress.id!==customerAddress.address.reference&&!isOrderAvailable&&(customerAddress.address.reference=customerAddress.id),addresses.push(customerAddress.address))}),addresses.sort((a,b)=>a.full_name&&b.full_name?a.full_name.localeCompare(b.full_name):0),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=getErrors({error,resource:"addresses"});dispatch({type:"setErrors",payload:{errors}})}}export async function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){if(config&&addresses&&dispatch&&config)try{await getSdk(config).customer_addresses.delete(customerAddressId);const newAddresses=addresses.filter(({reference})=>reference!==customerAddressId);dispatch({type:"setAddresses",payload:{addresses:newAddresses}})}catch{throw new Error("Couldn't delete address")}}export function getCustomerPaymentSources(params){if(params){const{order,dispatch}=params;order?.available_customer_payment_sources&&dispatch&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})}}export async function getCustomerOrders({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const orders=await getSdk(config).customers.orders(owner.id,{filters:{status_not_in:"draft,pending"},pageSize,pageNumber});dispatch({type:"setOrders",payload:{orders}})}}}export async function getCustomerSubscriptions({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const subscriptions=await getSdk(config).customers.order_subscriptions(owner.id,{pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}}}export async function createCustomerAddress({address,config,dispatch,state}){if(config&&address){const sdk=getSdk(config),{id}=address;try{if(id){const upAddress=await sdk.addresses.update(address),updatedAddresses=state?.addresses?.map(a=>a.id===upAddress.id?upAddress:a);dispatch&&dispatch({type:"setAddresses",payload:{addresses:updatedAddresses}})}else{const newAddress=await sdk.addresses.create(address);if(state?.customers?.id&&newAddress?.id){const newCustomerAddress=await sdk.customer_addresses.create({customer:sdk.customers.relationship(state?.customers?.id),address:sdk.addresses.relationship(newAddress.id)});await sdk.addresses.update({id:newAddress.id,reference:newCustomerAddress.id}),dispatch&&state?.addresses&&(newAddress.reference=newCustomerAddress.id,dispatch({type:"setAddresses",payload:{addresses:[...state.addresses,newAddress]}}))}}}catch{throw new Error("Couldn't create customer address")}}}export async function getCustomerPayments({config,dispatch}){if(config!=null&&dispatch!=null){const payments=await getSdk(config).customer_payment_sources.list({include:["payment_source"]});dispatch({type:"setPayments",payload:{payments}})}}export const customerInitialState={errors:[],addresses:null,payments:null};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders","setSubscriptions"],customerReducer=(state,reducer)=>baseReducer(state,reducer,type);export default customerReducer;
2
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";import jwtDecode from"../utils/jwt";import{getCustomerIdByToken}from"../utils/getCustomerIdByToken";export async function saveCustomerUser({customerEmail,order,updateOrder}){if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}}export function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}export function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}export async function getCustomerAddresses({config,dispatch,isOrderAvailable}){try{const addresses=[];(await getSdk(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&(customerAddress.id!==customerAddress.address.reference&&!isOrderAvailable&&(customerAddress.address.reference=customerAddress.id),addresses.push(customerAddress.address))}),addresses.sort((a,b)=>a.full_name&&b.full_name?a.full_name.localeCompare(b.full_name):0),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=getErrors({error,resource:"addresses"});dispatch({type:"setErrors",payload:{errors}})}}export async function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){if(config&&addresses&&dispatch&&config)try{await getSdk(config).customer_addresses.delete(customerAddressId);const newAddresses=addresses.filter(({reference})=>reference!==customerAddressId);dispatch({type:"setAddresses",payload:{addresses:newAddresses}})}catch{throw new Error("Couldn't delete address")}}export function getCustomerPaymentSources(params){if(params){const{order,dispatch}=params;order?.available_customer_payment_sources&&dispatch&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})}}export async function getCustomerOrders({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const orders=await getSdk(config).customers.orders(owner.id,{filters:{status_not_in:"draft,pending"},pageSize,pageNumber});dispatch({type:"setOrders",payload:{orders}})}}}export async function getCustomerSubscriptions({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const subscriptions=await getSdk(config).customers.order_subscriptions(owner.id,{pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}}}export async function createCustomerAddress({address,config,dispatch,state}){if(config&&address){const sdk=getSdk(config),{id}=address;try{if(id){const upAddress=await sdk.addresses.update(address),updatedAddresses=state?.addresses?.map(a=>a.id===upAddress.id?upAddress:a);dispatch&&dispatch({type:"setAddresses",payload:{addresses:updatedAddresses}})}else{const newAddress=await sdk.addresses.create(address);if(state?.customers?.id&&newAddress?.id){const newCustomerAddress=await sdk.customer_addresses.create({customer:sdk.customers.relationship(state?.customers?.id),address:sdk.addresses.relationship(newAddress.id)});await sdk.addresses.update({id:newAddress.id,reference:newCustomerAddress.id}),dispatch&&state?.addresses&&(newAddress.reference=newCustomerAddress.id,dispatch({type:"setAddresses",payload:{addresses:[...state.addresses,newAddress]}}))}}}catch{throw new Error("Couldn't create customer address")}}}export async function getCustomerPayments({config,dispatch}){if(config!=null&&dispatch!=null){const payments=await getSdk(config).customer_payment_sources.list({include:["payment_source"]});dispatch({type:"setPayments",payload:{payments}})}}export async function getCustomerInfo({config,dispatch}){if(config.accessToken&&dispatch!=null){const sdk=getSdk(config),customerId=getCustomerIdByToken(config.accessToken);if(customerId){const customers=await sdk.customers.retrieve(customerId);dispatch({type:"setCustomers",payload:{customers}})}}}export const customerInitialState={errors:[],addresses:null,payments:null};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders","setSubscriptions","setCustomers"],customerReducer=(state,reducer)=>baseReducer(state,reducer,type);export default customerReducer;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export type DefaultChildrenType = JSX.Element[] | JSX.Element | null;
3
2
  type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
4
3
  export type TRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
@@ -51,7 +51,7 @@ export interface BaseInputComponentProps {
51
51
  placeholder?: string;
52
52
  }
53
53
  export type GiftCardInputName = 'balanceCents' | 'balanceMaxCents' | 'singleUse' | 'rechargeable' | 'imageUrl' | 'expiresAt' | 'referenceOrigin' | 'email' | 'firstName' | 'lastName' | 'reference';
54
- export type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
54
+ export type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | `billing_address_${`metadata_${string}`}` | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
55
55
  export type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code';
56
56
  export type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code';
57
57
  export type LoaderType = string | JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type DefaultChildrenType } from '../typings/globals';
3
2
  interface Props<T> {
4
3
  children: DefaultChildrenType;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get the customer id from the token
3
+ * @param accessToken The access token
4
+ * @returns string
5
+ */
6
+ export declare function getCustomerIdByToken(accessToken: string): string | undefined;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import jwt from"./jwt";export function getCustomerIdByToken(accessToken){return jwt(accessToken)?.owner?.id}
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { type LoaderType } from '../typings/index';
3
2
  export default function getLoaderComponent(loader: LoaderType): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type Price } from '@commercelayer/sdk';
3
2
  import { type PTemplateProps } from '../components/utils/PriceTemplate';
4
3
  export declare function getPriceByCode(skuPrices: Price[], code?: string): Price | undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Check if the token is a sales channel token
3
+ * @param accessToken The access token
4
+ * @returns boolean
5
+ */
6
+ export declare function isGuestToken(accessToken: string): boolean;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import jwt from"./jwt";export function isGuestToken(accessToken){return jwt(accessToken).owner==null}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/react-components",
3
- "version": "4.5.2-beta.2",
3
+ "version": "4.6.0-beta.1",
4
4
  "description": "The Official Commerce Layer React Components",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -168,46 +168,46 @@
168
168
  "@ac-dev/countries-service": "^1.2.0",
169
169
  "@ac-dev/states-service": "^1.1.1",
170
170
  "@adyen/adyen-web": "^5.51.0",
171
- "@commercelayer/sdk": "^5.13.2",
172
- "@stripe/react-stripe-js": "^2.2.0",
173
- "@stripe/stripe-js": "^2.1.3",
174
- "@tanstack/react-table": "^8.9.8",
175
- "@types/iframe-resizer": "^3.5.9",
171
+ "@commercelayer/sdk": "^5.14.0",
172
+ "@stripe/react-stripe-js": "^2.3.0",
173
+ "@stripe/stripe-js": "^2.1.6",
174
+ "@tanstack/react-table": "^8.10.3",
175
+ "@types/iframe-resizer": "^3.5.10",
176
176
  "axios": "^1.5.0",
177
- "braintree-web": "^3.97.1",
177
+ "braintree-web": "^3.97.2",
178
178
  "frames-react": "^1.1.0",
179
- "iframe-resizer": "^4.3.6",
179
+ "iframe-resizer": "^4.3.7",
180
180
  "jwt-decode": "^3.1.2",
181
181
  "lodash": "^4.17.21",
182
182
  "rapid-form": "^2.1.0"
183
183
  },
184
184
  "devDependencies": {
185
185
  "@commercelayer/js-auth": "^4.1.1",
186
- "@faker-js/faker": "^8.0.2",
187
- "@playwright/test": "^1.37.1",
188
- "@testing-library/dom": "^9.3.1",
186
+ "@faker-js/faker": "^8.1.0",
187
+ "@playwright/test": "^1.38.1",
188
+ "@testing-library/dom": "^9.3.3",
189
189
  "@testing-library/react": "^14.0.0",
190
- "@types/braintree-web": "^3.96.4",
191
- "@types/lodash": "^4.14.198",
192
- "@types/node": "^20.6.0",
193
- "@types/prop-types": "^15.7.5",
194
- "@types/react": "^18.2.21",
195
- "@types/react-test-renderer": "^18.0.1",
190
+ "@types/braintree-web": "^3.96.5",
191
+ "@types/lodash": "^4.14.199",
192
+ "@types/node": "^20.7.0",
193
+ "@types/prop-types": "^15.7.7",
194
+ "@types/react": "^18.2.23",
195
+ "@types/react-test-renderer": "^18.0.2",
196
196
  "@types/react-window": "^1.8.5",
197
- "@vitejs/plugin-react": "^4.0.4",
197
+ "@vitejs/plugin-react": "^4.1.0",
198
198
  "@vitest/coverage-c8": "^0.33.0",
199
199
  "jsdom": "^22.1.0",
200
200
  "minimize-js": "^1.4.0",
201
- "msw": "^1.3.0",
201
+ "msw": "^1.3.1",
202
202
  "react": "^18.2.0",
203
203
  "react-dom": "^18.2.0",
204
204
  "react-test-renderer": "^18.2.0",
205
- "tsc-alias": "^1.8.7",
205
+ "tsc-alias": "^1.8.8",
206
206
  "tslib": "^2.6.2",
207
207
  "typescript": "^5.2.2",
208
208
  "vite": "^4.4.9",
209
209
  "vite-tsconfig-paths": "^4.2.1",
210
- "vitest": "^0.34.4"
210
+ "vitest": "^0.34.5"
211
211
  },
212
212
  "peerDependencies": {
213
213
  "react": "^18.0.0"