@commercelayer/react-components 4.0.1 → 4.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/lib/cjs/components/Errors.js +1 -1
  2. package/lib/cjs/components/ExternalFunction.d.ts +2 -9
  3. package/lib/cjs/components/ExternalFunction.js +1 -1
  4. package/lib/cjs/components/MetadataInput.d.ts +0 -10
  5. package/lib/cjs/components/MetadataInput.js +1 -1
  6. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +0 -16
  7. package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -1
  8. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +0 -16
  9. package/lib/cjs/components/addresses/AddressStateSelector.js +1 -1
  10. package/lib/cjs/components/addresses/BillingAddressForm.d.ts +0 -5
  11. package/lib/cjs/components/addresses/BillingAddressForm.js +1 -1
  12. package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +4 -9
  13. package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -1
  14. package/lib/cjs/components/addresses/ShippingAddressForm.d.ts +2 -7
  15. package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -1
  16. package/lib/cjs/components/customers/CustomerAddressForm.d.ts +2 -7
  17. package/lib/cjs/components/customers/CustomerAddressForm.js +1 -1
  18. package/lib/cjs/components/customers/CustomerInput.d.ts +1 -13
  19. package/lib/cjs/components/customers/CustomerInput.js +1 -1
  20. package/lib/cjs/components/gift_cards/GiftCard.d.ts +2 -12
  21. package/lib/cjs/components/gift_cards/GiftCard.js +1 -1
  22. package/lib/cjs/components/gift_cards/GiftCardContainer.d.ts +2 -8
  23. package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -1
  24. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -15
  25. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -1
  26. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -10
  27. package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -1
  28. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -5
  29. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -1
  30. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -10
  31. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -1
  32. package/lib/cjs/components/line_items/LineItemQuantity.d.ts +1 -1
  33. package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -1
  34. package/lib/cjs/components/orders/OrderContainer.d.ts +12 -0
  35. package/lib/cjs/components/orders/OrderNumber.d.ts +0 -6
  36. package/lib/cjs/components/orders/OrderNumber.js +1 -1
  37. package/lib/cjs/components/orders/OrderStorage.d.ts +2 -10
  38. package/lib/cjs/components/orders/OrderStorage.js +1 -1
  39. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +0 -12
  40. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.js +1 -1
  41. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -6
  42. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
  43. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +0 -7
  44. package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -1
  45. package/lib/cjs/components/skus/SkuList.d.ts +5 -9
  46. package/lib/cjs/components/skus/SkuList.js +1 -1
  47. package/lib/cjs/components/skus/SkuListsContainer.d.ts +2 -8
  48. package/lib/cjs/components/skus/SkuListsContainer.js +1 -1
  49. package/lib/cjs/components/skus/Skus.d.ts +2 -7
  50. package/lib/cjs/components/skus/Skus.js +1 -1
  51. package/lib/cjs/components/utils/BaseInput.d.ts +2 -2
  52. package/lib/cjs/components/utils/Parent.d.ts +1 -1
  53. package/lib/cjs/hooks/useOrderContainer.d.ts +6 -0
  54. package/lib/cjs/hooks/useOrderContainer.js +1 -0
  55. package/lib/cjs/reducers/AddressReducer.d.ts +1 -1
  56. package/lib/cjs/reducers/GiftCardReducer.d.ts +11 -21
  57. package/lib/cjs/reducers/GiftCardReducer.js +1 -1
  58. package/lib/cjs/typings/errors.d.ts +2 -2
  59. package/lib/cjs/typings/index.d.ts +2 -2
  60. package/lib/esm/components/Errors.js +1 -1
  61. package/lib/esm/components/ExternalFunction.d.ts +2 -9
  62. package/lib/esm/components/ExternalFunction.js +1 -1
  63. package/lib/esm/components/MetadataInput.d.ts +0 -10
  64. package/lib/esm/components/MetadataInput.js +1 -1
  65. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +0 -16
  66. package/lib/esm/components/addresses/AddressCountrySelector.js +1 -1
  67. package/lib/esm/components/addresses/AddressStateSelector.d.ts +0 -16
  68. package/lib/esm/components/addresses/AddressStateSelector.js +1 -1
  69. package/lib/esm/components/addresses/BillingAddressForm.d.ts +0 -5
  70. package/lib/esm/components/addresses/BillingAddressForm.js +1 -1
  71. package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +4 -9
  72. package/lib/esm/components/addresses/ShippingAddressContainer.js +1 -1
  73. package/lib/esm/components/addresses/ShippingAddressForm.d.ts +2 -7
  74. package/lib/esm/components/addresses/ShippingAddressForm.js +1 -1
  75. package/lib/esm/components/customers/CustomerAddressForm.d.ts +2 -7
  76. package/lib/esm/components/customers/CustomerAddressForm.js +1 -1
  77. package/lib/esm/components/customers/CustomerInput.d.ts +1 -13
  78. package/lib/esm/components/customers/CustomerInput.js +1 -1
  79. package/lib/esm/components/gift_cards/GiftCard.d.ts +2 -12
  80. package/lib/esm/components/gift_cards/GiftCard.js +1 -1
  81. package/lib/esm/components/gift_cards/GiftCardContainer.d.ts +2 -8
  82. package/lib/esm/components/gift_cards/GiftCardContainer.js +1 -1
  83. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +0 -15
  84. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.js +1 -1
  85. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -10
  86. package/lib/esm/components/gift_cards/GiftCardInput.js +1 -1
  87. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +0 -5
  88. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.js +1 -1
  89. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -10
  90. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.js +1 -1
  91. package/lib/esm/components/line_items/LineItemQuantity.d.ts +1 -1
  92. package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -1
  93. package/lib/esm/components/orders/OrderContainer.d.ts +12 -0
  94. package/lib/esm/components/orders/OrderNumber.d.ts +0 -6
  95. package/lib/esm/components/orders/OrderNumber.js +1 -1
  96. package/lib/esm/components/orders/OrderStorage.d.ts +2 -10
  97. package/lib/esm/components/orders/OrderStorage.js +1 -1
  98. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +0 -12
  99. package/lib/esm/components/shipping_methods/ShippingMethodPrice.js +1 -1
  100. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +0 -6
  101. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
  102. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +0 -7
  103. package/lib/esm/components/skus/DeliveryLeadTime.js +1 -1
  104. package/lib/esm/components/skus/SkuList.d.ts +5 -9
  105. package/lib/esm/components/skus/SkuList.js +1 -1
  106. package/lib/esm/components/skus/SkuListsContainer.d.ts +2 -8
  107. package/lib/esm/components/skus/SkuListsContainer.js +1 -1
  108. package/lib/esm/components/skus/Skus.d.ts +2 -7
  109. package/lib/esm/components/skus/Skus.js +1 -1
  110. package/lib/esm/components/utils/BaseInput.d.ts +2 -2
  111. package/lib/esm/components/utils/Parent.d.ts +1 -1
  112. package/lib/esm/hooks/useOrderContainer.d.ts +6 -0
  113. package/lib/esm/hooks/useOrderContainer.js +1 -0
  114. package/lib/esm/reducers/AddressReducer.d.ts +1 -1
  115. package/lib/esm/reducers/GiftCardReducer.d.ts +11 -21
  116. package/lib/esm/reducers/GiftCardReducer.js +1 -1
  117. package/lib/esm/typings/errors.d.ts +2 -2
  118. package/lib/esm/typings/index.d.ts +2 -2
  119. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  120. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  121. package/package.json +23 -66
  122. package/README.md +0 -302
  123. package/lib/cjs/config/components.d.ts +0 -860
  124. package/lib/cjs/config/components.js +0 -1
  125. package/lib/cjs/utils/childrenTypes.d.ts +0 -9
  126. package/lib/cjs/utils/childrenTypes.js +0 -1
  127. package/lib/esm/config/components.d.ts +0 -860
  128. package/lib/esm/config/components.js +0 -1
  129. package/lib/esm/utils/childrenTypes.d.ts +0 -9
  130. package/lib/esm/utils/childrenTypes.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethodPrice=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),getAmount_1=tslib_1.__importDefault(require("../../utils/getAmount")),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),components_1=tslib_1.__importDefault(require("../../config/components")),propTypes=components_1.default.ShippingMethodPrice.propTypes,displayName=components_1.default.ShippingMethodPrice.displayName;function ShippingMethodPrice(props){const{base="price_amount",type="for_shipment",format="formatted",labelFreeOver="Free",...p}=props,{shippingMethod}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default),[price,setPrice]=(0,react_1.useState)(""),[priceCents,setPriceCents]=(0,react_1.useState)(0);(0,react_1.useEffect)(()=>{if(shippingMethod){const p2=(0,getAmount_1.default)({base,type,format,obj:shippingMethod});setPrice(p2);const pCents=(0,getAmount_1.default)({base:"price_amount",type:"for_shipment",format:"cents",obj:shippingMethod});setPriceCents(pCents)}return()=>{setPrice(""),setPriceCents(0)}},[shippingMethod]);const parentProps={price,...p},finalPrice=priceCents===0?labelFreeOver:price;return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("span",{...p,children:finalPrice})}exports.ShippingMethodPrice=ShippingMethodPrice,ShippingMethodPrice.propTypes=propTypes,ShippingMethodPrice.displayName=displayName,exports.default=ShippingMethodPrice;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethodPrice=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),getAmount_1=tslib_1.__importDefault(require("../../utils/getAmount")),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function ShippingMethodPrice(props){const{base="price_amount",type="for_shipment",format="formatted",labelFreeOver="Free",...p}=props,{shippingMethod}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default),[price,setPrice]=(0,react_1.useState)(""),[priceCents,setPriceCents]=(0,react_1.useState)(0);(0,react_1.useEffect)(()=>{if(shippingMethod){const p2=(0,getAmount_1.default)({base,type,format,obj:shippingMethod});setPrice(p2);const pCents=(0,getAmount_1.default)({base:"price_amount",type:"for_shipment",format:"cents",obj:shippingMethod});setPriceCents(pCents)}return()=>{setPrice(""),setPriceCents(0)}},[shippingMethod]);const parentProps={price,...p},finalPrice=priceCents===0?labelFreeOver:price;return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("span",{...p,children:finalPrice})}exports.ShippingMethodPrice=ShippingMethodPrice,exports.default=ShippingMethodPrice;
