@commercelayer/react-components 4.15.5 → 4.15.6

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 (207) hide show
  1. package/lib/cjs/components/MetadataInput.d.ts +1 -0
  2. package/lib/cjs/components/addresses/Address.d.ts +1 -0
  3. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +1 -0
  4. package/lib/cjs/components/addresses/AddressInput.d.ts +1 -0
  5. package/lib/cjs/components/addresses/AddressInputSelect.d.ts +1 -0
  6. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +1 -0
  7. package/lib/cjs/components/addresses/AddressesEmpty.d.ts +1 -0
  8. package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +1 -0
  9. package/lib/cjs/components/auth/CommerceLayer.d.ts +1 -0
  10. package/lib/cjs/components/customers/CustomerContainer.d.ts +1 -0
  11. package/lib/cjs/components/customers/CustomerField.d.ts +1 -0
  12. package/lib/cjs/components/customers/CustomerInput.d.ts +1 -0
  13. package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +1 -0
  14. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
  15. package/lib/cjs/components/customers/MyAccountLink.d.ts +1 -0
  16. package/lib/cjs/components/customers/MyIdentityLink.d.ts +1 -0
  17. package/lib/cjs/components/errors/Errors.d.ts +1 -0
  18. package/lib/cjs/components/gift_cards/GiftCard.d.ts +1 -0
  19. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
  20. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -0
  21. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
  22. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
  23. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
  24. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
  25. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
  26. package/lib/cjs/components/line_items/LineItem.d.ts +1 -0
  27. package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -0
  28. package/lib/cjs/components/line_items/LineItemCode.d.ts +1 -0
  29. package/lib/cjs/components/line_items/LineItemField.d.ts +1 -0
  30. package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -0
  31. package/lib/cjs/components/line_items/LineItemName.d.ts +1 -0
  32. package/lib/cjs/components/line_items/LineItemsContainer.d.ts +1 -0
  33. package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -0
  34. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +1 -0
  35. package/lib/cjs/components/orders/AdjustmentAmount.d.ts +1 -0
  36. package/lib/cjs/components/orders/CheckoutLink.d.ts +1 -0
  37. package/lib/cjs/components/orders/CheckoutLink.js +1 -1
  38. package/lib/cjs/components/orders/DiscountAmount.d.ts +1 -0
  39. package/lib/cjs/components/orders/GiftCardAmount.d.ts +1 -0
  40. package/lib/cjs/components/orders/OrderContainer.d.ts +1 -0
  41. package/lib/cjs/components/orders/OrderList.d.ts +1 -0
  42. package/lib/cjs/components/orders/OrderListEmpty.d.ts +1 -0
  43. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +1 -0
  44. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +1 -0
  45. package/lib/cjs/components/orders/OrderListRow.d.ts +1 -0
  46. package/lib/cjs/components/orders/OrderNumber.d.ts +1 -0
  47. package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +1 -0
  48. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  49. package/lib/cjs/components/orders/ShippingAmount.d.ts +1 -0
  50. package/lib/cjs/components/orders/SubTotalAmount.d.ts +1 -0
  51. package/lib/cjs/components/orders/TaxesAmount.d.ts +1 -0
  52. package/lib/cjs/components/orders/TotalAmount.d.ts +1 -0
  53. package/lib/cjs/components/parcels/ParcelField.d.ts +1 -0
  54. package/lib/cjs/components/parcels/ParcelLineItem.d.ts +1 -0
  55. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +1 -0
  56. package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  57. package/lib/cjs/components/parcels/Parcels.d.ts +1 -0
  58. package/lib/cjs/components/parcels/ParcelsCount.d.ts +1 -0
  59. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -0
  60. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  61. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  62. package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +1 -0
  63. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  64. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +1 -0
  65. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -0
  66. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -0
  67. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  68. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -0
  69. package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +1 -0
  70. package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  71. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +1 -0
  72. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +1 -0
  73. package/lib/cjs/components/payment_source/ExternalPayment.d.ts +1 -0
  74. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -0
  75. package/lib/cjs/components/payment_source/PaymentSource.d.ts +1 -0
  76. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  77. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  78. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  79. package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +1 -0
  80. package/lib/cjs/components/payment_source/StripePayment.d.ts +1 -0
  81. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +1 -0
  82. package/lib/cjs/components/prices/Price.d.ts +1 -0
  83. package/lib/cjs/components/prices/PricesContainer.d.ts +1 -0
  84. package/lib/cjs/components/shipments/ShipmentField.d.ts +1 -0
  85. package/lib/cjs/components/shipments/ShipmentsCount.d.ts +1 -0
  86. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  87. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  88. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  89. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +1 -0
  90. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +1 -0
  91. package/lib/cjs/components/skus/SkuField.d.ts +1 -0
  92. package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +1 -0
  93. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +1 -0
  94. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -0
  95. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +1 -0
  96. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +1 -0
  97. package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -0
  98. package/lib/cjs/components/utils/getAllErrors.d.ts +1 -0
  99. package/lib/cjs/reducers/OrderReducer.js +1 -1
  100. package/lib/cjs/typings/globals.d.ts +1 -0
  101. package/lib/cjs/utils/filterChildren.d.ts +1 -0
  102. package/lib/cjs/utils/getLoaderComponent.d.ts +1 -0
  103. package/lib/cjs/utils/getPrices.d.ts +1 -0
  104. package/lib/esm/components/MetadataInput.d.ts +1 -0
  105. package/lib/esm/components/addresses/Address.d.ts +1 -0
  106. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +1 -0
  107. package/lib/esm/components/addresses/AddressInput.d.ts +1 -0
  108. package/lib/esm/components/addresses/AddressInputSelect.d.ts +1 -0
  109. package/lib/esm/components/addresses/AddressStateSelector.d.ts +1 -0
  110. package/lib/esm/components/addresses/AddressesEmpty.d.ts +1 -0
  111. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +1 -0
  112. package/lib/esm/components/auth/CommerceLayer.d.ts +1 -0
  113. package/lib/esm/components/customers/CustomerContainer.d.ts +1 -0
  114. package/lib/esm/components/customers/CustomerField.d.ts +1 -0
  115. package/lib/esm/components/customers/CustomerInput.d.ts +1 -0
  116. package/lib/esm/components/customers/CustomerPaymentSource.d.ts +1 -0
  117. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
  118. package/lib/esm/components/customers/MyAccountLink.d.ts +1 -0
  119. package/lib/esm/components/customers/MyIdentityLink.d.ts +1 -0
  120. package/lib/esm/components/errors/Errors.d.ts +1 -0
  121. package/lib/esm/components/gift_cards/GiftCard.d.ts +1 -0
  122. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
  123. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -0
  124. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
  125. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
  126. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
  127. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
  128. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
  129. package/lib/esm/components/line_items/LineItem.d.ts +1 -0
  130. package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -0
  131. package/lib/esm/components/line_items/LineItemCode.d.ts +1 -0
  132. package/lib/esm/components/line_items/LineItemField.d.ts +1 -0
  133. package/lib/esm/components/line_items/LineItemImage.d.ts +1 -0
  134. package/lib/esm/components/line_items/LineItemName.d.ts +1 -0
  135. package/lib/esm/components/line_items/LineItemsContainer.d.ts +1 -0
  136. package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -0
  137. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +1 -0
  138. package/lib/esm/components/orders/AdjustmentAmount.d.ts +1 -0
  139. package/lib/esm/components/orders/CheckoutLink.d.ts +1 -0
  140. package/lib/esm/components/orders/CheckoutLink.js +1 -1
  141. package/lib/esm/components/orders/DiscountAmount.d.ts +1 -0
  142. package/lib/esm/components/orders/GiftCardAmount.d.ts +1 -0
  143. package/lib/esm/components/orders/OrderContainer.d.ts +1 -0
  144. package/lib/esm/components/orders/OrderList.d.ts +1 -0
  145. package/lib/esm/components/orders/OrderListEmpty.d.ts +1 -0
  146. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +1 -0
  147. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +1 -0
  148. package/lib/esm/components/orders/OrderListRow.d.ts +1 -0
  149. package/lib/esm/components/orders/OrderNumber.d.ts +1 -0
  150. package/lib/esm/components/orders/PaymentMethodAmount.d.ts +1 -0
  151. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
  152. package/lib/esm/components/orders/ShippingAmount.d.ts +1 -0
  153. package/lib/esm/components/orders/SubTotalAmount.d.ts +1 -0
  154. package/lib/esm/components/orders/TaxesAmount.d.ts +1 -0
  155. package/lib/esm/components/orders/TotalAmount.d.ts +1 -0
  156. package/lib/esm/components/parcels/ParcelField.d.ts +1 -0
  157. package/lib/esm/components/parcels/ParcelLineItem.d.ts +1 -0
  158. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +1 -0
  159. package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +1 -0
  160. package/lib/esm/components/parcels/Parcels.d.ts +1 -0
  161. package/lib/esm/components/parcels/ParcelsCount.d.ts +1 -0
  162. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -0
  163. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -0
  164. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
  165. package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +1 -0
  166. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -0
  167. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +1 -0
  168. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -0
  169. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -0
  170. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -0
  171. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -0
  172. package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +1 -0
  173. package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
  174. package/lib/esm/components/payment_source/BraintreePayment.d.ts +1 -0
  175. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +1 -0
  176. package/lib/esm/components/payment_source/ExternalPayment.d.ts +1 -0
  177. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -0
  178. package/lib/esm/components/payment_source/PaymentSource.d.ts +1 -0
  179. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
  180. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
  181. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -0
  182. package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +1 -0
  183. package/lib/esm/components/payment_source/StripePayment.d.ts +1 -0
  184. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +1 -0
  185. package/lib/esm/components/prices/Price.d.ts +1 -0
  186. package/lib/esm/components/prices/PricesContainer.d.ts +1 -0
  187. package/lib/esm/components/shipments/ShipmentField.d.ts +1 -0
  188. package/lib/esm/components/shipments/ShipmentsCount.d.ts +1 -0
  189. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -0
  190. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
  191. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
  192. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +1 -0
  193. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +1 -0
  194. package/lib/esm/components/skus/SkuField.d.ts +1 -0
  195. package/lib/esm/components/stock_transfers/StockTransfer.d.ts +1 -0
  196. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +1 -0
  197. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -0
  198. package/lib/esm/components/utils/BaseOrderPrice.d.ts +1 -0
  199. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +1 -0
  200. package/lib/esm/components/utils/PriceTemplate.d.ts +1 -0
  201. package/lib/esm/components/utils/getAllErrors.d.ts +1 -0
  202. package/lib/esm/reducers/OrderReducer.js +1 -1
  203. package/lib/esm/typings/globals.d.ts +1 -0
  204. package/lib/esm/utils/filterChildren.d.ts +1 -0
  205. package/lib/esm/utils/getLoaderComponent.d.ts +1 -0
  206. package/lib/esm/utils/getPrices.d.ts +1 -0
  207. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LoaderType } from '../../typings/index';
