@commercelayer/react-components 4.0.0-alpha.5 → 4.0.0-alpha.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 (195) hide show
  1. package/lib/cjs/components/SubmitButton.d.ts +6 -15
  2. package/lib/cjs/components/SubmitButton.js +1 -1
  3. package/lib/cjs/components/addresses/AddressInput.d.ts +0 -11
  4. package/lib/cjs/components/addresses/AddressInput.js +1 -1
  5. package/lib/cjs/components/addresses/SaveAddressesButton.d.ts +4 -3
  6. package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -1
  7. package/lib/cjs/components/auth/CommerceLayer.d.ts +2 -9
  8. package/lib/cjs/components/auth/CommerceLayer.js +1 -1
  9. package/lib/cjs/components/customers/SaveCustomerButton.d.ts +6 -7
  10. package/lib/cjs/components/customers/SaveCustomerButton.js +1 -1
  11. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +8 -16
  12. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -1
  13. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +4 -12
  14. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
  15. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.d.ts +6 -12
  16. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -1
  17. package/lib/cjs/components/line_items/LineItemOption.d.ts +2 -2
  18. package/lib/cjs/components/line_items/LineItemQuantity.d.ts +4 -16
  19. package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
  20. package/lib/cjs/components/line_items/LineItemRemoveLink.d.ts +6 -16
  21. package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
  22. package/lib/cjs/components/line_items/LineItemsCount.d.ts +4 -14
  23. package/lib/cjs/components/line_items/LineItemsCount.js +1 -1
  24. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +6 -17
  25. package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -1
  26. package/lib/cjs/components/orders/AddToCartButton.d.ts +4 -5
  27. package/lib/cjs/components/orders/AddToCartButton.js +1 -1
  28. package/lib/cjs/components/orders/CartLink.d.ts +6 -6
  29. package/lib/cjs/components/orders/CartLink.js +1 -1
  30. package/lib/cjs/components/orders/CheckoutLink.d.ts +4 -4
  31. package/lib/cjs/components/orders/CheckoutLink.js +1 -1
  32. package/lib/cjs/components/orders/ItemContainer.d.ts +2 -13
  33. package/lib/cjs/components/orders/ItemContainer.js +1 -1
  34. package/lib/cjs/components/orders/OrderList.d.ts +10 -11
  35. package/lib/cjs/components/orders/OrderList.js +1 -1
  36. package/lib/cjs/components/orders/OrderListEmpty.d.ts +14 -0
  37. package/lib/cjs/components/orders/OrderListEmpty.js +1 -0
  38. package/lib/cjs/components/orders/OrderListRow.d.ts +1 -1
  39. package/lib/cjs/components/orders/PlaceOrderButton.d.ts +4 -14
  40. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
  41. package/lib/cjs/components/parcels/Parcel.d.ts +6 -0
  42. package/lib/cjs/components/parcels/Parcel.js +1 -0
  43. package/lib/cjs/components/payment_source/AdyenPayment.js +1 -1
  44. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +4 -14
  45. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -1
  46. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +4 -11
  47. package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -1
  48. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +6 -12
  49. package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -1
  50. package/lib/cjs/components/payment_source/PaymentSourceEditButton.d.ts +4 -10
  51. package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -1
  52. package/lib/cjs/components/prices/Price.d.ts +6 -18
  53. package/lib/cjs/components/prices/Price.js +1 -1
  54. package/lib/cjs/components/prices/PricesContainer.d.ts +4 -20
  55. package/lib/cjs/components/prices/PricesContainer.js +1 -1
  56. package/lib/cjs/components/shipments/Shipment.d.ts +2 -8
  57. package/lib/cjs/components/shipments/Shipment.js +1 -1
  58. package/lib/cjs/components/shipments/ShipmentField.d.ts +0 -7
  59. package/lib/cjs/components/shipments/ShipmentField.js +1 -1
  60. package/lib/cjs/components/shipments/ShipmentsContainer.d.ts +2 -8
  61. package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -1
  62. package/lib/cjs/components/shipping_methods/ShippingMethod.d.ts +2 -9
  63. package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -1
  64. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +0 -6
  65. package/lib/cjs/components/shipping_methods/ShippingMethodName.js +1 -1
  66. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +4 -13
  67. package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -1
  68. package/lib/cjs/components/skus/QuantitySelector.d.ts +4 -18
  69. package/lib/cjs/components/skus/QuantitySelector.js +1 -1
  70. package/lib/cjs/components/skus/VariantSelector.d.ts +4 -27
  71. package/lib/cjs/components/skus/VariantSelector.js +1 -1
  72. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +2 -2
  73. package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
  74. package/lib/cjs/components/utils/ErrorBoundary.d.ts +14 -0
  75. package/lib/cjs/components/utils/ErrorBoundary.js +1 -0
  76. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +2 -2
  77. package/lib/cjs/components/utils/PriceTemplate.d.ts +2 -2
  78. package/lib/cjs/components/utils/PriceTemplate.js +1 -1
  79. package/lib/cjs/context/BillingAddressFormContext.d.ts +2 -2
  80. package/lib/cjs/context/OrderListChildrenContext.d.ts +8 -0
  81. package/lib/cjs/context/ParcelChildrenContext.d.ts +7 -0
  82. package/lib/cjs/context/ParcelChildrenContext.js +1 -0
  83. package/lib/cjs/context/ShipmentChildrenContext.d.ts +6 -5
  84. package/lib/cjs/context/ShipmentChildrenContext.js +1 -1
  85. package/lib/cjs/index.d.ts +35 -34
  86. package/lib/cjs/index.js +1 -1
  87. package/lib/cjs/reducers/CustomerReducer.d.ts +16 -18
  88. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  89. package/lib/cjs/reducers/OrderReducer.d.ts +14 -24
  90. package/lib/cjs/reducers/ShipmentReducer.d.ts +1 -3
  91. package/lib/cjs/typings/errors.d.ts +2 -2
  92. package/lib/cjs/typings/index.d.ts +8 -16
  93. package/lib/cjs/utils/getPrices.d.ts +4 -15
  94. package/lib/cjs/utils/getPrices.js +1 -1
  95. package/lib/cjs/utils/getSdk.d.ts +1 -1
  96. package/lib/cjs/utils/organization.d.ts +2 -2
  97. package/lib/esm/components/SubmitButton.d.ts +6 -15
  98. package/lib/esm/components/SubmitButton.js +1 -1
  99. package/lib/esm/components/addresses/AddressInput.d.ts +0 -11
  100. package/lib/esm/components/addresses/AddressInput.js +1 -1
  101. package/lib/esm/components/addresses/SaveAddressesButton.d.ts +4 -3
  102. package/lib/esm/components/addresses/SaveAddressesButton.js +1 -1
  103. package/lib/esm/components/auth/CommerceLayer.d.ts +2 -9
  104. package/lib/esm/components/auth/CommerceLayer.js +1 -1
  105. package/lib/esm/components/customers/SaveCustomerButton.d.ts +6 -7
  106. package/lib/esm/components/customers/SaveCustomerButton.js +1 -1
  107. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +8 -16
  108. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.js +1 -1
  109. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +4 -12
  110. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
  111. package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.d.ts +6 -12
  112. package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.js +1 -1
  113. package/lib/esm/components/line_items/LineItemOption.d.ts +2 -2
  114. package/lib/esm/components/line_items/LineItemQuantity.d.ts +4 -16
  115. package/lib/esm/components/line_items/LineItemQuantity.js +1 -1
  116. package/lib/esm/components/line_items/LineItemRemoveLink.d.ts +6 -16
  117. package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -1
  118. package/lib/esm/components/line_items/LineItemsCount.d.ts +4 -14
  119. package/lib/esm/components/line_items/LineItemsCount.js +1 -1
  120. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +6 -17
  121. package/lib/esm/components/line_items/LineItemsEmpty.js +1 -1
  122. package/lib/esm/components/orders/AddToCartButton.d.ts +4 -5
  123. package/lib/esm/components/orders/AddToCartButton.js +1 -1
  124. package/lib/esm/components/orders/CartLink.d.ts +6 -6
  125. package/lib/esm/components/orders/CartLink.js +1 -1
  126. package/lib/esm/components/orders/CheckoutLink.d.ts +4 -4
  127. package/lib/esm/components/orders/CheckoutLink.js +1 -1
  128. package/lib/esm/components/orders/ItemContainer.d.ts +2 -13
  129. package/lib/esm/components/orders/ItemContainer.js +1 -1
  130. package/lib/esm/components/orders/OrderList.d.ts +10 -11
  131. package/lib/esm/components/orders/OrderList.js +1 -1
  132. package/lib/esm/components/orders/OrderListEmpty.d.ts +14 -0
  133. package/lib/esm/components/orders/OrderListEmpty.js +1 -0
  134. package/lib/esm/components/orders/OrderListRow.d.ts +1 -1
  135. package/lib/esm/components/orders/PlaceOrderButton.d.ts +4 -14
  136. package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
  137. package/lib/esm/components/parcels/Parcel.d.ts +6 -0
  138. package/lib/esm/components/parcels/Parcel.js +1 -0
  139. package/lib/esm/components/payment_source/AdyenPayment.js +1 -1
  140. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +4 -14
  141. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.js +1 -1
  142. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +4 -11
  143. package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -1
  144. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +6 -12
  145. package/lib/esm/components/payment_source/PaymentSourceDetail.js +1 -1
  146. package/lib/esm/components/payment_source/PaymentSourceEditButton.d.ts +4 -10
  147. package/lib/esm/components/payment_source/PaymentSourceEditButton.js +1 -1
  148. package/lib/esm/components/prices/Price.d.ts +6 -18
  149. package/lib/esm/components/prices/Price.js +1 -1
  150. package/lib/esm/components/prices/PricesContainer.d.ts +4 -20
  151. package/lib/esm/components/prices/PricesContainer.js +1 -1
  152. package/lib/esm/components/shipments/Shipment.d.ts +2 -8
  153. package/lib/esm/components/shipments/Shipment.js +1 -1
  154. package/lib/esm/components/shipments/ShipmentField.d.ts +0 -7
  155. package/lib/esm/components/shipments/ShipmentField.js +1 -1
  156. package/lib/esm/components/shipments/ShipmentsContainer.d.ts +2 -8
  157. package/lib/esm/components/shipments/ShipmentsContainer.js +1 -1
  158. package/lib/esm/components/shipping_methods/ShippingMethod.d.ts +2 -9
  159. package/lib/esm/components/shipping_methods/ShippingMethod.js +1 -1
  160. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +0 -6
  161. package/lib/esm/components/shipping_methods/ShippingMethodName.js +1 -1
  162. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +4 -13
  163. package/lib/esm/components/skus/AvailabilityTemplate.js +1 -1
  164. package/lib/esm/components/skus/QuantitySelector.d.ts +4 -18
  165. package/lib/esm/components/skus/QuantitySelector.js +1 -1
  166. package/lib/esm/components/skus/VariantSelector.d.ts +4 -27
  167. package/lib/esm/components/skus/VariantSelector.js +1 -1
  168. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +2 -2
  169. package/lib/esm/components/utils/BaseInput.d.ts +1 -1
  170. package/lib/esm/components/utils/ErrorBoundary.d.ts +14 -0
  171. package/lib/esm/components/utils/ErrorBoundary.js +1 -0
  172. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +2 -2
  173. package/lib/esm/components/utils/PriceTemplate.d.ts +2 -2
  174. package/lib/esm/components/utils/PriceTemplate.js +1 -1
  175. package/lib/esm/context/BillingAddressFormContext.d.ts +2 -2
  176. package/lib/esm/context/OrderListChildrenContext.d.ts +8 -0
  177. package/lib/esm/context/ParcelChildrenContext.d.ts +7 -0
  178. package/lib/esm/context/ParcelChildrenContext.js +1 -0
  179. package/lib/esm/context/ShipmentChildrenContext.d.ts +6 -5
  180. package/lib/esm/context/ShipmentChildrenContext.js +1 -1
  181. package/lib/esm/index.d.ts +35 -34
  182. package/lib/esm/index.js +1 -1
  183. package/lib/esm/reducers/CustomerReducer.d.ts +16 -18
  184. package/lib/esm/reducers/CustomerReducer.js +1 -1
  185. package/lib/esm/reducers/OrderReducer.d.ts +14 -24
  186. package/lib/esm/reducers/ShipmentReducer.d.ts +1 -3
  187. package/lib/esm/typings/errors.d.ts +2 -2
  188. package/lib/esm/typings/index.d.ts +8 -16
  189. package/lib/esm/utils/getPrices.d.ts +4 -15
  190. package/lib/esm/utils/getPrices.js +1 -1
  191. package/lib/esm/utils/getSdk.d.ts +1 -1
  192. package/lib/esm/utils/organization.d.ts +2 -2
  193. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  194. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  195. package/package.json +46 -35
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext}from"react";import Parent from"../utils/Parent";import components from"../../config/components";const displayName=components.PaymentSourceEditButton.displayName,propTypes=components.PaymentSourceEditButton.propTypes;export function PaymentSourceEditButton({children,label="Edit",...props}){const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps={showCard,label,handleEditClick,...props};return children?_jsx(Parent,{...parentProps,children}):readonly?null:_jsx("button",{...props,onClick:handleEditClick,children:label})}PaymentSourceEditButton.propTypes=propTypes,PaymentSourceEditButton.displayName=displayName;export default PaymentSourceEditButton;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext}from"react";import Parent from"../utils/Parent";export function PaymentSourceEditButton({children,label="Edit",...props}){const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps={showCard,label,handleEditClick,...props};return children?_jsx(Parent,{...parentProps,children}):readonly?null:_jsx("button",{...props,onClick:handleEditClick,children:label})}export default PaymentSourceEditButton;
@@ -1,28 +1,16 @@
1
1
  /// <reference types="react" />