@@ -10,10 +10,4 @@ declare type Props = {
10
10
  onChange?: ShippingMethodRadioButtonOnChangeType;
11
11
  } & Omit<JSX.IntrinsicElements['input'], 'onChange'>;
12
12
  export declare function ShippingMethodRadioButton(props: Props): JSX.Element;
13
- export declare namespace ShippingMethodRadioButton {
14
- var propTypes: {
15
- children: import("prop-types").Requireable<(...args: any[]) => any>;
16
- };
17
- var displayName: string;
18
- }
19
13
  export default ShippingMethodRadioButton;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethodRadioButton=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),components_1=tslib_1.__importDefault(require("../../config/components")),ShipmentContext_1=tslib_1.__importDefault(require("../../context/ShipmentContext")),propTypes=components_1.default.ShippingMethodRadioButton.propTypes,displayName=components_1.default.ShippingMethodRadioButton.displayName;function ShippingMethodRadioButton(props){const{onChange,...p}=props,[checked,setChecked]=(0,react_1.useState)(!1),{shippingMethod,currentShippingMethodId,shipmentId}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default),{setShippingMethod}=(0,react_1.useContext)(ShipmentContext_1.default),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId}`,id=`${name}-${shippingMethodId}`;(0,react_1.useEffect)(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId]);const handleOnChange=async()=>{shipmentId&&shippingMethodId&&(setChecked(!0),await setShippingMethod(shipmentId,shippingMethodId),shippingMethod&&onChange&&onChange(shippingMethod,shipmentId))},parentProps={shippingMethod,shipmentId,handleOnChange,name,id,...props};return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("input",{type:"radio",name,id,onChange:handleOnChange,checked,...p})}exports.ShippingMethodRadioButton=ShippingMethodRadioButton,ShippingMethodRadioButton.propTypes=propTypes,ShippingMethodRadioButton.displayName=displayName,exports.default=ShippingMethodRadioButton;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShippingMethodRadioButton=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),ShipmentContext_1=tslib_1.__importDefault(require("../../context/ShipmentContext"));function ShippingMethodRadioButton(props){const{onChange,...p}=props,[checked,setChecked]=(0,react_1.useState)(!1),{shippingMethod,currentShippingMethodId,shipmentId}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default),{setShippingMethod}=(0,react_1.useContext)(ShipmentContext_1.default),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId??""}`,id=`${name}-${shippingMethodId??""}`;(0,react_1.useEffect)(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId]);const handleOnChange=async()=>{shipmentId&&shippingMethodId&&(setChecked(!0),await setShippingMethod(shipmentId,shippingMethodId),shippingMethod&&onChange&&onChange(shippingMethod,shipmentId))},parentProps={shippingMethod,shipmentId,handleOnChange,name,id,...props};return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("input",{type:"radio",name,id,onChange:()=>{handleOnChange()},checked,...p})}exports.ShippingMethodRadioButton=ShippingMethodRadioButton,exports.default=ShippingMethodRadioButton;
@@ -7,11 +7,4 @@ declare type Props = Partial<JSX.IntrinsicElements['span']> & {
7
7
  text?: string;
8
8
  };
9
9
  export declare function DeliveryLeadTime(props: Props): JSX.Element;
10
- export declare namespace DeliveryLeadTime {
11
- var propTypes: {
12
- type: import("prop-types").Validator<NonNullable<DeliveryLeadTimeField>>;
13
- children: import("prop-types").Requireable<(...args: any[]) => any>;
14
- };
15
- var displayName: string;
16
- }
17
10
  export default DeliveryLeadTime;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeliveryLeadTime=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),components_1=tslib_1.__importDefault(require("../../config/components")),propTypes=components_1.default.DeliveryLeadTime.propTypes,displayName=components_1.default.DeliveryLeadTime.displayName;function DeliveryLeadTime(props){const{type,...p}=props,[text,setText]=(0,react_1.useState)(),{deliveryLeadTimeForShipment}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default);(0,react_1.useEffect)(()=>(deliveryLeadTimeForShipment&&deliveryLeadTimeForShipment[type]&&setText(deliveryLeadTimeForShipment[type]),()=>{setText("")}),[deliveryLeadTimeForShipment]);const parentProps={text,...p};return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("span",{...p,children:text})}exports.DeliveryLeadTime=DeliveryLeadTime,DeliveryLeadTime.propTypes=propTypes,DeliveryLeadTime.displayName=displayName,exports.default=DeliveryLeadTime;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeliveryLeadTime=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShippingMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/ShippingMethodChildrenContext")),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function DeliveryLeadTime(props){const{type,...p}=props,[text,setText]=(0,react_1.useState)(),{deliveryLeadTimeForShipment}=(0,react_1.useContext)(ShippingMethodChildrenContext_1.default);(0,react_1.useEffect)(()=>(deliveryLeadTimeForShipment?.[type]&&setText(deliveryLeadTimeForShipment[type]),()=>{setText("")}),[deliveryLeadTimeForShipment]);const parentProps={text,...p};return props.children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children:props.children}):(0,jsx_runtime_1.jsx)("span",{...p,children:text})}exports.DeliveryLeadTime=DeliveryLeadTime,exports.default=DeliveryLeadTime;
@@ -1,14 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props {
3
3
  children: ReactNode;
4
+ /**
5
+ * ID of the SKU list.
6
+ */
4
7
  id: string;
5
- };
6
- export declare function SkuList(props: Props): JSX.Element;
7
- export declare namespace SkuList {
8
- var propTypes: {
9
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
10
- id: import("prop-types").Validator<string>;
11
- };
12
- var displayName: string;
13
8
  }