2
3
  import { type CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
3
4
  export interface CustomerCardsProps {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type IconBrand } from '../../context/PaymentSourceContext';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type IconBrand } from '../../context/PaymentSourceContext';
2
3
  import { type ChildrenFunction } from '../../typings/index';
3
4
  interface CustomComponent extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { ChildrenFunction } from '../../typings/index';
2
3
  export type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  interface Props {
2
3
  clientSecret: string;
3
4
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type StripeElementLocale, type StripeElementsOptions, type StripePaymentElementOptions } from '@stripe/stripe-js';
2
3
  import { type PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
3
4
  import { type PaymentSourceProps } from './PaymentSource';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface WireTransferConfig {
2
3
  infoMessage?: {
3
4
  text?: string | JSX.Element[];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type Price as PriceType } from '@commercelayer/sdk';
2
3
  import { type ChildrenFunction, type LoaderType } from '../../typings/index';
3
4
  interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LoaderType } from '../../typings/index';
2
3
  import { type QueryPageSize } from '@commercelayer/sdk';
3
4
  interface Props {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type Shipment } from '@commercelayer/sdk';
2
3
  type ShipmentFieldChildrenProps = Omit<Props, 'children'> & {
3
4
  shipment: Shipment;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ChildrenFunction } from '../../typings/index';
2
3
  import type { Shipment } from '@commercelayer/sdk';
3
4
  interface ChildrenProps extends Omit<Props, 'children'> {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ShippingMethod } from '@commercelayer/sdk';
2
3
  type ChildrenProps = Omit<Props, 'children'> & {
3
4
  label: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type BaseAmountComponent } from '../../typings/index';
2
3
  type Props = BaseAmountComponent & {
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { Order, ShippingMethod } from '@commercelayer/sdk';
2
3
  interface ShippingMethodRadioButtonType extends Omit<Props, 'children'> {
3
4
  shippingMethod: ShippingMethod;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type TimeFormat, type ChildrenFunction } from '../../typings/index';
2
3
  import { type DeliveryLeadTime } from '../../reducers/AvailabilityReducer';
3
4
  interface AvailabilityTemplateChildrenProps extends Omit<Props, 'children'>, DeliveryLeadTime {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type DeliveryLeadTimeField = 'min_hours' | 'max_hours' | 'min_days' | 'max_days';
2
3
  export type DeliveryLeadTimeComponentChildren = Omit<Props, 'children'>;
3
4
  type Props = Partial<JSX.IntrinsicElements['span']> & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ConditionalElement } from '../../typings/index';
2
3
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
3
4
  type SkuFieldChildrenProps = TGenericChildrenProps<TResources['Sku']>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { DefaultChildrenType } from '../../typings/globals';
2
3
  interface Props {
3
4
  children: DefaultChildrenType;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type ConditionalElement } from '../../typings/index';
2
3
  import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
3
4
  type StockTransferFieldChildrenProps = TGenericChildrenProps<TResources['StockTransfer']>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { Address } from '@commercelayer/sdk';
2
3
  import AddressChildrenContext from '../../context/AddressChildrenContext';
3
4
  import { type ChildrenFunction } from '../../typings/index';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type PropsType } from '../../utils/PropsType';
2
3
  import { type baseOrderPricePropTypes } from '../../typings/index';
3
4
  export type BaseOrderPriceProps = PropsType<typeof baseOrderPricePropTypes, unknown> & Omit<JSX.IntrinsicElements['span'], 'children'>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type PaymentResource } from '../../reducers/PaymentMethodReducer';