2
2
  import { Price as PriceType } from '@commercelayer/sdk';
3
- import { FunctionChildren, LoaderType } from '../../typings/index';
4
- declare type PriceChildrenProps = FunctionChildren<{
3
+ import { ChildrenFunction, LoaderType } from '../../typings/index';
4
+ interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
5
5
  loading: boolean;
6
6
  loader: LoaderType;
7
7
  prices: PriceType[];
8
- } & Omit<PriceProps, 'children'>>;
9
- export declare type PriceProps = Partial<JSX.IntrinsicElements['span']> & {
10
- children?: PriceChildrenProps;
8
+ }
9
+ export interface PriceProps extends Omit<JSX.IntrinsicElements['span'], 'children'> {
10
+ children?: ChildrenFunction<PriceChildrenProps>;
11
11
  compareClassName?: string;
12
12
  showCompare?: boolean;
13
13
  skuCode?: string;
14
- };
15
- export declare function Price(props: PriceProps): JSX.Element;
16
- export declare namespace Price {
17
- var propTypes: {
18
- children: import("prop-types").Requireable<(...args: any[]) => any>;
19
- compareClassName: import("prop-types").Requireable<string>;
20
- skuCode: import("prop-types").Requireable<string>;
21
- showCompare: import("prop-types").Requireable<boolean>;
22
- };
23
- var defaultProps: {
24
- skuCode: string;
25
- };
26
- var displayName: string;
27
14
  }