9
+ export declare function SkuList(props: Props): JSX.Element;
14
10
  export default SkuList;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SkuList=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),SkuListsContext_1=tslib_1.__importDefault(require("../../context/SkuListsContext")),components_1=tslib_1.__importDefault(require("../../config/components")),propTypes=components_1.default.SkuList.propTypes,displayName=components_1.default.SkuList.displayName;function SkuList(props){const{id,children}=props,{listIds}=(0,react_1.useContext)(SkuListsContext_1.default);return(0,react_1.useEffect)(()=>{listIds&&!listIds.includes(id)&&listIds.push(id)},[]),(0,jsx_runtime_1.jsx)(react_1.Fragment,{children})}exports.SkuList=SkuList,SkuList.propTypes=propTypes,SkuList.displayName=displayName,exports.default=SkuList;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SkuList=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),SkuListsContext_1=tslib_1.__importDefault(require("../../context/SkuListsContext"));function SkuList(props){const{id,children}=props,{listIds}=(0,react_1.useContext)(SkuListsContext_1.default);return(0,react_1.useEffect)(()=>{listIds&&!listIds.includes(id)&&listIds.push(id)},[]),(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children})}exports.SkuList=SkuList,exports.default=SkuList;
@@ -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 SkuListsContainer(props: Props): JSX.Element;
6
- export declare namespace SkuListsContainer {
7
- var propTypes: {
8
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
9
- };
10
- var displayName: string;
11
4
  }
5
+ export declare function SkuListsContainer(props: Props): JSX.Element;
12
6
  export default SkuListsContainer;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SkuListsContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),SkuListsContext_1=tslib_1.__importDefault(require("../../context/SkuListsContext")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),SkuListsReducer_1=tslib_1.__importStar(require("../../reducers/SkuListsReducer")),components_1=tslib_1.__importDefault(require("../../config/components")),propTypes=components_1.default.SkuListsContainer.propTypes,displayName=components_1.default.SkuListsContainer.displayName;function SkuListsContainer(props){const{children}=props,[state,dispatch]=(0,react_1.useReducer)(SkuListsReducer_1.default,SkuListsReducer_1.skuListsInitialState),config=(0,react_1.useContext)(CommerceLayerContext_1.default);return(0,react_1.useEffect)(()=>{state.listIds&&state.listIds.length>0&&config.accessToken&&(0,SkuListsReducer_1.getSkuList)({listIds:state.listIds,dispatch,config,state})},[config.accessToken]),(0,jsx_runtime_1.jsx)(SkuListsContext_1.default.Provider,{value:state,children})}exports.SkuListsContainer=SkuListsContainer,SkuListsContainer.propTypes=propTypes,SkuListsContainer.displayName=displayName,exports.default=SkuListsContainer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SkuListsContainer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),SkuListsContext_1=tslib_1.__importDefault(require("../../context/SkuListsContext")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),SkuListsReducer_1=tslib_1.__importStar(require("../../reducers/SkuListsReducer"));function SkuListsContainer(props){const{children}=props,[state,dispatch]=(0,react_1.useReducer)(SkuListsReducer_1.default,SkuListsReducer_1.skuListsInitialState),config=(0,react_1.useContext)(CommerceLayerContext_1.default);return(0,react_1.useEffect)(()=>{state.listIds&&state.listIds.length>0&&config.accessToken&&(0,SkuListsReducer_1.getSkuList)({listIds:state.listIds,dispatch,config,state})},[config.accessToken]),(0,jsx_runtime_1.jsx)(SkuListsContext_1.default.Provider,{value:state,children})}exports.SkuListsContainer=SkuListsContainer,exports.default=SkuListsContainer;
@@ -1,11 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props {
3
3
  children: ReactNode;
4
- };
5
- export declare function Skus<P extends Props>({ children }: P): JSX.Element;
6
- export declare namespace Skus {
7
- var propTypes: {
8
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
9
- };
10
4
  }
5
+ export declare function Skus<P extends Props>({ children }: P): JSX.Element;
11
6
  export default Skus;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Skus=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),components_1=tslib_1.__importDefault(require("../../config/components")),SkuChildrenContext_1=tslib_1.__importDefault(require("../../context/SkuChildrenContext")),SkuContext_1=tslib_1.__importDefault(require("../../context/SkuContext")),react_1=require("react");function Skus({children}){const{skus}=(0,react_1.useContext)(SkuContext_1.default),components=skus&&skus.map((sku,key)=>{const value={sku};return(0,jsx_runtime_1.jsx)(SkuChildrenContext_1.default.Provider,{value,children},key)});return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:components})}exports.Skus=Skus,Skus.propTypes=components_1.default.Skus.propTypes,exports.default=Skus;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Skus=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),SkuChildrenContext_1=tslib_1.__importDefault(require("../../context/SkuChildrenContext")),SkuContext_1=tslib_1.__importDefault(require("../../context/SkuContext")),react_1=require("react");function Skus({children}){const{skus}=(0,react_1.useContext)(SkuContext_1.default),components=skus?.map((sku,key)=>{const value={sku};return(0,jsx_runtime_1.jsx)(SkuChildrenContext_1.default.Provider,{value,children},key)});return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:components})}exports.Skus=Skus,exports.default=Skus;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { BaseInputComponentProps } from '../../typings/index';
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" | "alt" | "crossOrigin" | "height" | "src" | "width" | "max" | "min" | "type" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "autoComplete" | "accept" | "capture" | "checked" | "enterKeyHint" | "list" | "maxLength" | "minLength" | "multiple" | "readOnly" | "size" | "step" | "cols" | "dirName" | "rows" | "wrap"> & React.RefAttributes<any>>;
3
+ export declare type BaseInputProps = BaseInputComponentProps & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
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" | "nonce" | "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" | "height" | "max" | "min" | "type" | "width" | "crossOrigin" | "alt" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "autoComplete" | "accept" | "capture" | "checked" | "enterKeyHint" | "list" | "maxLength" | "minLength" | "multiple" | "readOnly" | "size" | "step" | "cols" | "dirName" | "rows" | "wrap"> & React.RefAttributes<any>>;
5
5
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import { Component, ForwardedRef } from 'react';
2
2
  export interface ParentProps {
3
3
  parentRef?: ForwardedRef<any>;
4
- children?: typeof Component | ((P: any) => JSX.Element);
4
+ children?: typeof Component | ((P: any) => JSX.Element | null);
5
5
  }
6
6
  export default function Parent({ children, ...p }: ParentProps): JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ import { type Order } from '@commercelayer/sdk';
2
+ export declare function useOrderContainer(): {
3
+ order?: Order;
4
+ reloadOrder: () => Promise<Order | undefined>;
5
+ };
6
+ export default useOrderContainer;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useOrderContainer=void 0;const tslib_1=require("tslib"),OrderContext_1=tslib_1.__importDefault(require("../context/OrderContext")),react_1=require("react");function useOrderContainer(){const ctx=(0,react_1.useContext)(OrderContext_1.default);if("order"in ctx)return{order:ctx.order,reloadOrder:async()=>{if(ctx?.order?.id)return await ctx?.getOrder(ctx?.order?.id)}};throw new Error("Cannot use `useOrderContainer` outside of <OrderContainer/>")}exports.useOrderContainer=useOrderContainer,exports.default=useOrderContainer;
@@ -9,7 +9,7 @@ export declare type AddressField = 'city' | 'company' | 'country_code' | 'first_
9
9
  export declare type AddressFieldView = AddressField | 'full_address' | 'full_name';
10
10
  export declare const addressFields: AddressField[];
11
11
  export declare type AddressResource = Extract<ResourceErrorType, 'billing_address' | 'shipping_address'>;