2
3
  import PaymentSourceContext, { type IconBrand } from '../../context/PaymentSourceContext';
3
4
  import { type ChildrenFunction } from '../../typings/index';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type PriceProps } from '../prices/Price';
2
3
  export type PTemplateProps = {
3
4
  formattedAmount?: string | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type LineItem } from '@commercelayer/sdk';
2
3
  import { type BaseError } from '../../typings/errors';
3
4
  import { type TResourceError } from '../errors/Errors';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";import{getOrganizationSlug}from"../utils/organization";import{publish}from"../utils/events";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export async function createOrder(params){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return"";const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Create order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""}export const getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return;const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id??"",options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return{success:!1};const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await getApiOrder({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=getErrors({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}export async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption,openMiniCart=!0}=params;try{if(config){const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:lineItem?._update_quantity??!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=await sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),await getApiOrder({id,...params})}else await getApiOrder({id,...params,state});if(!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=getOrganizationSlug(config.endpoint??""),params2=`${id}?accessToken=${config.accessToken??""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}else openMiniCart&&publish("open-cart");return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=getErrors({error,resource:"orders"});return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}}export const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};export async function setGiftCardOrCouponCode({code,codeType,dispatch,config,order,include,state}){try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,order:currentOrder,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success,order:currentOrder}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export async function removeGiftCardOrCouponCode({codeType,dispatch,config,order,include,state}){try{if(config&&order&&dispatch){const attributes={[codeType]:""},orderUpdated=await updateOrder({id:order.id,attributes,config,include,dispatch,state});return dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0,order:orderUpdated?.order}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export const orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