15
+ export declare function Price(props: PriceProps): JSX.Element;
28
16
  export default Price;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useState,useEffect,useContext}from"react";import{isEmpty,has,indexOf}from"lodash";import Parent from"../utils/Parent";import PricesContext from"../../context/PricesContext";import{getPricesComponent}from"../../utils/getPrices";import components from"../../config/components";import SkuChildrenContext from"../../context/SkuChildrenContext";const propTypes=components.Price.propTypes,defaultProps=components.Price.defaultProps,displayName=components.Price.displayName;export function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=useContext(PricesContext),{sku}=useContext(SkuChildrenContext),[skuPrices,setSkuPrices]=useState([]),sCode=pricesSkuCode||skuCode||sku?.code;useEffect(()=>(!isEmpty(prices)&&has(prices,`${sCode}`)?setSkuPrices(prices[sCode]):sCode&&indexOf(skuCodes,sCode)===-1&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes(skuCodes)),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps={loading,loader,prices:skuPrices,...props},pricesComponent=isEmpty(prices)||isEmpty(skuPrices)?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,{...parentProps,children}):_jsx(Fragment,{children:loading||isEmpty(pricesComponent)?loader:pricesComponent})}Price.propTypes=propTypes,Price.defaultProps=defaultProps,Price.displayName=displayName;export default Price;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import Parent from"../utils/Parent";import PricesContext from"../../context/PricesContext";import{useState,useEffect,useContext}from"react";import{isEmpty,has,indexOf}from"lodash";import{getPricesComponent}from"../../utils/getPrices";import SkuChildrenContext from"../../context/SkuChildrenContext";export function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=useContext(PricesContext),{sku}=useContext(SkuChildrenContext),[skuPrices,setSkuPrices]=useState([]),sCode=pricesSkuCode||skuCode||sku?.code;useEffect(()=>(!isEmpty(prices)&&has(prices,`${sCode}`)?setSkuPrices(prices[sCode]):sCode&&indexOf(skuCodes,sCode)===-1&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes(skuCodes)),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps={loading,loader,prices:skuPrices,...props},pricesComponent=isEmpty(prices)||isEmpty(skuPrices)?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,{...parentProps,children}):_jsx(_Fragment,{children:loading||isEmpty(pricesComponent)?loader:pricesComponent})}export default Price;
@@ -1,27 +1,11 @@
1
- import { ReactNode } from 'react';
1
+ /// <reference types="react" />
2
2
  import { LoaderType } from '../../typings/index';
3
- declare type Props = {
4
- children: ReactNode;
3
+ interface Props {
4
+ children: JSX.Element | JSX.Element[];
5
5
  filters?: object;
6
6
  loader?: LoaderType;
7
7
  perPage?: number;
8
8
  skuCode?: string;
9
- };
10
- export declare function PricesContainer(props: Props): JSX.Element;
11
- export declare namespace PricesContainer {
12
- var propTypes: {
13
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
14
- skuCode: import("prop-types").Requireable<string>;
15
- loader: import("prop-types").Requireable<NonNullable<string | import("prop-types").ReactElementLike | null | undefined>>;
16
- perPage: import("prop-types").Requireable<number>;
17
- filters: import("prop-types").Requireable<object>;
18
- };
19
- var defaultProps: {
20
- perPage: number;
21
- filters: {};
22
- loader: string;
23
- skuCode: string;
24
- };
25
- var displayName: string;
26
9
  }
10
+ export declare function PricesContainer(props: Props): JSX.Element;
27
11
  export default PricesContainer;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useContext,useReducer}from"react";import getPrices from"../../utils/getPrices";import isEmpty from"lodash/isEmpty";import has from"lodash/has";import indexOf from"lodash/indexOf";import CommerceLayerContext from"../../context/CommerceLayerContext";import priceReducer,{unsetPriceState}from"../../reducers/PriceReducer";import{priceInitialState,getSkusPrice}from"../../reducers/PriceReducer";import PricesContext from"../../context/PricesContext";import getCurrentItemKey from"../../utils/getCurrentItemKey";import ItemContext from"../../context/ItemContext";import components from"../../config/components";import SkuContext from"../../context/SkuContext";const propTypes=components.PricesContainer.propTypes,defaultProps=components.PricesContainer.defaultProps,displayName=components.PricesContainer.displayName;export function PricesContainer(props){const{children,skuCode="",loader="Loading...",perPage=10,filters={}}=props,[state,dispatch]=useReducer(priceReducer,priceInitialState),config=useContext(CommerceLayerContext),{skuCodes}=useContext(SkuContext),{setPrices,prices,items,item:currentItem,skuCode:itemSkuCode}=useContext(ItemContext);indexOf(state.skuCodes,skuCode)===-1&&skuCode&&state.skuCodes.push(skuCode);const sCode=skuCodes&&skuCodes?.length>0?"":skuCode||getCurrentItemKey(currentItem)||itemSkuCode||"",setSkuCodes=skuCodes2=>{dispatch({type:"setSkuCodes",payload:{skuCodes:skuCodes2}})};useEffect(()=>{if(state.skuCodes.length===0&&skuCodes&&skuCodes.length>0&&setSkuCodes(skuCodes),currentItem&&has(prices,sCode)&&dispatch({type:"setPrices",payload:{prices}}),!isEmpty(items)&&isEmpty(currentItem)){const p=getPrices(items);dispatch({type:"setPrices",payload:{prices:p}})}return config.accessToken&&!has(prices,itemSkuCode||sCode)&&(state.skuCodes.length>0||itemSkuCode||sCode)&&getSkusPrice(sCode&&[itemSkuCode||sCode]||state.skuCodes,{config,dispatch,setPrices,prices,perPage,filters}),config.accessToken&&isEmpty(currentItem)&&(state.skuCodes.length>0||skuCode)&&getSkusPrice(sCode&&[sCode]||state.skuCodes,{config,dispatch,setPrices,prices,perPage,filters}),()=>{isEmpty(currentItem)&&unsetPriceState(dispatch)}},[config.accessToken,currentItem,sCode,state.skuCodes.length,itemSkuCode]);const priceValue={...state,skuCode:sCode,loader,setSkuCodes};return _jsx(PricesContext.Provider,{value:priceValue,children})}PricesContainer.propTypes=propTypes,PricesContainer.defaultProps=defaultProps,PricesContainer.displayName=displayName;export default PricesContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useContext,useReducer}from"react";import getPrices from"../../utils/getPrices";import isEmpty from"lodash/isEmpty";import has from"lodash/has";import indexOf from"lodash/indexOf";import CommerceLayerContext from"../../context/CommerceLayerContext";import priceReducer,{unsetPriceState,priceInitialState,getSkusPrice}from"../../reducers/PriceReducer";import PricesContext from"../../context/PricesContext";import getCurrentItemKey from"../../utils/getCurrentItemKey";import ItemContext from"../../context/ItemContext";import SkuContext from"../../context/SkuContext";export function PricesContainer(props){const{children,skuCode="",loader="Loading...",perPage=10,filters={}}=props,[state,dispatch]=useReducer(priceReducer,priceInitialState),config=useContext(CommerceLayerContext),{skuCodes}=useContext(SkuContext),{setPrices,prices,items,item:currentItem,skuCode:itemSkuCode}=useContext(ItemContext);indexOf(state.skuCodes,skuCode)===-1&&skuCode&&state.skuCodes.push(skuCode);const sCode=skuCodes&&skuCodes?.length>0?"":skuCode||getCurrentItemKey(currentItem)||itemSkuCode||"",setSkuCodes=skuCodes2=>{dispatch({type:"setSkuCodes",payload:{skuCodes:skuCodes2}})};useEffect(()=>{if(state.skuCodes.length===0&&skuCodes&&skuCodes.length>0&&setSkuCodes(skuCodes),currentItem&&has(prices,sCode)&&dispatch({type:"setPrices",payload:{prices}}),!isEmpty(items)&&isEmpty(currentItem)){const p=getPrices(items);dispatch({type:"setPrices",payload:{prices:p}})}return config.accessToken&&!has(prices,itemSkuCode||sCode)&&(state.skuCodes.length>0||itemSkuCode||sCode)&&getSkusPrice(sCode&&[itemSkuCode||sCode]||state.skuCodes,{config,dispatch,setPrices,prices,perPage,filters}),config.accessToken&&isEmpty(currentItem)&&(state.skuCodes.length>0||skuCode)&&getSkusPrice(sCode&&[sCode]||state.skuCodes,{config,dispatch,setPrices,prices,perPage,filters}),()=>{isEmpty(currentItem)&&unsetPriceState(dispatch)}},[config.accessToken,currentItem,sCode,state.skuCodes.length,itemSkuCode]);const priceValue={...state,skuCode:sCode,loader,setSkuCodes};return _jsx(PricesContext.Provider,{value:priceValue,children})}export default PricesContainer;