12
- export declare type AddressSchema = Address;
12
+ export declare type AddressSchema = Omit<Address, 'created_at' | 'updated_at' | 'id' | 'type'>;
13
13
  export interface AddressActionPayload {
14
14
  errors: BaseError[];
15
15
  billing_address: TCustomerAddress;
@@ -3,7 +3,7 @@ import { BaseMetadata } from '../typings/index';
3
3
  import { Dispatch } from 'react';
4
4
  import { CommerceLayerConfig } from '../context/CommerceLayerContext';
5
5
  import { BaseError } from '../typings/errors';
6
- import { CreateOrder } from './OrderReducer';
6
+ import { CreateOrder, getOrderContext } from './OrderReducer';
7
7
  export declare type GiftCardActionType = 'setAvailability' | 'setGiftCardRecipient' | 'setGiftCardErrors' | 'setGiftCardLoading';
8
8
  export interface GiftCardRecipientI {
9
9
  email: string;
@@ -50,27 +50,17 @@ export interface GiftCardAction {
50
50
  payload: GiftCardActionPayload;
51
51
  }
52
52
  export declare const giftCardInitialState: GiftCardState;
53
- export interface AddGiftCardRecipient {
54
- <V extends GiftCardRecipientCreate>(values: V, config: CommerceLayerConfig, dispatch: Dispatch<GiftCardAction>): void;
55
- }
56
- export interface AddGiftCard {
57
- <V extends GiftCardI>(values: V, configParameters: {
58
- getOrder?: (id: string) => void;
59
- createOrder?: CreateOrder;
60
- config: CommerceLayerConfig;
61
- dispatch: Dispatch<GiftCardAction>;
62
- order?: Order;
63
- }): void;
64
- }
65
- export interface AddGiftCardError {
66
- <V extends BaseError[]>(errors: V, dispatch: Dispatch<GiftCardAction>): void;
67
- }
68
- export interface AddGiftCardLoading {
69
- <V extends boolean>(loading: V, dispatch: Dispatch<GiftCardAction>): void;
70
- }
71
- export declare const addGiftCardRecipient: AddGiftCardRecipient;
53
+ export declare type AddGiftCardError = <V extends BaseError[]>(errors: V, dispatch: Dispatch<GiftCardAction>) => void;
54
+ export declare type AddGiftCardLoading = <V extends boolean>(loading: V, dispatch: Dispatch<GiftCardAction>) => void;
55
+ export declare function addGiftCardRecipient<V extends GiftCardRecipientCreate>(values: V, config: CommerceLayerConfig, dispatch: Dispatch<GiftCardAction>): Promise<void>;
72
56
  export declare const addGiftCardLoading: AddGiftCardLoading;
73
- export declare const addGiftCard: AddGiftCard;
57
+ export declare function addGiftCard<V extends GiftCardI>(values: V, { config, dispatch, getOrder, createOrder, order }: {
58
+ getOrder?: getOrderContext;
59
+ createOrder?: CreateOrder;
60
+ config: CommerceLayerConfig;
61
+ dispatch: Dispatch<GiftCardAction>;
62
+ order?: Order;
63
+ }): Promise<void>;
74
64
  export declare const addGiftCardError: AddGiftCardError;
75
65
  declare const giftCardReducer: (state: GiftCardState, reducer: GiftCardAction) => GiftCardState;
76
66
  export default giftCardReducer;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addGiftCardError=exports.addGiftCard=exports.addGiftCardLoading=exports.addGiftCardRecipient=exports.giftCardInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),lodash_1=require("lodash"),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]};const addGiftCardRecipient=async(values,config,dispatch)=>{try{const recipient=await(0,getSdk_1.default)(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}};exports.addGiftCardRecipient=addGiftCardRecipient;const addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})};exports.addGiftCardLoading=addGiftCardLoading;const addGiftCard=async(values,{config,dispatch,getOrder,createOrder,order})=>{try{const sdk=(0,getSdk_1.default)(config);(0,exports.addGiftCardLoading)(!0,dispatch);const{firstName,lastName,email,...val}=values,giftCardValue={recipient_email:email,...val},giftCard=await sdk.gift_cards.create(giftCardValue,{include:["gift_card_recipient"]}),recipientValues={id:giftCard.gift_card_recipient?.id};if(firstName&&(recipientValues.first_name=firstName),lastName&&(recipientValues.last_name=lastName),(0,lodash_1.isEmpty)(recipientValues)||await sdk.gift_card_recipients.update(recipientValues),createOrder&&getOrder){const id=order?order.id:await createOrder();if(id){const order2=sdk.orders.relationship(id),item=sdk.gift_cards.relationship(giftCard.id);await sdk.line_items.create({quantity:1,order:order2,item}),getOrder&&await getOrder(id)}}dispatch({type:"setGiftCardRecipient",payload:{...giftCardValue}}),(0,exports.addGiftCardLoading)(!1,dispatch)}catch(error){const errors=(0,getErrors_1.default)(error,"gift_cards");dispatch({type:"setGiftCardErrors",payload:{errors}}),(0,exports.addGiftCardLoading)(!1,dispatch)}};exports.addGiftCard=addGiftCard;const addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};exports.addGiftCardError=addGiftCardError;const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=giftCardReducer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addGiftCardError=exports.addGiftCard=exports.addGiftCardLoading=exports.addGiftCardRecipient=exports.giftCardInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),lodash_1=require("lodash"),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]};async function addGiftCardRecipient(values,config,dispatch){try{const recipient=await(0,getSdk_1.default)(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}}exports.addGiftCardRecipient=addGiftCardRecipient;const addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})};exports.addGiftCardLoading=addGiftCardLoading;async function addGiftCard(values,{config,dispatch,getOrder,createOrder,order}){try{const sdk=(0,getSdk_1.default)(config);(0,exports.addGiftCardLoading)(!0,dispatch);const{firstName,lastName,email,...val}=values,giftCardValue={recipient_email:email,...val},giftCard=await sdk.gift_cards.create(giftCardValue,{include:["gift_card_recipient"]}),recipientValues={id:giftCard.gift_card_recipient?.id};if(firstName&&(recipientValues.first_name=firstName),lastName&&(recipientValues.last_name=lastName),(0,lodash_1.isEmpty)(recipientValues)||await sdk.gift_card_recipients.update(recipientValues),createOrder&&getOrder){const id=order?order.id:await createOrder();if(id){const order2=sdk.orders.relationship(id),item=sdk.gift_cards.relationship(giftCard.id);await sdk.line_items.create({quantity:1,order:order2,item}),await getOrder(id)}}dispatch({type:"setGiftCardRecipient",payload:{...giftCardValue}}),(0,exports.addGiftCardLoading)(!1,dispatch)}catch(error){const errors=(0,getErrors_1.default)(error,"gift_cards");dispatch({type:"setGiftCardErrors",payload:{errors}}),(0,exports.addGiftCardLoading)(!1,dispatch)}}exports.addGiftCard=addGiftCard;const addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};exports.addGiftCardError=addGiftCardError;const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=giftCardReducer;
@@ -29,12 +29,12 @@ declare type ErrorChildrenComponentProps = ChildrenFunction<Omit<ErrorComponentP
29
29
  }>;