2
+ import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";import{getOrganizationSlug}from"../utils/organization";import{publish}from"../utils/events";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export async function createOrder(params){if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return"";const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Create order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""}export const getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return;const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id??"",options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors({error,resource:"orders"});console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=config!=null?getSdk(config):void 0;try{if(sdk==null)return{success:!1};const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await getApiOrder({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0,order}}catch(error){const errors=getErrors({error,resource:"orders"});return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...new Set([...resourcesIncluded,...resources])],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}export async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption,openMiniCart=!0}=params;try{if(config){const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl,metadata=lineItem?.metadata,frequency=lineItem?.frequency,externalPrice=lineItem?.externalPrice;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:lineItem?._update_quantity??!0,bundle_code:bundleCode,metadata,frequency};externalPrice===!0&&(attrs._external_price=externalPrice);const newLineItem=await sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),await getApiOrder({id,...params})}else await getApiOrder({id,...params,state});if(!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=getOrganizationSlug(config.endpoint??""),params2=`${id}?accessToken=${config.accessToken??""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.commercelayer.app/checkout/${params2}`;location.href=redirectUrl}else openMiniCart&&publish("open-cart");return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=getErrors({error,resource:"orders"});return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}}export const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};export async function setGiftCardOrCouponCode({code,codeType,dispatch,config,order,include,state}){try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,order:currentOrder,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success,order:currentOrder}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export async function removeGiftCardOrCouponCode({codeType,dispatch,config,order,include,state}){try{if(config&&order&&dispatch){const attributes={[codeType]:""},orderUpdated=await updateOrder({id:order.id,attributes,config,include,dispatch,state});return dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0,order:orderUpdated?.order}}return{success:!1}}catch(error){const errors=getErrors({error,resource:"orders",field:codeType});return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}}export const orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type DefaultChildrenType = JSX.Element[] | JSX.Element | null;
2
3
  type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
3
4
  export type TRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type DefaultChildrenType } from '../typings/globals';
2
3
  interface Props<T> {
3
4
  children: DefaultChildrenType;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import { type LoaderType } from '../typings/index';
2
3
  export default function getLoaderComponent(loader: LoaderType): JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type Price } from '@commercelayer/sdk';
2
3
  import { type PTemplateProps } from '../components/utils/PriceTemplate';
3
4
  export declare function getPriceByCode(skuPrices: Price[], code?: string): Price | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/react-components",
3
- "version": "4.15.5",
3
+ "version": "4.15.6",
4
4
  "description": "The Official Commerce Layer React Components",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.js",