@@ -1,15 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { LoaderType } from '../../typings/index';
3
- declare type ShipmentProps = {
3
+ interface ShipmentProps {
4
4
  children: ReactNode;
5
5
  loader?: LoaderType;
6
6
  autoSelectSingleShippingMethod?: boolean | (() => void);
7
- };
8
- export declare function Shipment({ children, loader, autoSelectSingleShippingMethod, }: ShipmentProps): JSX.Element;
9
- export declare namespace Shipment {
10
- var propTypes: {
11
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
12
- };
13
- var displayName: string;
14
7
  }
8
+ export declare function Shipment({ children, loader, autoSelectSingleShippingMethod }: ShipmentProps): JSX.Element;
15
9
  export default Shipment;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShipmentContext from"../../context/ShipmentContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import components from"../../config/components";import getLoaderComponent from"../../utils/getLoaderComponent";const propTypes=components.Shipment.propTypes,displayName=components.Shipment.displayName;export function Shipment({children,loader="Loading...",autoSelectSingleShippingMethod=!1}){const[loading,setLoading]=useState(!0),{shipments,deliveryLeadTimes,setShippingMethod}=useContext(ShipmentContext);useEffect(()=>{shipments&&(autoSelectSingleShippingMethod?(async()=>await shipments.forEach(async shipment=>{const isSingle=shipment?.available_shipping_methods?.length===1;if(!shipment?.shipping_method&&isSingle){const[shippingMethod]=shipment?.available_shipping_methods||[];shippingMethod&&await setShippingMethod(shipment.id,shippingMethod.id),typeof autoSelectSingleShippingMethod=="function"&&autoSelectSingleShippingMethod()}else setTimeout(()=>{setLoading(!1)},200)}))():setLoading(!1))},[shipments]);const components2=shipments&&shipments.map((shipment,k)=>{const lineItems=shipment.shipment_line_items?.map(shipmentLineItem=>{const l=shipmentLineItem.line_item;return l&&(l.quantity=shipmentLineItem.quantity),l}),shippingMethods=shipment.available_shipping_methods,currentShippingMethodId=autoSelectSingleShippingMethod&&shippingMethods&&shippingMethods.length===1?shippingMethods[0]?.id:shipment.shipping_method?.id,stockTransfers=shipment.stock_transfers,times=deliveryLeadTimes?.filter(time=>time.stock_location?.id===shipment.stock_location?.id),shipmentProps={lineItems,shippingMethods,currentShippingMethodId,stockTransfers,deliveryLeadTimes:times,shipment,keyNumber:k+1};return _jsx(ShipmentChildrenContext.Provider,{value:shipmentProps,children},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components2})}Shipment.propTypes=propTypes,Shipment.displayName=displayName;export default Shipment;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShipmentContext from"../../context/ShipmentContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";export function Shipment({children,loader="Loading...",autoSelectSingleShippingMethod=!1}){const[loading,setLoading]=useState(!0),{shipments,deliveryLeadTimes,setShippingMethod}=useContext(ShipmentContext);useEffect(()=>{shipments&&(autoSelectSingleShippingMethod?(async()=>shipments.forEach(async shipment=>{const isSingle=shipment?.available_shipping_methods?.length===1;if(!shipment?.shipping_method&&isSingle){const[shippingMethod]=shipment?.available_shipping_methods||[];shippingMethod&&await setShippingMethod(shipment.id,shippingMethod.id),typeof autoSelectSingleShippingMethod=="function"&&autoSelectSingleShippingMethod()}else setTimeout(()=>{setLoading(!1)},200)}))():setLoading(!1))},[shipments]);const components=shipments?.map((shipment,k)=>{const lineItems=shipment.shipment_line_items?.map(shipmentLineItem=>{const l=shipmentLineItem.line_item;return l&&(l.quantity=shipmentLineItem.quantity),l}),shippingMethods=shipment.available_shipping_methods,currentShippingMethodId=autoSelectSingleShippingMethod&&shippingMethods&&shippingMethods.length===1?shippingMethods[0]?.id:shipment.shipping_method?.id,stockTransfers=shipment.stock_transfers,parcels=shipment.parcels,times=deliveryLeadTimes?.filter(time=>time.stock_location?.id===shipment.stock_location?.id),shipmentProps={parcels,lineItems,shippingMethods,currentShippingMethodId,stockTransfers,deliveryLeadTimes:times,shipment,keyNumber:k+1};return _jsx(ShipmentChildrenContext.Provider,{value:shipmentProps,children},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default Shipment;
@@ -9,11 +9,4 @@ declare type Props = {
9
9
  name: ShipmentAttribute;
10
10
  } & JSX.IntrinsicElements['span'];
11
11
  export declare function ShipmentField(props: Props): JSX.Element;
12
- export declare namespace ShipmentField {
13
- var propTypes: {
14
- children: import("prop-types").Requireable<(...args: any[]) => any>;
15
- name: import("prop-types").Validator<NonNullable<ShipmentAttribute>>;
16
- };
17
- var displayName: string;
18
- }
19
12
  export default ShipmentField;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import components from"../../config/components";import get from"lodash/get";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";const propTypes=components.ShipmentField.propTypes,displayName=components.ShipmentField.displayName;export function ShipmentField(props){const{name}=props,{shipment,keyNumber}=useContext(ShipmentChildrenContext),key=name,text=key!=="key_number"?get(shipment,key):keyNumber,parentProps={shipment,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...props,children:text})}ShipmentField.propTypes=propTypes,ShipmentField.displayName=displayName;export default ShipmentField;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import get from"lodash/get";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function ShipmentField(props){const{name}=props,{shipment,keyNumber}=useContext(ShipmentChildrenContext),key=name,text=key!=="key_number"?get(shipment,key):keyNumber,parentProps={shipment,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...props,children:text})}export default ShipmentField;
@@ -1,12 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props {
3
3
  children: ReactNode;
4
- };
5
- export declare function ShipmentsContainer(props: Props): JSX.Element;
6
- export declare namespace ShipmentsContainer {
7
- var propTypes: {
8
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
9
- };
10
- var displayName: string;
11
4
  }
5
+ export declare function ShipmentsContainer(props: Props): JSX.Element;
12
6
  export default ShipmentsContainer;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import ShipmentContext,{defaultShipmentContext}from"../../context/ShipmentContext";import{useContext,useEffect,useReducer}from"react";import shipmentReducer,{shipmentInitialState,setShipmentErrors,getShipments,setShippingMethod}from"../../reducers/ShipmentReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import components from"../../config/components";import isEmpty from"lodash/isEmpty";const propTypes=components.ShipmentsContainer.propTypes,displayName=components.ShipmentsContainer.displayName;export function ShipmentsContainer(props){const{children}=props,[state,dispatch]=useReducer(shipmentReducer,shipmentInitialState),{order,getOrder,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.shipment_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location"]}),order&&!isEmpty(config)&&order.shipments&&getShipments({order,dispatch,config})},[order,include,includeLoaded]),useEffect(()=>(order&&(order.shipments&&order.shipments.length>0&&order.shipments.map(shipment=>shipment.available_shipping_methods&&shipment.available_shipping_methods.length>0).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"NO_SHIPPING_METHODS",message:"No shipping methods",resource:"shipments"}],dispatch),order.line_items&&order.line_items.length>0&&order.line_items.filter(({item_type})=>item_type==="skus").map(lineItem=>!!(lineItem.item?.do_not_ship||lineItem.item?.do_not_track||lineItem.item?.inventory?.quantity>=lineItem?.quantity)).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"OUT_OF_STOCK",message:"No stock available",resource:"line_items"}],dispatch)),()=>{setShipmentErrors([],dispatch)}),[order?.shipments]);const contextValue={...state,setShipmentErrors:errors=>defaultShipmentContext.setShipmentErrors(errors,dispatch),setShippingMethod:async(shipmentId,shippingMethodId)=>await setShippingMethod({shippingMethodId,shipmentId,config,getOrder,order})};return _jsx(ShipmentContext.Provider,{value:contextValue,children})}ShipmentsContainer.propTypes=propTypes,ShipmentsContainer.displayName=displayName;export default ShipmentsContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import ShipmentContext,{defaultShipmentContext}from"../../context/ShipmentContext";import{useContext,useEffect,useReducer}from"react";import shipmentReducer,{shipmentInitialState,setShipmentErrors,getShipments,setShippingMethod}from"../../reducers/ShipmentReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import isEmpty from"lodash/isEmpty";export function ShipmentsContainer(props){const{children}=props,[state,dispatch]=useReducer(shipmentReducer,shipmentInitialState),{order,getOrder,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0,"shipments.parcels":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.shipment_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location","shipments.parcels"]}),order&&!isEmpty(config)&&order.shipments&&getShipments({order,dispatch,config})},[order,include,includeLoaded]),useEffect(()=>(order&&(order.shipments&&order.shipments.length>0&&order.shipments.map(shipment=>shipment.available_shipping_methods&&shipment.available_shipping_methods.length>0).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"NO_SHIPPING_METHODS",message:"No shipping methods",resource:"shipments"}],dispatch),order.line_items&&order.line_items.length>0&&order.line_items.filter(({item_type:itemType})=>itemType==="skus").map(lineItem=>!!(lineItem.item?.do_not_ship||lineItem.item?.do_not_track||lineItem.item?.inventory?.quantity>=lineItem?.quantity)).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"OUT_OF_STOCK",message:"No stock available",resource:"line_items"}],dispatch)),()=>{setShipmentErrors([],dispatch)}),[order?.shipments]);const contextValue={...state,setShipmentErrors:errors=>defaultShipmentContext.setShipmentErrors(errors,dispatch),setShippingMethod:async(shipmentId,shippingMethodId)=>await setShippingMethod({shippingMethodId,shipmentId,config,getOrder,order})};return _jsx(ShipmentContext.Provider,{value:contextValue,children})}export default ShipmentsContainer;