30
30
  export interface ErrorComponentProps {
31
31
  /**
32
- * Resource which caused the error
32
+ * Resource which get the error
33
33
  */
34
34
  resource: ResourceErrorType;
35
35
  children?: ErrorChildrenComponentProps;
36
36
  /**
37
- * Field which caused the error
37
+ * Field which get the error
38
38
  */
39
39
  field?: string;
40
40
  /**
@@ -116,13 +116,13 @@ export interface BaseAmountComponent extends Omit<JSX.IntrinsicElements['span'],
116
116
  priceCents?: number;
117
117
  labelFree?: string;
118
118
  }
119
- export declare type ChildrenFunction<P = Record<string, any>> = (props: P) => JSX.Element;
119
+ export declare type ChildrenFunction<P = Record<string, any>> = (props: P) => JSX.Element | null;
120
120
  export declare type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JSX.IntrinsicElements, T>;
121
121
  export declare type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
122
122
  export declare type ConditionalElement<E> = ({
123
123
  attribute: Extract<keyof E, 'image_url'>;
124
124
  tagElement: ExtractTag<'img'>;
125
- } & Omit<JSX.IntrinsicElements['img'], 'children'>) | ({
125
+ } & JSX.IntrinsicElements['img']) | ({
126
126
  attribute: Exclude<keyof E, 'image_url'>;
127
127
  tagElement: ExcludeTag<'img'>;
128
128
  } & Omit<JSX.IntrinsicElements[ExcludeTag<'img'>], 'children'>);
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,Fragment,useMemo}from"react";import Parent from"./utils/Parent";import GiftCardContext from"../context/GiftCardContext";import OrderContext from"../context/OrderContext";import AddressContext from"../context/AddressContext";import getAllErrors from"./utils/getAllErrors";import LineItemContext from"../context/LineItemContext";import LineItemChildrenContext from"../context/LineItemChildrenContext";import CustomerContext from"../context/CustomerContext";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import ShipmentContext from"../context/ShipmentContext";export function Errors(props){const{children,messages=[],resource,field,...p}=props,{payment}=useContext(PaymentMethodChildrenContext),{errors:orderErrors}=useContext(OrderContext),{errors:giftCardErrors}=useContext(GiftCardContext),{errors:lineItemErrors}=useContext(LineItemContext),{errors:addressErrors}=useContext(AddressContext),{errors:customerErrors}=useContext(CustomerContext),{errors:shipmentErrors}=useContext(ShipmentContext),{errors:paymentMethodErrors,currentPaymentMethodType,currentPaymentMethodId}=useContext(PaymentMethodContext),{lineItem}=useContext(LineItemChildrenContext),allErrors=useMemo(()=>[...giftCardErrors||[],...orderErrors||[],...lineItemErrors||[],...addressErrors||[],...customerErrors||[],...shipmentErrors||[],...paymentMethodErrors?.filter(v=>v.field===currentPaymentMethodType&&payment?.id===currentPaymentMethodId)||[]],[giftCardErrors,orderErrors,lineItemErrors,addressErrors,customerErrors,shipmentErrors,paymentMethodErrors]).filter((v,k,a)=>v?.code!==a[k-1]?.code),msgErrors=getAllErrors({allErrors,field,messages,props:p,lineItem,resource,returnHtml:!children}),parentProps={messages,resource,field,errors:msgErrors,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx(Fragment,{children:msgErrors})}export default Errors;
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useMemo}from"react";import Parent from"./utils/Parent";import GiftCardContext from"../context/GiftCardContext";import OrderContext from"../context/OrderContext";import AddressContext from"../context/AddressContext";import getAllErrors from"./utils/getAllErrors";import LineItemContext from"../context/LineItemContext";import LineItemChildrenContext from"../context/LineItemChildrenContext";import CustomerContext from"../context/CustomerContext";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import ShipmentContext from"../context/ShipmentContext";export function Errors(props){const{children,messages=[],resource,field,...p}=props,{payment}=useContext(PaymentMethodChildrenContext),{errors:orderErrors}=useContext(OrderContext),{errors:giftCardErrors}=useContext(GiftCardContext),{errors:lineItemErrors}=useContext(LineItemContext),{errors:addressErrors}=useContext(AddressContext),{errors:customerErrors}=useContext(CustomerContext),{errors:shipmentErrors}=useContext(ShipmentContext),{errors:paymentMethodErrors,currentPaymentMethodType,currentPaymentMethodId}=useContext(PaymentMethodContext),{lineItem}=useContext(LineItemChildrenContext),allErrors=useMemo(()=>[...giftCardErrors||[],...orderErrors||[],...lineItemErrors||[],...addressErrors||[],...customerErrors||[],...shipmentErrors||[],...paymentMethodErrors?.filter(v=>v.field===currentPaymentMethodType&&payment?.id===currentPaymentMethodId)||[]],[giftCardErrors,orderErrors,lineItemErrors,addressErrors,customerErrors,shipmentErrors,paymentMethodErrors]).filter((v,k,a)=>v?.code!==a[k-1]?.code),msgErrors=getAllErrors({allErrors,field,messages,props:p,lineItem,resource,returnHtml:!children}),parentProps={messages,resource,field,errors:msgErrors,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx(_Fragment,{children:msgErrors})}export default Errors;
@@ -1,14 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props {
3
3
  children: ReactNode;
4
4
  url: string;
5
- };
6
- export declare function ExternalFunction({ children, url }: Props): JSX.Element;
7
- export declare namespace ExternalFunction {
8
- var propTypes: {
9
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
10
- url: import("prop-types").Validator<string>;
11
- };
12
- var displayName: string;
13
5
  }
6
+ export declare function ExternalFunction({ children, url }: Props): JSX.Element;
14
7
  export default ExternalFunction;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import ExternalFunctionContext,{callExternalFunction}from"../context/ExternalFunctionContext";import components from"../config/components";const propTypes=components.ExternalFunction.propTypes,displayName=components.ExternalFunction.displayName;export function ExternalFunction({children,url}){return _jsx(ExternalFunctionContext.Provider,{value:{url,callExternalFunction},children})}ExternalFunction.propTypes=propTypes,ExternalFunction.displayName=displayName;export default ExternalFunction;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import ExternalFunctionContext,{callExternalFunction}from"../context/ExternalFunctionContext";export function ExternalFunction({children,url}){return _jsx(ExternalFunctionContext.Provider,{value:{url,callExternalFunction},children})}export default ExternalFunction;
@@ -2,14 +2,4 @@
2
2
  import { BaseInputComponentProps } from '../typings/index';
3
3
  declare type Props = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
4
4
  export declare function MetadataInput(props: Props): JSX.Element;
5
- export declare namespace MetadataInput {
6
- var propTypes: {
7
- children: import("prop-types").Requireable<(...args: any[]) => any>;
8
- name: import("prop-types").Validator<string>;
9
- type: import("prop-types").Validator<NonNullable<import("../typings/index").BaseInputType>>;
10
- onChange: import("prop-types").Requireable<(...args: any[]) => any>;
11
- placeholder: import("prop-types").Requireable<string>;
12
- };
13
- var displayName: string;
14
- }
15
5
  export default MetadataInput;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";import components from"../config/components";const propTypes=components.MetadataInput.propTypes,displayName=components.MetadataInput.displayName;export function MetadataInput(props){return _jsx(BaseInput,{"data-metadata":!0,...props})}MetadataInput.propTypes=propTypes,MetadataInput.displayName=displayName;export default MetadataInput;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";export function MetadataInput(props){return _jsx(BaseInput,{"data-metadata":!0,...props})}export default MetadataInput;
@@ -7,20 +7,4 @@ declare type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
7
7
  disabled?: boolean;
8
8
  } & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
9
9
  export declare function AddressCountrySelector(props: Props): JSX.Element;
10
- export declare namespace AddressCountrySelector {
11
- var propTypes: {
12
- children: import("prop-types").Requireable<(...args: any[]) => any>;
13
- placeholder: import("prop-types").Requireable<import("prop-types").InferProps<{
14
- label: import("prop-types").Validator<string>;
15
- value: import("prop-types").Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
16
- }>>;
17
- value: import("prop-types").Requireable<string>;
18
- name: import("prop-types").Validator<NonNullable<AddressCountrySelectName>>;
19
- required: import("prop-types").Requireable<boolean>;
20
- };
21
- var defaultProps: {
22
- required: boolean;
23
- };
24
- var displayName: string;
25
- }
26
10
  export default AddressCountrySelector;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"../utils/BaseSelect";import components from"../../config/components";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import{getCountries}from"../../utils/countryStateCity";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";const propTypes=components.AddressCountrySelector.propTypes,defaultProps=components.AddressCountrySelector.defaultProps,displayName=components.AddressCountrySelector.displayName;export function AddressCountrySelector(props){const{required=!0,value,name,className,...p}=props,billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),customerAddress=useContext(CustomerAddressFormContext),[hasError,setHasError]=useState(!1);useEffect(()=>(value&&billingAddress?.setValue&&billingAddress.setValue(name,value),value&&shippingAddress?.setValue&&shippingAddress.setValue(name,value),value&&customerAddress?.setValue&&customerAddress.setValue(name,value),billingAddress.errors&&billingAddress?.errors?.[name]?.error&&setHasError(!0),billingAddress?.errors?.[name]&&hasError&&setHasError(!1),customerAddress.errors&&customerAddress?.errors?.[name]?.error&&setHasError(!0),customerAddress?.errors?.[name]&&hasError&&setHasError(!1),shippingAddress.errors&&shippingAddress?.errors?.[name]?.error&&setHasError(!0),shippingAddress?.errors?.[name]&&hasError&&setHasError(!1),()=>{setHasError(!1)}),[value,billingAddress?.errors,shippingAddress?.errors,customerAddress?.errors]);const errorClassName=billingAddress?.errorClassName||shippingAddress?.errorClassName||customerAddress?.errorClassName,classNameComputed=`${className||""} ${hasError&&errorClassName?errorClassName:""}`;return _jsx(BaseSelect,{className:classNameComputed,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,required,options:getCountries(),name,value,...p})}AddressCountrySelector.propTypes=propTypes,AddressCountrySelector.defaultProps=defaultProps,AddressCountrySelector.displayName=displayName;export default AddressCountrySelector;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"../utils/BaseSelect";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import{getCountries}from"../../utils/countryStateCity";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";export function AddressCountrySelector(props){const{required=!0,value,name,className,...p}=props,billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),customerAddress=useContext(CustomerAddressFormContext),[hasError,setHasError]=useState(!1);useEffect(()=>(value&&billingAddress?.setValue&&billingAddress.setValue(name,value),value&&shippingAddress?.setValue&&shippingAddress.setValue(name,value),value&&customerAddress?.setValue&&customerAddress.setValue(name,value),billingAddress.errors&&billingAddress?.errors?.[name]?.error&&setHasError(!0),billingAddress?.errors?.[name]&&hasError&&setHasError(!1),customerAddress.errors&&customerAddress?.errors?.[name]?.error&&setHasError(!0),customerAddress?.errors?.[name]&&hasError&&setHasError(!1),shippingAddress.errors&&shippingAddress?.errors?.[name]?.error&&setHasError(!0),shippingAddress?.errors?.[name]&&hasError&&setHasError(!1),()=>{setHasError(!1)}),[value,billingAddress?.errors,shippingAddress?.errors,customerAddress?.errors]);const errorClassName=billingAddress?.errorClassName||shippingAddress?.errorClassName||customerAddress?.errorClassName,classNameComputed=`${className??""} ${hasError&&errorClassName?errorClassName:""}`;return _jsx(BaseSelect,{className:classNameComputed,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,required,options:getCountries(),name,value,...p})}export default AddressCountrySelector;
@@ -8,20 +8,4 @@ declare type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
8
8
  selectClassName?: string;
9
9
  } & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>;
10
10
  export declare function AddressStateSelector(props: Props): JSX.Element;
11
- export declare namespace AddressStateSelector {
12
- var propTypes: {
13
- children: import("prop-types").Requireable<(...args: any[]) => any>;
14
- placeholder: import("prop-types").Requireable<import("prop-types").InferProps<{
15
- label: import("prop-types").Validator<string>;
16
- value: import("prop-types").Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
17
- }>>;
18
- value: import("prop-types").Requireable<string>;
19
- name: import("prop-types").Validator<NonNullable<AddressStateSelectName>>;
20
- required: import("prop-types").Requireable<boolean>;
21
- };
22
- var defaultProps: {
23
- required: boolean;
24
- };
25
- var displayName: string;
26
- }
27
11
  export default AddressStateSelector;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"../utils/BaseSelect";import components from"../../config/components";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import isEmpty from"lodash/isEmpty";import{getStateOfCountry,isValidState}from"../../utils/countryStateCity";import isEmptyStates from"../../utils/isEmptyStates";import AddressesContext from"../../context/AddressContext";import BaseInput from"../utils/BaseInput";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";const propTypes=components.AddressStateSelector.propTypes,defaultProps=components.AddressStateSelector.defaultProps,displayName=components.AddressStateSelector.displayName;export function AddressStateSelector(props){const{required=!0,value,name,className="",inputClassName="",selectClassName="",...p}=props,billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),customerAddress=useContext(CustomerAddressFormContext),{errors:addressErrors}=useContext(AddressesContext),[hasError,setHasError]=useState(!1),[countryCode,setCountryCode]=useState(""),[val,setVal]=useState(value||"");useEffect(()=>{const billingCountryCode=typeof billingAddress?.values?.billing_address_country_code=="string"?billingAddress?.values?.billing_address_country_code:billingAddress?.values?.billing_address_country_code?.value;billingCountryCode&&billingCountryCode!==countryCode&&setCountryCode(billingCountryCode);const shippingCountryCode=typeof shippingAddress?.values?.shipping_address_country_code=="string"?shippingAddress?.values?.shipping_address_country_code:shippingAddress?.values?.shipping_address_country_code?.value;if(shippingCountryCode&&shippingCountryCode!==countryCode&&setCountryCode(shippingCountryCode),[Object.keys(billingAddress).length>0,billingCountryCode,countryCode!==billingCountryCode].every(Boolean)&&billingCountryCode&&!isValidState(val,billingCountryCode)&&!isEmptyStates(billingCountryCode)&&(billingAddress.resetField&&billingAddress.resetField(name),setVal("")),[!isEmpty(shippingAddress),shippingCountryCode,countryCode!==shippingCountryCode].every(Boolean)&&shippingCountryCode&&!isValidState(val,shippingCountryCode)&&!isEmptyStates(shippingCountryCode)&&(shippingAddress.resetField&&shippingAddress.resetField(name),setVal("")),!isEmpty(billingAddress)){const fieldError=billingAddress?.errors?.[name]?.error;setHasError(!!fieldError)}if(!isEmpty(customerAddress)){const fieldError=customerAddress?.errors?.[name]?.error;setHasError(!!fieldError)}if(!isEmpty(shippingAddress)){const fieldError=shippingAddress?.errors?.[name]?.error;setHasError(!!fieldError)}return()=>{setHasError(!1)}},[value,billingAddress,shippingAddress,addressErrors,customerAddress]);const errorClassName=billingAddress?.errorClassName||shippingAddress?.errorClassName||customerAddress?.errorClassName||"",classNameComputed=isEmptyStates(countryCode)?`${className} ${inputClassName} ${hasError?errorClassName:""}`:`${className} ${selectClassName} ${hasError?errorClassName:""}`;return isEmptyStates(countryCode)?_jsx(BaseInput,{...p,name,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,className:classNameComputed,required,placeholder:p.placeholder?.label||"",defaultValue:val,type:"text"}):_jsx(BaseSelect,{...p,className:classNameComputed,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,required,options:getStateOfCountry(countryCode),name,value:val})}AddressStateSelector.propTypes=propTypes,AddressStateSelector.defaultProps=defaultProps,AddressStateSelector.displayName=displayName;export default AddressStateSelector;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import BaseSelect from"../utils/BaseSelect";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import isEmpty from"lodash/isEmpty";import{getStateOfCountry,isValidState}from"../../utils/countryStateCity";import isEmptyStates from"../../utils/isEmptyStates";import AddressesContext from"../../context/AddressContext";import BaseInput from"../utils/BaseInput";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";export function AddressStateSelector(props){const{required=!0,value,name,className="",inputClassName="",selectClassName="",...p}=props,billingAddress=useContext(BillingAddressFormContext),shippingAddress=useContext(ShippingAddressFormContext),customerAddress=useContext(CustomerAddressFormContext),{errors:addressErrors}=useContext(AddressesContext),[hasError,setHasError]=useState(!1),[countryCode,setCountryCode]=useState(""),[val,setVal]=useState(value||"");useEffect(()=>{const billingCountryCode=typeof billingAddress?.values?.billing_address_country_code=="string"?billingAddress?.values?.billing_address_country_code:billingAddress?.values?.billing_address_country_code?.value;billingCountryCode&&billingCountryCode!==countryCode&&setCountryCode(billingCountryCode);const shippingCountryCode=typeof shippingAddress?.values?.shipping_address_country_code=="string"?shippingAddress?.values?.shipping_address_country_code:shippingAddress?.values?.shipping_address_country_code?.value;if(shippingCountryCode&&shippingCountryCode!==countryCode&&setCountryCode(shippingCountryCode),[Object.keys(billingAddress).length>0,billingCountryCode,countryCode!==billingCountryCode].every(Boolean)&&billingCountryCode&&!isValidState(val,billingCountryCode)&&!isEmptyStates(billingCountryCode)&&(billingAddress.resetField&&billingAddress?.resetField(name),setVal("")),[!isEmpty(shippingAddress),shippingCountryCode,countryCode!==shippingCountryCode].every(Boolean)&&shippingCountryCode&&!isValidState(val,shippingCountryCode)&&!isEmptyStates(shippingCountryCode)&&(shippingAddress.resetField&&shippingAddress?.resetField(name),setVal("")),!isEmpty(billingAddress)){const fieldError=billingAddress?.errors?.[name]?.error;setHasError(!!fieldError)}if(!isEmpty(customerAddress)){const fieldError=customerAddress?.errors?.[name]?.error;setHasError(!!fieldError)}if(!isEmpty(shippingAddress)){const fieldError=shippingAddress?.errors?.[name]?.error;setHasError(!!fieldError)}return()=>{setHasError(!1)}},[value,billingAddress,shippingAddress,addressErrors,customerAddress]);const errorClassName=billingAddress?.errorClassName||shippingAddress?.errorClassName||customerAddress?.errorClassName||"",classNameComputed=isEmptyStates(countryCode)?`${className} ${inputClassName} ${hasError?errorClassName:""}`:`${className} ${selectClassName} ${hasError?errorClassName:""}`;return isEmptyStates(countryCode)?_jsx(BaseInput,{...p,name,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,className:classNameComputed,required,placeholder:p.placeholder?.label||"",defaultValue:val,type:"text"}):_jsx(BaseSelect,{...p,className:classNameComputed,ref:billingAddress?.validation||shippingAddress?.validation||customerAddress?.validation,required,options:getStateOfCountry(countryCode),name,value:val})}export default AddressStateSelector;
@@ -5,9 +5,4 @@ declare type Props = {
5
5
  errorClassName?: string;
6
6
  } & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
7
7
  export declare function BillingAddressForm(props: Props): JSX.Element;
8
- export declare namespace BillingAddressForm {
9
- var propTypes: {
10
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
11
- };
12
- }
13
8
  export default BillingAddressForm;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import{isEmpty}from"lodash";import components from"../../config/components";import OrderContext from"../../context/OrderContext";import{getSaveBillingAddressToAddressBook}from"../../utils/localStorage";import{businessMandatoryField}from"../../utils/validateFormFields";const propTypes=components.BillingAddressForm.propTypes;export function BillingAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,order,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(include?.includes("billing_address")?includeLoaded?.billing_address||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),isEmpty(errors)){if(values&&Object.keys(values).length>0){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field?.value||field?.required===!1&&field?.type!=="checkbox")&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),field?.type==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"billing_address",value:field.checked}))}setAddress({values:{...values,...isBusiness&&{business:isBusiness}},resource:"billing_address"})}}else{const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;["billing_address_state_code"].includes(fieldName)?values?.state_code?formErrors.push({code,message:message||"",resource:"billing_address",field:fieldName}):delete errors[fieldName]:formErrors.push({code,message:message||"",resource:"billing_address",field:fieldName})}setAddressErrors(formErrors,"billing_address")}const checkboxChecked=ref.current?.querySelector('[name="billing_address_save_to_customer_book"]')?.checked||getSaveBillingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"billing_address",value:!1}),ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"})))},[errors,values,reset,include,includeLoaded,isBusiness]);const providerValues={isBusiness,values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:{...values,...field,...isBusiness&&{business:isBusiness}},resource:"billing_address"})},errorClassName,requiresBillingInfo:order?.requires_billing_info||!1,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(BillingAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}BillingAddressForm.propTypes=propTypes;export default BillingAddressForm;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import BillingAddressFormContext from"../../context/BillingAddressFormContext";import isEmpty from"lodash/isEmpty";import OrderContext from"../../context/OrderContext";import{getSaveBillingAddressToAddressBook}from"../../utils/localStorage";import{businessMandatoryField}from"../../utils/validateFormFields";export function BillingAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,order,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(include?.includes("billing_address")?includeLoaded?.billing_address||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),isEmpty(errors)){if(values&&Object.keys(values).length>0){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field?.value||field?.required===!1&&field?.type!=="checkbox")&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),field?.type==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"billing_address",value:field.checked}))}setAddress({values:{...values,...isBusiness&&{business:isBusiness}},resource:"billing_address"})}}else{const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;["billing_address_state_code"].includes(fieldName)?values?.state_code?formErrors.push({code,message:message||"",resource:"billing_address",field:fieldName}):delete errors[fieldName]:formErrors.push({code,message:message||"",resource:"billing_address",field:fieldName})}setAddressErrors(formErrors,"billing_address")}const checkboxChecked=ref.current?.querySelector('[name="billing_address_save_to_customer_book"]')?.checked||getSaveBillingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"billing_address",value:!1}),ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"})))},[errors,values,reset,include,includeLoaded,isBusiness]);const providerValues={isBusiness,values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:{...values,...field,...isBusiness&&{business:isBusiness}},resource:"billing_address"})},errorClassName,requiresBillingInfo:order?.requires_billing_info||!1,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(BillingAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default BillingAddressForm;
@@ -1,11 +1,6 @@
1
- import { ReactNode } from 'react';
2
- declare type Props = {
3
- children: ReactNode;
4
- };
5
- export declare function ShippingAddressContainer(props: Props): JSX.Element;
6
- export declare namespace ShippingAddressContainer {
7
- var propTypes: {
8
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
9
- };
1
+ /// <reference types="react" />
2
+ interface Props {
3
+ children: JSX.Element[] | JSX.Element;
10
4
  }
5
+ export declare function ShippingAddressContainer(props: Props): JSX.Element;
11
6
  export default ShippingAddressContainer;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import ShippingAddressContext from"../../context/ShippingAddressContext";import{useContext,useEffect,useReducer}from"react";import shippingAddressReducer,{setShippingAddress,shippingAddressInitialState,setShippingCustomerAddressId}from"../../reducers/ShippingAddressReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import components from"../../config/components";import OrderContext from"../../context/OrderContext";import AddressContext from"../../context/AddressContext";const propTypes=components.ShippingAddressContainer.propTypes;export function ShippingAddressContainer(props){const{children}=props,[state,dispatch]=useReducer(shippingAddressReducer,shippingAddressInitialState),config=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{setCloneAddress}=useContext(AddressContext);useEffect(()=>(order&&config&&setShippingCustomerAddressId({dispatch,order,setCloneAddress}),()=>{dispatch({type:"cleanup",payload:{}})}),[config,order]);const contextValue={...state,setShippingAddress:async(id,options)=>{await setShippingAddress(id,{config,dispatch,order,customerAddressId:options?.customerAddressId}),setCloneAddress(id,"shipping_address")}};return _jsx(ShippingAddressContext.Provider,{value:contextValue,children})}ShippingAddressContainer.propTypes=propTypes;export default ShippingAddressContainer;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import ShippingAddressContext from"../../context/ShippingAddressContext";import{useContext,useEffect,useReducer}from"react";import shippingAddressReducer,{setShippingAddress,shippingAddressInitialState,setShippingCustomerAddressId}from"../../reducers/ShippingAddressReducer";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import AddressContext from"../../context/AddressContext";export function ShippingAddressContainer(props){const{children}=props,[state,dispatch]=useReducer(shippingAddressReducer,shippingAddressInitialState),config=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{setCloneAddress}=useContext(AddressContext);useEffect(()=>(order&&config&&setShippingCustomerAddressId({dispatch,order,setCloneAddress}),()=>{dispatch({type:"cleanup",payload:{}})}),[config,order]);const contextValue={...state,setShippingAddress:async(id,options)=>{await setShippingAddress(id,{config,dispatch,order,customerAddressId:options?.customerAddressId}),setCloneAddress(id,"shipping_address")}};return _jsx(ShippingAddressContext.Provider,{value:contextValue,children})}export default ShippingAddressContainer;
@@ -1,13 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props extends Omit<JSX.IntrinsicElements['form'], 'onSubmit'> {
3
3
  children: ReactNode;
4
4
  reset?: boolean;
5
5
  errorClassName?: string;
6
- } & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
7
- export declare function ShippingAddressForm(props: Props): JSX.Element;
8
- export declare namespace ShippingAddressForm {
9
- var propTypes: {
10
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
11
- };
12
6
  }
7
+ export declare function ShippingAddressForm(props: Props): JSX.Element;
13
8
  export default ShippingAddressForm;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import{isEmpty}from"lodash";import components from"../../config/components";import OrderContext from"../../context/OrderContext";import{getSaveShippingAddressToAddressBook}from"../../utils/localStorage";import{businessMandatoryField}from"../../utils/validateFormFields";const propTypes=components.ShippingAddressForm.propTypes;export function ShippingAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,shipToDifferentAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address"}),isEmpty(errors)){if(!isEmpty(values)&&shipToDifferentAddress){setAddressErrors([],"shipping_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field?.value||field?.required===!1&&field?.type!=="checkbox")&&(values[name.replace("shipping_address_","")]=field.value,delete values[name]),field?.type==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"shipping_address",value:field.checked}))}setAddress({values:{...values,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})}}else{const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;["shipping_address_state_code"].includes(fieldName)?isEmpty(values.state_code)?delete errors[fieldName]:formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName}):formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName})}shipToDifferentAddress&&setAddressErrors(formErrors,"shipping_address")}const checkboxChecked=ref.current?.querySelector('[name="shipping_address_save_to_customer_book"]')?.checked||getSaveShippingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"shipping_address",value:!1}),ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"shipping_address"),setAddress({values:{},resource:"shipping_address"})))},[values,errors,shipToDifferentAddress,reset,include,includeLoaded,isBusiness]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("shipping_address_","")]:value};setAddress({values:{...values,...field,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})},errorClassName,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(ShippingAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}ShippingAddressForm.propTypes=propTypes;export default ShippingAddressForm;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import ShippingAddressFormContext from"../../context/ShippingAddressFormContext";import{isEmpty}from"lodash";import OrderContext from"../../context/OrderContext";import{getSaveShippingAddressToAddressBook}from"../../utils/localStorage";import{businessMandatoryField}from"../../utils/validateFormFields";export function ShippingAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress,shipToDifferentAddress,isBusiness}=useContext(AddressesContext),{saveAddressToCustomerAddressBook,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(include?.includes("shipping_address")?includeLoaded?.shipping_address||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address"}),isEmpty(errors)){if(!isEmpty(values)&&shipToDifferentAddress){setAddressErrors([],"shipping_address");for(const name in values){const field=values[name];businessMandatoryField(name,isBusiness)||delete values[name],(field?.value||field?.required===!1&&field?.type!=="checkbox")&&(values[name.replace("shipping_address_","")]=field.value,delete values[name]),field?.type==="checkbox"&&(delete values[name],saveAddressToCustomerAddressBook({type:"shipping_address",value:field.checked}))}setAddress({values:{...values,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})}}else{const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message;["shipping_address_state_code"].includes(fieldName)?isEmpty(values.state_code)?delete errors[fieldName]:formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName}):formErrors.push({code,message:message||"",resource:"shipping_address",field:fieldName})}shipToDifferentAddress&&setAddressErrors(formErrors,"shipping_address")}const checkboxChecked=ref.current?.querySelector('[name="shipping_address_save_to_customer_book"]')?.checked||getSaveShippingAddressToAddressBook();reset&&(!isEmpty(values)||!isEmpty(errors)||checkboxChecked)&&(saveAddressToCustomerAddressBook&&saveAddressToCustomerAddressBook({type:"shipping_address",value:!1}),ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"shipping_address"),setAddress({values:{},resource:"shipping_address"})))},[values,errors,shipToDifferentAddress,reset,include,includeLoaded,isBusiness]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("shipping_address_","")]:value};setAddress({values:{...values,...field,...isBusiness&&{business:isBusiness}},resource:"shipping_address"})},errorClassName,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(ShippingAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default ShippingAddressForm;
@@ -1,13 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- declare type Props = {
2
+ interface Props extends Omit<JSX.IntrinsicElements['form'], 'onSubmit'> {
3
3
  children: ReactNode;
4
4
  reset?: boolean;
5
5
  errorClassName?: string;
6
- } & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>;
7
- export declare function CustomerAddressForm(props: Props): JSX.Element;
8
- export declare namespace CustomerAddressForm {
9
- var propTypes: {
10
- children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
11
- };
12
6
  }
7
+ export declare function CustomerAddressForm(props: Props): JSX.Element;
13
8
  export default CustomerAddressForm;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";import components from"../../config/components";import OrderContext from"../../context/OrderContext";import isEmptyStates from"../../utils/isEmptyStates";const propTypes=components.CustomerAddressForm.propTypes;export function CustomerAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress}=useContext(AddressesContext),{order}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(Object.keys(errors).length>0){const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message||"";fieldName==="billing_address_state_code"?values.state_code?delete errors[fieldName]:formErrors.push({code,message,resource:"billing_address",field:fieldName}):formErrors.push({code,message,resource:"billing_address",field:fieldName})}setAddressErrors(formErrors,"billing_address")}else if(Object.keys(values).length>0){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];if(field?.value&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),["billing_address_state_code"].includes(name)){const countryCode=values.billing_address_country_code?.value||values.country_code;!isEmptyStates(countryCode)&&!field.value&&delete values.billing_address_state_code}}setAddress({values,resource:"billing_address"})}reset&&(Object.keys(values).length>0||Object.keys(errors).length>0)&&ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"}))},[errors,values,reset]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:{...values,...field},resource:"billing_address"})},errorClassName,requiresBillingInfo:order?.requiresBillingInfo||!1,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(CustomerAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}CustomerAddressForm.propTypes=propTypes;export default CustomerAddressForm;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import AddressesContext from"../../context/AddressContext";import{useRapidForm}from"rapid-form";import{useContext,useEffect,useRef}from"react";import CustomerAddressFormContext from"../../context/CustomerAddressFormContext";import OrderContext from"../../context/OrderContext";import isEmptyStates from"../../utils/isEmptyStates";export function CustomerAddressForm(props){const{children,errorClassName,autoComplete="on",reset=!1,...p}=props,{validation,values,errors,reset:resetForm}=useRapidForm(),{setAddressErrors,setAddress}=useContext(AddressesContext),{order}=useContext(OrderContext),ref=useRef(null);useEffect(()=>{if(Object.keys(errors).length>0){const formErrors=[];for(const fieldName in errors){const code=errors[fieldName]?.code,message=errors[fieldName]?.message||"";fieldName==="billing_address_state_code"?values.state_code?delete errors[fieldName]:formErrors.push({code,message,resource:"billing_address",field:fieldName}):formErrors.push({code,message,resource:"billing_address",field:fieldName})}setAddressErrors(formErrors,"billing_address")}else if(Object.keys(values).length>0){setAddressErrors([],"billing_address");for(const name in values){const field=values[name];if(field?.value&&(values[name.replace("billing_address_","")]=field.value,delete values[name]),["billing_address_state_code"].includes(name)){const countryCode=values.billing_address_country_code?.value||values.country_code;!isEmptyStates(countryCode)&&!field.value&&delete values.billing_address_state_code}}setAddress({values,resource:"billing_address"})}reset&&(Object.keys(values).length>0||Object.keys(errors).length>0)&&ref&&(ref.current?.reset(),resetForm({target:ref.current}),setAddressErrors([],"billing_address"),setAddress({values:{},resource:"billing_address"}))},[errors,values,reset]);const providerValues={values,validation,setValue:(name,value)=>{const field={[name.replace("billing_address_","")]:value};setAddress({values:{...values,...field},resource:"billing_address"})},errorClassName,requiresBillingInfo:order?.requires_billing_info||!1,errors,resetField:name=>resetForm({currentTarget:ref.current},name)};return _jsx(CustomerAddressFormContext.Provider,{value:providerValues,children:_jsx("form",{ref,autoComplete,...p,children})})}export default CustomerAddressForm;
@@ -6,18 +6,6 @@ declare type Props = {
6
6
  saveOnBlur?: boolean;
7
7
  onBlur?: (email: string) => void;
8
8
  errorClassName?: string;
9
- } & Omit<BaseInputComponentProps, 'name' | 'type' | 'onBlur'> & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
9
+ } & Omit<BaseInputComponentProps, 'name' | 'type' | 'onBlur'> & Omit<JSX.IntrinsicElements['input'], 'children'> & Omit<JSX.IntrinsicElements['textarea'], 'children'>;
10
10
  export declare function CustomerInput(props: Props): JSX.Element;
11
- export declare namespace CustomerInput {
12
- var propTypes: {
13
- children: import("prop-types").Requireable<(...args: any[]) => any>;
14
- name: import("prop-types").Requireable<string>;
15
- type: import("prop-types").Requireable<string>;
16
- placeholder: import("prop-types").Requireable<string>;
17
- disabled: import("prop-types").Requireable<boolean>;
18
- required: import("prop-types").Requireable<boolean>;
19
- saveOnBlur: import("prop-types").Requireable<boolean>;
20
- };
21
- var displayName: string;
22
- }
23
11
  export default CustomerInput;