@@ -1,15 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props {
3
3
  children: ReactNode;
4
4
  readonly?: boolean;
5
5
  emptyText?: string;
6
- };
7
- export declare function ShippingMethod(props: Props): JSX.Element;
8
- export declare namespace ShippingMethod {
9
- var propTypes: {
10
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
11
- readonly: import("prop-types").Requireable<boolean>;
12
- };
13
- var displayName: string;
14
6
  }
7
+ export declare function ShippingMethod(props: Props): JSX.Element;
15
8
  export default ShippingMethod;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import components from"../../config/components";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import isEmpty from"lodash/isEmpty";const propTypes=components.ShippingMethod.propTypes,displayName=components.ShippingMethod.displayName;export function ShippingMethod(props){const{children,readonly,emptyText="There are not any shipping method available"}=props,{shippingMethods,currentShippingMethodId,deliveryLeadTimes,shipment}=useContext(ShipmentChildrenContext),[items,setItems]=useState([]);useEffect(()=>{const methods=shippingMethods&&shippingMethods.filter(s=>readonly?s.id===currentShippingMethodId:!0).map((shippingMethod,k)=>{const[deliveryLeadTimeForShipment]=deliveryLeadTimes?.filter(delivery=>{const deliveryShippingMethodId=delivery.shipping_method?.id;return shippingMethod.id===deliveryShippingMethodId}),shippingProps={shipmentId:shipment?.id,shippingMethod,currentShippingMethodId,deliveryLeadTimeForShipment};return _jsx(ShippingMethodChildrenContext.Provider,{value:shippingProps,children},k)});methods&&setItems(methods)},[currentShippingMethodId,deliveryLeadTimes,shippingMethods]);const components2=!isEmpty(items)&&items||emptyText;return _jsx(Fragment,{children:components2})}ShippingMethod.propTypes=propTypes,ShippingMethod.displayName=displayName;export default ShippingMethod;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import isEmpty from"lodash/isEmpty";export function ShippingMethod(props){const{children,readonly,emptyText="There are not any shipping method available"}=props,{shippingMethods,currentShippingMethodId,deliveryLeadTimes,shipment}=useContext(ShipmentChildrenContext),[items,setItems]=useState([]);useEffect(()=>{const methods=shippingMethods?.filter(s=>readonly?s.id===currentShippingMethodId:!0).map((shippingMethod,k)=>{const[deliveryLeadTimeForShipment]=deliveryLeadTimes?.filter(delivery=>{const deliveryShippingMethodId=delivery.shipping_method?.id;return shippingMethod.id===deliveryShippingMethodId}),shippingProps={shipmentId:shipment?.id,shippingMethod,currentShippingMethodId,deliveryLeadTimeForShipment};return _jsx(ShippingMethodChildrenContext.Provider,{value:shippingProps,children},k)});methods&&setItems(methods)},[currentShippingMethodId,deliveryLeadTimes,shippingMethods]);const components=!isEmpty(items)&&items||emptyText;return _jsx(_Fragment,{children:components})}export default ShippingMethod;
@@ -8,10 +8,4 @@ declare type Props = {
8
8
  children?: (props: ChildrenProps) => JSX.Element;
9
9
  } & JSX.IntrinsicElements['label'];
10
10
  export declare function ShippingMethodName(props: Props): JSX.Element;
11
- export declare namespace ShippingMethodName {
12
- var propTypes: {
13
- children: import("prop-types").Requireable<(...args: any[]) => any>;
14
- };
15
- var displayName: string;
16
- }
17
11
  export default ShippingMethodName;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";import components from"../../config/components";const propTypes=components.ShippingMethodName.propTypes,displayName=components.ShippingMethodName.displayName;export function ShippingMethodName(props){const{shippingMethod,deliveryLeadTimeForShipment,shipmentId}=useContext(ShippingMethodChildrenContext),htmlFor=`shipment-${shipmentId}-${shippingMethod?.id}`||"",labelName=shippingMethod?.name,parentProps={shippingMethod,deliveryLeadTimeForShipment,label:labelName,htmlFor,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("label",{htmlFor,...props,children:labelName})}ShippingMethodName.propTypes=propTypes,ShippingMethodName.displayName=displayName;export default ShippingMethodName;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";export function ShippingMethodName(props){const{shippingMethod,deliveryLeadTimeForShipment,shipmentId}=useContext(ShippingMethodChildrenContext),htmlFor=`shipment-${shipmentId??""}-${shippingMethod?.id??""}`||"",labelName=shippingMethod?.name,parentProps={shippingMethod,deliveryLeadTimeForShipment,label:labelName,htmlFor,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("label",{htmlFor,...props,children:labelName})}export default ShippingMethodName;
@@ -1,24 +1,15 @@
1
1
  /// <reference types="react" />
2
- import { TimeFormat, FunctionChildren } from '../../typings/index';
2
+ import { TimeFormat, ChildrenFunction } from '../../typings/index';
3
3
  import { DeliveryLeadTime } from '../../reducers/AvailabilityReducer';
4
- declare type AvailabilityTemplateChildrenProps = FunctionChildren<Omit<Props, 'children'> & DeliveryLeadTime & {
4
+ interface AvailabilityTemplateChildrenProps extends Omit<Props, 'children'>, DeliveryLeadTime {
5
5
  text: string;
6
6
  quantity: number;
7
- }>;
7
+ }
8
8
  declare type Props = {
9
- children?: AvailabilityTemplateChildrenProps;
9
+ children?: ChildrenFunction<AvailabilityTemplateChildrenProps>;
10
10
  timeFormat?: TimeFormat;
11
11
  showShippingMethodName?: boolean;
12
12
  showShippingMethodPrice?: boolean;
13
13
  } & JSX.IntrinsicElements['p'];
14
14
  export declare function AvailabilityTemplate(props: Props): JSX.Element;
15
- export declare namespace AvailabilityTemplate {
16
- var propTypes: {
17
- timeFormat: import("prop-types").Requireable<TimeFormat>;
18
- showShippingMethodName: import("prop-types").Requireable<boolean>;
19
- children: import("prop-types").Requireable<(...args: any[]) => any>;
20
- };
21
- var defaultProps: Props;
22
- var displayName: string;
23
- }
24
15
  export default AvailabilityTemplate;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import AvailabilityContext from"../../context/AvailabilityContext";import Parent from"../utils/Parent";import{isEmpty}from"lodash";import components from"../../config/components";import ItemContext from"../../context/ItemContext";import SkuChildrenContext from"../../context/SkuChildrenContext";const propTypes=components.AvailabilityTemplate.propTypes,defaultProps=components.AvailabilityTemplate.defaultProps,displayName=components.AvailabilityTemplate.displayName;export function AvailabilityTemplate(props){const{timeFormat,showShippingMethodName,showShippingMethodPrice,children,...p}=props;let{min,max,shipping_method,quantity}=useContext(AvailabilityContext);const{item}=useContext(ItemContext),{sku}=useContext(SkuChildrenContext),text=[];if(item&&sku){const code=sku.code,currentItem=item[code];if(currentItem){const[level]=currentItem.inventory?.levels||[],[delivery]=level?.delivery_lead_times||[];delivery&&(min=delivery?.min,max=delivery?.max,shipping_method=delivery?.shipping_method),quantity=currentItem.inventory.quantity}}const mn=!isEmpty(min)&&timeFormat?min?.[timeFormat]:"",mx=!isEmpty(max)&&timeFormat?max?.[timeFormat]:"",shippingMethodPrice=showShippingMethodPrice&&shipping_method?.formatted_price_amount?`(${shipping_method?.formatted_price_amount})`:"",name=showShippingMethodName&&shipping_method?`with ${shipping_method.name}`:"";quantity&&quantity>0?(text.push("Available"),mn&&mx&&text.push(`in ${mn} - ${mx} ${timeFormat} ${name} ${shippingMethodPrice}`)):quantity===0&&text.push("Out of stock");const parentProps={min,max,shipping_method,quantity,text:text.join(" "),...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("p",{...p,children:text.join(" ")})}AvailabilityTemplate.propTypes=propTypes,AvailabilityTemplate.defaultProps=defaultProps,AvailabilityTemplate.displayName=displayName;export default AvailabilityTemplate;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import AvailabilityContext from"../../context/AvailabilityContext";import Parent from"../utils/Parent";import{isEmpty}from"lodash";import ItemContext from"../../context/ItemContext";import SkuChildrenContext from"../../context/SkuChildrenContext";export function AvailabilityTemplate(props){const{timeFormat,showShippingMethodName,showShippingMethodPrice,children,...p}=props;let{min,max,shipping_method:shippingMethod,quantity}=useContext(AvailabilityContext);const{item}=useContext(ItemContext),{sku}=useContext(SkuChildrenContext),text=[];if(item&&sku){const code=sku.code,currentItem=item[code];if(currentItem){const[level]=currentItem.inventory?.levels||[],[delivery]=level?.delivery_lead_times||[];delivery&&(min=delivery?.min,max=delivery?.max,shippingMethod=delivery?.shipping_method),quantity=currentItem.inventory.quantity}}const mn=!isEmpty(min)&&timeFormat?min?.[timeFormat]:"",mx=!isEmpty(max)&&timeFormat?max?.[timeFormat]:"",shippingMethodPrice=showShippingMethodPrice&&shippingMethod?.formatted_price_amount?`(${shippingMethod?.formatted_price_amount})`:"",name=showShippingMethodName&&shippingMethod?`with ${shippingMethod.name}`:"";quantity&&quantity>0?(text.push("Available"),mn&&mx&&text.push(`in ${mn} - ${mx} ${timeFormat??""} ${name} ${shippingMethodPrice}`)):quantity===0&&text.push("Out of stock");const parentProps={min,max,shipping_method:shippingMethod,quantity,text:text.join(" "),...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("p",{...p,children:text.join(" ")})}export default AvailabilityTemplate;
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { FunctionChildren } from '../../typings/index';
3
- declare type ChildrenProps = FunctionChildren<Omit<Props, 'children'> & {
2
+ import { ChildrenFunction } from '../../typings/index';
3
+ interface ChildrenProps extends Omit<Props, 'children'> {
4
4
  handleChange: (event: React.MouseEvent<HTMLInputElement>) => void;
5
5
  handleBlur: (event: React.MouseEvent<HTMLInputElement>) => void;
6
- }>;
6
+ }
7
7
  declare type Props = {
8
- children?: ChildrenProps;
8
+ children?: ChildrenFunction<ChildrenProps>;
9
9
  disabled?: boolean;
10
10
  min?: number;
11
11
  max?: number;
@@ -14,18 +14,4 @@ declare type Props = {
14
14
  skuListId?: string;
15
15
  } & JSX.IntrinsicElements['input'];
16
16
  export declare function QuantitySelector(props: Props): JSX.Element;
17
- export declare namespace QuantitySelector {
18
- var propTypes: {
19
- children: import("prop-types").Requireable<(...args: any[]) => any>;
20
- min: import("prop-types").Requireable<number>;
21
- max: import("prop-types").Requireable<number>;
22
- value: import("prop-types").Requireable<string>;
23
- skuCode: import("prop-types").Requireable<string>;
24
- disabled: import("prop-types").Requireable<boolean>;
25
- };
26
- var defaultProps: {
27
- min: number;
28
- };
29
- var displayName: string;
30
- }
31
17
  export default QuantitySelector;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"../utils/Parent";import has from"lodash/has";import isEmpty from"lodash/isEmpty";import getCurrentItemKey from"../../utils/getCurrentItemKey";import ItemContext from"../../context/ItemContext";import components from"../../config/components";import SkuListsContext from"../../context/SkuListsContext";import SkuChildrenContext from"../../context/SkuChildrenContext";const propTypes=components.QuantitySelector.propTypes,defaultProps=components.QuantitySelector.defaultProps,displayName=components.QuantitySelector.displayName;export function QuantitySelector(props){const{skuCode,skuListId,children,min=1,max,...p}=props,{item,setQuantity,items,quantity,prices,skuCode:itemSkuCode}=useContext(ItemContext),{sku}=useContext(SkuChildrenContext),{skuLists,listIds}=useContext(SkuListsContext),defaultVal=p?.value||min,[value,setValue]=useState(defaultVal),[disabled,setDisabled]=useState(!!p.disabled),sCode=!isEmpty(items)&&skuCode?items[skuCode]?.code:sku?.code||skuCode||getCurrentItemKey(item)||itemSkuCode,inventory=isEmpty(item)?50:item[sCode]?.inventory?.quantity,maxInv=max||inventory;useEffect(()=>{if(setValue(defaultVal),(!prices[sCode]||!sCode)&&setDisabled(!0),skuListId&&setDisabled(!1),sCode&&!quantity[sCode]){const qty=Number(defaultVal);setQuantity&&setQuantity({...quantity,[`${sCode}`]:qty}),!isEmpty(prices)&&has(prices,sCode)&&setDisabled(!1)}return()=>{setValue(defaultVal)}},[item,listIds,prices,quantity]);const handleChange=e=>{const qty=Number(e.target.value),valid=Number(qty)>=Number(min)&&Number(qty)<=Number(maxInv);setValue(qty),!isEmpty(skuLists)&&skuListId&&valid?setQuantity&&setQuantity({...quantity,[`${skuListId}`]:Number(qty)}):sCode&&valid&&setQuantity&&setQuantity({...quantity,[`${sCode}`]:Number(qty)})},handleBlur=e=>{const qty=e.target.value;if(!(Number(qty)>=Number(min)&&Number(qty)<=Number(maxInv))){const resetVal=Number(qty)<Number(min)?min:maxInv;resetVal&&setValue(resetVal),!isEmpty(skuLists)&&skuListId?setQuantity&&setQuantity({...quantity,[`${skuListId}`]:Number(resetVal)}):setQuantity&&setQuantity({...quantity,[`${sCode}`]:Number(resetVal)})}},parentProps={min,max:maxInv,disabled,handleChange,handleBlur,value,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("input",{type:"number",max:maxInv,min,value:value||"",disabled,onChange:handleChange,onBlur:handleBlur,...p})}QuantitySelector.propTypes=propTypes,QuantitySelector.defaultProps=defaultProps,QuantitySelector.displayName=displayName;export default QuantitySelector;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"../utils/Parent";import has from"lodash/has";import isEmpty from"lodash/isEmpty";import getCurrentItemKey from"../../utils/getCurrentItemKey";import ItemContext from"../../context/ItemContext";import SkuListsContext from"../../context/SkuListsContext";import SkuChildrenContext from"../../context/SkuChildrenContext";export function QuantitySelector(props){const{skuCode,skuListId,children,min=1,max,...p}=props,{item,setQuantity,items,quantity,prices,skuCode:itemSkuCode}=useContext(ItemContext),{sku}=useContext(SkuChildrenContext),{skuLists,listIds}=useContext(SkuListsContext),defaultVal=p?.value||min,[value,setValue]=useState(defaultVal),[disabled,setDisabled]=useState(!!p.disabled),sCode=!isEmpty(items)&&skuCode?items[skuCode]?.code:sku?.code||skuCode||getCurrentItemKey(item)||itemSkuCode,inventory=isEmpty(item)?50:item[sCode]?.inventory?.quantity,maxInv=max||inventory;useEffect(()=>{if(setValue(defaultVal),(!prices[sCode]||!sCode)&&setDisabled(!0),skuListId&&setDisabled(!1),sCode&&!quantity[sCode]){const qty=Number(defaultVal);setQuantity&&setQuantity({...quantity,[`${sCode}`]:qty}),!isEmpty(prices)&&has(prices,sCode)&&setDisabled(!1)}return()=>{setValue(defaultVal)}},[item,listIds,prices,quantity]);const handleChange=e=>{const qty=Number(e.target.value),valid=Number(qty)>=Number(min)&&Number(qty)<=Number(maxInv);setValue(qty),!isEmpty(skuLists)&&skuListId&&valid?setQuantity&&setQuantity({...quantity,[`${skuListId}`]:Number(qty)}):sCode&&valid&&setQuantity&&setQuantity({...quantity,[`${sCode}`]:Number(qty)})},handleBlur=e=>{const qty=e.target.value;if(!(Number(qty)>=Number(min)&&Number(qty)<=Number(maxInv))){const resetVal=Number(qty)<Number(min)?min:maxInv;resetVal&&setValue(resetVal),!isEmpty(skuLists)&&skuListId?setQuantity&&setQuantity({...quantity,[`${skuListId}`]:Number(resetVal)}):setQuantity&&setQuantity({...quantity,[`${sCode}`]:Number(resetVal)})}},parentProps={min,max:maxInv,disabled,handleChange,handleBlur,value,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("input",{type:"number",max:maxInv,min,value:value||"",disabled,onChange:handleChange,onBlur:handleBlur,...p})}export default QuantitySelector;
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { VariantHandleCallback } from '../utils/VariantTemplate';
3
3
  import { BaseSelectorType } from '../../typings/index';
4
- import { FunctionChildren } from '../../typings/index';
4
+ import { ChildrenFunction } from '../../typings/index';
5
5
  import { VariantsObject, SetSkuCode } from '../../reducers/VariantReducer';
6
6
  export interface VariantOption {
7
7
  label: string;
@@ -11,13 +11,13 @@ export interface VariantOption {
11
11
  imageUrl?: string | null;
12
12
  } | null;
13
13
  }
14
- declare type ChildrenProps = FunctionChildren<Omit<Props, 'children'> & {
14
+ interface ChildrenProps extends Omit<Props, 'children'> {
15
15
  variants: VariantsObject;
16
16
  handleSelect: SetSkuCode;
17
17
  loading: boolean;
18
- }>;
18
+ }
19
19
  declare type Props = {
20
- children?: ChildrenProps;
20
+ children?: ChildrenFunction<ChildrenProps>;
21
21
  options: VariantOption[];
22
22
  type?: BaseSelectorType;
23
23
  loader?: ReactNode;
@@ -26,27 +26,4 @@ declare type Props = {
26
26
  handleCallback?: VariantHandleCallback;
27
27
  } & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['select'];
28
28
  export declare function VariantSelector(props: Props): JSX.Element;
29
- export declare namespace VariantSelector {
30
- var propTypes: {
31
- options: import("prop-types").Validator<NonNullable<import("prop-types").InferProps<{
32
- label: import("prop-types").Validator<string>;
33
- code: import("prop-types").Validator<string>;
34
- lineItem: import("prop-types").Requireable<import("prop-types").InferProps<{
35
- name: import("prop-types").Validator<string>;
36
- imageUrl: import("prop-types").Requireable<string>;
37
- }>>;
38
- }>>[]>;
39
- name: import("prop-types").Requireable<string>;
40
- children: import("prop-types").Requireable<(...args: any[]) => any>;
41
- type: import("prop-types").Requireable<BaseSelectorType>;
42
- loader: import("prop-types").Requireable<import("prop-types").ReactElementLike>;
43
- placeholder: import("prop-types").Requireable<string>;
44
- skuCode: import("prop-types").Requireable<string>;
45
- };
46
- var defaultProps: {
47
- placeholder: string;
48
- type: BaseSelectorType;
49
- };
50
- var displayName: string;
51
- }
52
29
  export default VariantSelector;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useEffect}from"react";import VariantTemplate from"../utils/VariantTemplate";import Parent from"../utils/Parent";import VariantsContext from"../../context/VariantsContext";import components from"../../config/components";const propTypes=components.VariantSelector.propTypes,defaultProps=components.VariantSelector.defaultProps,displayName=components.VariantSelector.displayName;export function VariantSelector(props){const{children,type,placeholder,skuCode,name,options,...prs}=props,{setSkuCode,skuCode:variantSkuCode,loading,variants,setSkuCodes}=useContext(VariantsContext);useEffect(()=>(setSkuCodes&&setSkuCodes(options),()=>{setSkuCodes&&setSkuCodes([])}),[options]);const sCode=variantSkuCode||skuCode||"",DefaultTemplate=()=>loading?_jsx(Fragment,{children:props.loader||"Loading..."}):_jsx(VariantTemplate,{variants,type,placeholder,skuCode:sCode,options,handleChange:setSkuCode,name,...prs}),parentProps={variants,loading:!!loading,handleSelect:setSkuCode,skuCode:sCode,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx(Fragment,{children:_jsx(DefaultTemplate,{})})}VariantSelector.propTypes=propTypes,VariantSelector.defaultProps=defaultProps,VariantSelector.displayName=displayName;export default VariantSelector;
1
+ import{Fragment as _Fragment,jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect}from"react";import VariantTemplate from"../utils/VariantTemplate";import Parent from"../utils/Parent";import VariantsContext from"../../context/VariantsContext";export function VariantSelector(props){const{children,type="select",placeholder,skuCode,name,options,...prs}=props,{setSkuCode,skuCode:variantSkuCode,loading,variants,setSkuCodes}=useContext(VariantsContext);useEffect(()=>(setSkuCodes&&setSkuCodes(options),()=>{setSkuCodes&&setSkuCodes([])}),[options]);const sCode=variantSkuCode||skuCode||"",DefaultTemplate=()=>loading?_jsx(_Fragment,{children:props.loader||"Loading..."}):_jsx(VariantTemplate,{variants,type,placeholder,skuCode:sCode,options,handleChange:setSkuCode,name,...prs}),parentProps={variants,loading:!!loading,handleSelect:setSkuCode,skuCode:sCode,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx(DefaultTemplate,{})}export default VariantSelector;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Address } from '@commercelayer/sdk';
3
3
  import AddressChildrenContext from '../../context/AddressChildrenContext';
4
- import { FunctionChildren } from '../../typings/index';
4
+ import { ChildrenFunction } from '../../typings/index';
5
5
  declare type ChildrenProps = Pick<Props, 'customerAddresses' | 'className'> & {
6
6
  AddressProvider: typeof AddressChildrenContext.Provider;
7
7
  };
@@ -9,7 +9,7 @@ export declare type CustomerAddress = Address & {
9
9
  onClick: () => void;
10
10
  handleSelect?: () => void;
11
11
  };
12
- export declare type AddressCardsTemplateChildren = FunctionChildren<ChildrenProps>;
12
+ export declare type AddressCardsTemplateChildren = ChildrenFunction<ChildrenProps>;
13
13
  export declare type AddressCardsType = ChildrenProps;
14
14
  export declare type HandleSelect = (k: number, addressId: string, customerAddressId: string, disabled: boolean, address: Address) => Promise<void>;
15
15
  declare type Props = {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { BaseInputComponentProps } from '../../typings/index';
3
3
  export declare type BaseInputProps = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
4
- declare const _default: React.ForwardRefExoticComponent<Pick<BaseInputProps, "children" | "form" | "slot" | "style" | "title" | "pattern" | "resource" | "id" | "value" | "placeholder" | "className" | "required" | "name" | "onChange" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "min" | "max" | "type" | "list" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "enterKeyHint" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "maxLength" | "minLength" | "multiple" | "readOnly" | "size" | "src" | "step" | "width" | "cols" | "dirName" | "rows" | "wrap"> & React.RefAttributes<any>>;
4
+ declare const _default: React.ForwardRefExoticComponent<Pick<BaseInputProps, "children" | "form" | "slot" | "style" | "title" | "pattern" | "resource" | "id" | "value" | "placeholder" | "className" | "required" | "name" | "onChange" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "min" | "max" | "type" | "list" | "disabled" | "width" | "height" | "src" | "step" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "enterKeyHint" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "maxLength" | "minLength" | "multiple" | "readOnly" | "size" | "cols" | "dirName" | "rows" | "wrap"> & React.RefAttributes<any>>;
5
5
  export default _default;
@@ -0,0 +1,14 @@
1
+ import { Component, ErrorInfo } from 'react';
2
+ interface Props {
3
+ children: JSX.Element;
4
+ }
5
+ interface State {
6
+ hasError: boolean;
7
+ }
8
+ export declare class ErrorBoundary extends Component<Props, State> {
9
+ state: State;
10
+ static getDerivedStateFromError(): State;
11
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
12
+ render(): JSX.Element;
13
+ }
14
+ export default ErrorBoundary;
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";export class ErrorBoundary extends Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(error,errorInfo){if(process.env.NODE_ENV!=="test")console.error("Uncaught error:",error,errorInfo);else throw error}render(){return this.state.hasError?_jsx("h1",{children:"Sorry.. there was an error, check the console."}):this.props.children}}export default ErrorBoundary;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { PaymentResource, PaymentSourceType } from '../../reducers/PaymentMethodReducer';
3
3
  import PaymentSourceContext, { IconBrand } from '../../context/PaymentSourceContext';
4
- import { FunctionChildren } from '../../typings/index';
4
+ import { ChildrenFunction } from '../../typings/index';
5
5
  declare type ChildrenProps = Pick<Props, 'customerPayments'> & {
6
6
  PaymentSourceProvider: typeof PaymentSourceContext.Provider;
7
7
  };
@@ -12,7 +12,7 @@ declare type CustomerPayment = PaymentSourceType & {
12
12
  };
13
13
  handleClick?: () => void;
14
14
  };
15
- export declare type CustomerCardsTemplateChildren = FunctionChildren<ChildrenProps>;
15
+ export declare type CustomerCardsTemplateChildren = ChildrenFunction<ChildrenProps>;
16
16
  export declare type CustomerCardsType = ChildrenProps;
17
17
  declare type Props = {
18
18
  customerPayments: CustomerPayment[];
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { PriceProps } from '../prices/Price';
3
3
  export declare type PTemplateProps = {
4
4
  formattedAmount?: string;
5
5
  formattedCompare?: string;
6
6
  } & Omit<PriceProps, 'children'>;
7
- declare const PriceTemplate: React.FunctionComponent<PTemplateProps>;
7
+ export declare function PriceTemplate(props: PTemplateProps): JSX.Element;
8
8
  export default PriceTemplate;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import PropTypes from"prop-types";const propTypes={formattedAmount:PropTypes.string,formattedCompare:PropTypes.string},defaultProps={formattedAmount:"",formattedCompare:""},PriceTemplate=props=>{const{showCompare,formattedCompare,compareClassName,className,formattedAmount,...p}=props;return delete p.skuCode,_jsxs(_Fragment,{children:[_jsx("span",{className,...p,children:formattedAmount}),showCompare&&_jsx("span",{className:compareClassName||"",...p,children:formattedCompare})]})};PriceTemplate.propTypes=propTypes,PriceTemplate.defaultProps=defaultProps;export default PriceTemplate;
1
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export function PriceTemplate(props){const{showCompare,formattedCompare,compareClassName,className,formattedAmount,skuCode,...p}=props;return _jsxs(_Fragment,{children:[_jsx("span",{"data-testid":`price-${skuCode??""}`,className,...p,children:formattedAmount}),showCompare&&_jsx("span",{"data-testid":`compare-${skuCode??""}`,className:compareClassName||"",...p,children:formattedCompare})]})}export default PriceTemplate;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { Address } from '@commercelayer/sdk';
3
3
  export declare type AddressValuesKeys = `${keyof Address}` | `billing_address_${keyof Address}` | `shipping_address_${keyof Address}`;
4
- export declare type DefaultContextAddress = {
4
+ export interface DefaultContextAddress {
5
5
  validation?: void;
6
6
  setValue?: (name: AddressValuesKeys, value: string | number | readonly string[]) => void;
7
7
  errors?: {
@@ -20,6 +20,6 @@ export declare type DefaultContextAddress = {
20
20
  };
21
21
  };
22
22
  isBusiness?: boolean;
23
- };
23
+ }
24
24
  declare const BillingAddressFormContext: import("react").Context<DefaultContextAddress>;
25
25
  export default BillingAddressFormContext;
@@ -6,6 +6,10 @@ export declare type InitialOrderListContext = Partial<{
6
6
  * The current order
7
7
  */
8
8
  order: Order | null;
9
+ /**
10
+ * The list of orders
11
+ */
12
+ orders: Order[] | null;
9
13
  /**
10
14
  * The current row
11
15
  */
@@ -34,6 +38,10 @@ declare const OrderListChildrenContext: import("react").Context<Partial<{
34
38
  * The current order
35
39
  */
36
40
  order: Order | null;
41
+ /**
42
+ * The list of orders
43
+ */
44
+ orders: Order[] | null;
37
45
  /**
38
46
  * The current row
39
47
  */
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { Parcel } from '@commercelayer/sdk';
3
+ export interface InitialParcelContext {
4
+ parcel?: Parcel;
5
+ }
6
+ declare const _default: import("react").Context<InitialParcelContext>;
7
+ export default _default;
@@ -0,0 +1 @@
1
+ import{createContext}from"react";const initial={};export default createContext(initial);
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { DeliveryLeadTime, LineItem, Shipment, ShippingMethod, StockTransfer } from '@commercelayer/sdk';
2
+ import type { DeliveryLeadTime, LineItem, Parcel, Shipment, ShippingMethod, StockTransfer } from '@commercelayer/sdk';
3
3
  export interface InitialShipmentContext {
4
- lineItems?: LineItem[];
5
- shippingMethods?: ShippingMethod[];
6
4
  currentShippingMethodId?: string;
7
- stockTransfers?: StockTransfer[];
8
5
  deliveryLeadTimes?: DeliveryLeadTime[];
9
- shipment?: Shipment;
10
6
  keyNumber: number;
7
+ lineItems?: LineItem[];
8
+ parcels?: Parcel[];
9
+ shipment?: Shipment;
10
+ shippingMethods?: ShippingMethod[];
11
+ stockTransfers?: StockTransfer[];
11
12
  }
12
13
  declare const ShipmentChildrenContext: import("react").Context<InitialShipmentContext>;
13
14
  export default ShipmentChildrenContext;
@@ -1 +1 @@
1
- import{createContext}from"react";const initial={lineItems:[],shippingMethods:[],stockTransfers:[],keyNumber:0},ShipmentChildrenContext=createContext(initial);export default ShipmentChildrenContext;
1
+ import{createContext}from"react";const initial={keyNumber:0,lineItems:[],shippingMethods:[],stockTransfers:[]},ShipmentChildrenContext=createContext(initial);export default ShipmentChildrenContext;