@shopgate/engage 7.29.1-beta.1 → 7.29.1-beta.3

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 (119) hide show
  1. package/cart/cart.context.js +18 -1
  2. package/cart/cart.hooks.js +5 -3
  3. package/cart/cart.types.js +35 -1
  4. package/cart/components/CartItem/CartItem.js +3 -1
  5. package/cart/components/CartItem/CartItemCoupon.connector.js +8 -2
  6. package/cart/components/CartItem/CartItemCoupon.js +26 -18
  7. package/cart/components/CartItem/CartItemCoupon.types.js +15 -0
  8. package/cart/components/CartItem/CartItemCouponLayout.js +9 -3
  9. package/cart/components/CartItem/CartItemCouponPrice.js +8 -2
  10. package/cart/components/CartItem/CartItemProduct.js +0 -1
  11. package/cart/components/CartItem/CartItemProductLayoutWide.js +0 -1
  12. package/cart/components/CartItem/CartItemProductLayoutWide.style.js +1 -1
  13. package/cart/components/CartItem/CartItemProductLayoutWideFulfillmentLabel.js +1 -2
  14. package/cart/components/CartItem/CartItemProductLayoutWideFulfillmentLabel.style.js +1 -1
  15. package/cart/components/CartItem/CartItemProductLayoutWideOrderDetails.js +1 -1
  16. package/cart/components/CartItem/CartItemProductLayoutWideRemoveItem.js +1 -2
  17. package/cart/components/CartItem/CartItemProductOrderDetails.js +1 -1
  18. package/cart/components/CartItem/CartItemProductPriceCaption.js +1 -1
  19. package/cart/components/CartItem/CartItemProductPriceList.js +4 -1
  20. package/cart/components/CartItem/CartItemProductPriceListPromotion.js +3 -1
  21. package/cart/components/CartItem/CartItemProductProvider.connector.js +15 -3
  22. package/cart/components/CartItem/CartItemProductProvider.js +10 -4
  23. package/cart/components/CartItem/CartItemProductProvider.types.js +27 -1
  24. package/cart/components/CartItem/CartItemProvider.js +12 -3
  25. package/cart/components/CartItem/CartItemQuantityPicker.js +25 -24
  26. package/cart/components/CartItem/CartItemSubstitution.js +3 -1
  27. package/cart/components/CartItems/CartItemCard.js +8 -3
  28. package/cart/components/CartItems/CartItemCardReservation.js +4 -3
  29. package/cart/components/CartItems/CartItemCardReservationAccordion.js +5 -4
  30. package/cart/components/CartItems/CartItemCardReservationLabel.js +4 -4
  31. package/cart/components/CartItems/CartItemGroup.js +7 -3
  32. package/cart/components/CartItems/CartItemGroupReservation.js +4 -3
  33. package/cart/components/CartItems/CartItemGroupReservationLabel.js +4 -4
  34. package/cart/components/CartItems/CartItems.js +13 -3
  35. package/cart/components/CartItems/CartItemsHeaderWide.js +10 -3
  36. package/cart/components/CartItems/CartItemsHeaderWide.style.js +1 -1
  37. package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.js +3 -2
  38. package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.style.js +1 -1
  39. package/cart/components/PaymentBar/PaymentBarCheckoutButton.js +1 -1
  40. package/cart/components/PaymentBar/PaymentBarDiscounts.js +6 -2
  41. package/cart/components/PaymentBar/PaymentBarGrandTotal.js +8 -3
  42. package/cart/components/PaymentBar/PaymentBarReserveButton.js +5 -4
  43. package/cart/components/PaymentBar/PaymentBarShippingCost.js +8 -3
  44. package/cart/components/PaymentBar/PaymentBarSubTotal.js +9 -3
  45. package/cart/components/PaymentBar/PaymentBarTax.js +7 -3
  46. package/cart/index.js +2 -1
  47. package/checkout/paymentMethods/stripe/StripeProvider.js +6 -3
  48. package/checkout/providers/CheckoutProvider.js +41 -10
  49. package/components/SideNavigation/SideNavigation.js +7 -3
  50. package/components/SideNavigation/SideNavigationCategories.js +9 -4
  51. package/components/SideNavigation/SideNavigationCategories.style.js +1 -1
  52. package/components/SideNavigation/SideNavigationCategoriesItem.js +10 -3
  53. package/components/SideNavigation/SideNavigationCategoriesItem.style.js +1 -1
  54. package/components/SideNavigation/SideNavigationCategoriesItemChildren.js +6 -3
  55. package/components/SideNavigation/SideNavigationContent.js +5 -2
  56. package/components/SideNavigation/SideNavigationContent.style.js +1 -1
  57. package/components/SideNavigation/SideNavigationItem.js +14 -4
  58. package/components/SideNavigation/SideNavigationLinksLegal.js +5 -4
  59. package/components/SideNavigation/SideNavigationLinksQuicklinks.js +4 -3
  60. package/components/SideNavigation/SideNavigationNestedItem.js +8 -2
  61. package/components/SideNavigation/SideNavigationProvider.js +12 -3
  62. package/core/config/config.types.js +15 -0
  63. package/core/hooks/useAsyncMemo.js +1 -1
  64. package/i18n/countries.hooks.js +5 -5
  65. package/locations/action-creators/setUserSearchCountryCode.js +11 -4
  66. package/locations/action-creators/setUserSearchPostalCode.js +11 -4
  67. package/locations/components/Cart/CartChangeFulfillmentMethod.connector.js +4 -1
  68. package/locations/components/Cart/CartChangeFulfillmentMethod.js +10 -7
  69. package/locations/components/Cart/CartChangeFulfillmentMethod.types.js +10 -0
  70. package/locations/components/Cart/CartContextMenuChangeFulfillment.js +9 -4
  71. package/locations/components/Cart/CartContextMenuItemChangeLocation.js +7 -6
  72. package/locations/components/Cart/CartItemProductChangeLocation.connector.js +5 -2
  73. package/locations/components/Cart/CartItemProductChangeLocation.js +12 -9
  74. package/locations/components/Cart/CartItemProductChangeLocation.types.js +9 -0
  75. package/locations/components/ChangeLocationButton/ChangeLocationButton.js +6 -3
  76. package/locations/components/FulfillmentPath/FulfillmentPathItem.js +6 -4
  77. package/locations/components/FulfillmentSelector/FulfillmentSelector.connector.js +20 -6
  78. package/locations/components/FulfillmentSelector/FulfillmentSelector.context.js +2 -1
  79. package/locations/components/FulfillmentSelector/FulfillmentSelector.hooks.js +3 -2
  80. package/locations/components/FulfillmentSelector/FulfillmentSelector.js +8 -17
  81. package/locations/components/FulfillmentSelector/FulfillmentSelector.style.js +1 -1
  82. package/locations/components/FulfillmentSelector/FulfillmentSelector.types.js +57 -1
  83. package/locations/components/FulfillmentSelector/FulfillmentSelectorAddToCart.js +5 -8
  84. package/locations/components/FulfillmentSelector/FulfillmentSelectorBOPIS.js +3 -3
  85. package/locations/components/FulfillmentSelector/FulfillmentSelectorDirectShip.js +2 -3
  86. package/locations/components/FulfillmentSelector/FulfillmentSelectorHeader.js +3 -3
  87. package/locations/components/FulfillmentSelector/FulfillmentSelectorHeader.style.js +1 -1
  88. package/locations/components/FulfillmentSelector/FulfillmentSelectorItem.js +9 -5
  89. package/locations/components/FulfillmentSelector/FulfillmentSelectorItem.style.js +1 -1
  90. package/locations/components/ReserveForm/ReserveForm.js +6 -5
  91. package/locations/components/ReserveForm/ReserveForm.style.js +1 -1
  92. package/locations/components/ReserveForm/ReserveFormPhone.connector.js +6 -2
  93. package/locations/components/ReserveForm/ReserveFormPhone.js +8 -3
  94. package/locations/components/ReserveForm/ReserveFormPhone.types.js +11 -0
  95. package/locations/components/StoreFinder/Store.context.js +3 -1
  96. package/locations/components/StoreFinder/StoreFinderLocation.js +1 -1
  97. package/locations/components/StoreList/Store.context.js +3 -1
  98. package/locations/index.js +1 -1
  99. package/locations/locations.context.js +32 -1
  100. package/locations/locations.types.js +130 -1
  101. package/locations/providers/FulfillmentProvider.connector.js +7 -3
  102. package/locations/providers/FulfillmentProvider.js +38 -27
  103. package/locations/providers/FulfillmentProvider.types.js +42 -1
  104. package/locations/providers/StoreFinderProvider.js +1 -1
  105. package/locations/reducers/index.js +3 -1
  106. package/locations/reducers/userFormInput.js +7 -7
  107. package/locations/selectors/index.js +1 -1
  108. package/package.json +7 -7
  109. package/page/helpers/index.d.ts +14 -0
  110. package/page/helpers/index.js +9 -1
  111. package/page/widgets/Video/Video.js +4 -0
  112. package/page/widgets/Video/hooks.js +14 -0
  113. package/page/widgets/Video/index.js +1 -0
  114. package/page/widgets/index.js +1 -1
  115. package/page/widgets/widgets.json +3 -0
  116. package/product/product.types.js +32 -0
  117. package/registration/hooks/index.js +1 -1
  118. package/registration/providers/RegistrationProvider.js +12 -2
  119. package/types.js +0 -0
@@ -1,2 +1,2 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var chevronButton=css({flexShrink:0,outline:0,margin:"0 -".concat(variables.gap.big,"px 0 ").concat(variables.gap.small,"px"),fontSize:'1.6em',color:'#373D41',position:'relative'});export var chevron=css({transformOrigin:'center center',transition:'transform 250ms cubic-bezier(0.25, 0.1, 0.25, 1)'});export var chevronDown=css(chevron,{transform:'rotateZ(0deg)'});export var chevronUp=css(chevron,{transform:'rotateZ(180deg)'});export var progressBar=css({position:'absolute',overflow:'hidden',width:'100%',bottom:0,height:3});export var open=css({// borderRight: '2px solid var(--color-primary)',
1
+ import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var chevronButton=css({flexShrink:0,outline:0,margin:"0 -".concat(variables.gap.big,"px 0 ").concat(variables.gap.small,"px"),fontSize:'1.6em',color:'#373D41',position:'relative'}).toString();export var chevron=css({transformOrigin:'center center',transition:'transform 250ms cubic-bezier(0.25, 0.1, 0.25, 1)'});export var chevronDown=css(chevron,{transform:'rotateZ(0deg)'});export var chevronUp=css(chevron,{transform:'rotateZ(180deg)'});export var progressBar=css({position:'absolute',overflow:'hidden',width:'100%',bottom:0,height:3}).toString();export var open=css({// borderRight: '2px solid var(--color-primary)',
2
2
  }).toString();export var loadingIndicator=css({position:'absolute',padding:0,top:'50%',marginTop:'-50%',paddingTop:1,right:3}).toString();
@@ -1,5 +1,8 @@
1
- import React from'react';// eslint-disable-next-line import/no-cycle
1
+ import React from'react';import PropTypes from'prop-types';// eslint-disable-next-line import/no-cycle
2
2
  import SideNavigationCategoriesItem from"./SideNavigationCategoriesItem";/**
3
- * The SideNavigationCategoriesItemChildren component
4
- * @returns {JSX}
3
+ * The SideNavigationCategoriesItemChildren component.
4
+ * @param {Object} props The component props.
5
+ * @param {Array} props.subcategories The list of subcategories.
6
+ * @param {number} props.level The current nesting level.
7
+ * @returns {JSX.Element} The rendered component.
5
8
  */var SideNavigationCategoriesItemChildren=function SideNavigationCategoriesItemChildren(_ref){var subcategories=_ref.subcategories,level=_ref.level;return React.createElement("ul",null,subcategories.map(function(category){return React.createElement(SideNavigationCategoriesItem,{key:category.id,level:level,categoryId:category.id});}));};export default SideNavigationCategoriesItemChildren;
@@ -1,3 +1,6 @@
1
- import React,{useMemo}from'react';import{INDEX_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import SideNavigationCategories from"./SideNavigationCategories";import SideNavigationLinks from"./SideNavigationLinks";import SideNavigationItem from"./SideNavigationItem";import{useSideNavigation}from"./SideNavigation.hooks";import{container}from"./SideNavigationContent.style";/**
2
- * @returns {JSX}
1
+ import React,{useMemo}from'react';import PropTypes from'prop-types';import{INDEX_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import SideNavigationCategories from"./SideNavigationCategories";import SideNavigationLinks from"./SideNavigationLinks";import SideNavigationItem from"./SideNavigationItem";import{useSideNavigation}from"./SideNavigation.hooks";import{container}from"./SideNavigationContent.style";/**
2
+ * SideNavigationContent component.
3
+ * @param {Object} props - The component props.
4
+ * @param {Object} [props.classNames] - The class names for the navigation visibility.
5
+ * @returns {JSX.Element} The rendered component.
3
6
  */var SideNavigationContent=function SideNavigationContent(_ref){var classNames=_ref.classNames;var _useSideNavigation=useSideNavigation(),isVisible=_useSideNavigation.isVisible;var wrapperClass=useMemo(function(){if(!classNames){return'';}var _classNames$visible=classNames.visible,visible=_classNames$visible===void 0?'':_classNames$visible,_classNames$hidden=classNames.hidden,hidden=_classNames$hidden===void 0?'':_classNames$hidden;return isVisible?visible:hidden;},[classNames,isVisible]);return React.createElement("div",{className:wrapperClass},isVisible&&React.createElement("nav",{className:container},React.createElement("ul",null,React.createElement(SideNavigationItem,{href:INDEX_PATH,label:"navigation.home"}),React.createElement(SideNavigationCategories,null),React.createElement(SideNavigationLinks,null))));};SideNavigationContent.defaultProps={classNames:null};export default SideNavigationContent;
@@ -1,4 +1,4 @@
1
1
  import{css}from'glamor';export var container=css({background:'#fff'/*
2
2
  position: 'sticky',
3
3
  top: 'var(--app-bar-height)',
4
- */});
4
+ */}).toString();
@@ -1,4 +1,14 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{useMemo,memo}from'react';import classNames from'classnames';import Link from'@shopgate/pwa-common/components/Link';import{i18n}from'@shopgate/engage/core';import{getIndentation,item,itemActive,link,linkActive,list}from"./SideNavigationItem.style";import{useSideNavigation}from"./SideNavigation.hooks";/**
2
- * SideNavigationItem component
3
- * @returns {JSX}
4
- */var SideNavigationItem=function SideNavigationItem(_ref){var level=_ref.level,href=_ref.href,label=_ref.label,buttonRight=_ref.buttonRight,children=_ref.children,forceActive=_ref.forceActive,forceInactive=_ref.forceInactive,className=_ref.className,onClick=_ref.onClick;var _useSideNavigation=useSideNavigation(),currentPathname=_useSideNavigation.currentPathname;var isActive=useMemo(function(){return!forceInactive&&(currentPathname===href||forceActive);},[currentPathname,forceActive,forceInactive,href]);return React.createElement("li",{className:classNames(list,className)},React.createElement("div",{className:classNames(item,_defineProperty({},itemActive,isActive))},href?React.createElement(Link,{tag:"a",href:href,className:classNames(link,getIndentation(level),_defineProperty({},linkActive,isActive))},i18n.text(label)):React.createElement("button",{type:"button",className:classNames(link,getIndentation(level),_defineProperty({},linkActive,isActive)),onClick:onClick},i18n.text(label)),buttonRight),children);};SideNavigationItem.defaultProps={buttonRight:null,children:null,forceActive:false,forceInactive:false,level:0,href:null,className:null,onClick:function onClick(){}};export default memo(SideNavigationItem);
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{useMemo,memo}from'react';import classNames from'classnames';import Link from'@shopgate/pwa-common/components/Link';import{i18n}from'@shopgate/engage/core';import PropTypes from'prop-types';import{getIndentation,item,itemActive,link,linkActive,list}from"./SideNavigationItem.style";import{useSideNavigation}from"./SideNavigation.hooks";/**
2
+ * SideNavigationItem component.
3
+ * @param {Object} props - The component props.
4
+ * @param {React.ReactNode} [props.children] - The child components.
5
+ * @param {number} [props.level=0] - The indentation level of the item.
6
+ * @param {React.ReactNode} [props.buttonRight] - The button to display on the right side.
7
+ * @param {boolean} [props.forceActive=false] - Whether to force the item to be active.
8
+ * @param {boolean} [props.forceInactive=false] - Whether to force the item to be inactive.
9
+ * @param {string} [props.className] - Additional class names for the item.
10
+ * @param {Function} [props.onClick] - The click handler for the item.
11
+ * @param {string} [props.href] - The URL the item links to.
12
+ * @param {string} props.label - The label text for the item.
13
+ * @returns {JSX.Element} The rendered component.
14
+ */var SideNavigationItem=function SideNavigationItem(_ref){var children=_ref.children,level=_ref.level,buttonRight=_ref.buttonRight,forceActive=_ref.forceActive,forceInactive=_ref.forceInactive,className=_ref.className,onClick=_ref.onClick,href=_ref.href,label=_ref.label;var _useSideNavigation=useSideNavigation(),currentPathname=_useSideNavigation.currentPathname;var isActive=useMemo(function(){return!forceInactive&&(currentPathname===href||forceActive);},[currentPathname,forceActive,forceInactive,href]);return React.createElement("li",{className:classNames(list,className)},React.createElement("div",{className:classNames(item,_defineProperty({},itemActive,isActive))},href?React.createElement(Link,{tag:"a",href:href,className:classNames(link,getIndentation(level),_defineProperty({},linkActive,isActive))},i18n.text(label)):React.createElement("button",{type:"button",className:classNames(link,getIndentation(level),_defineProperty({},linkActive,isActive)),onClick:onClick},i18n.text(label)),buttonRight),children);};SideNavigationItem.defaultProps={buttonRight:null,children:null,forceActive:false,forceInactive:false,level:0,href:null,className:null,onClick:function onClick(){}};export default memo(SideNavigationItem);
@@ -1,5 +1,6 @@
1
- import React from'react';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksLegal.connector";/**
2
- *
3
- * @param {Object} props The component props
4
- * @returns {JSX}
1
+ import React from'react';import PropTypes from'prop-types';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksLegal.connector";/**
2
+ * SideNavigationLinksLegal component.
3
+ * @param {Object} props - The component props.
4
+ * @param {Array<{label: string, url: string}>} [props.links] - The list of legal links.
5
+ * @returns {*[]} The rendered component or null.
5
6
  */var SideNavigationLinksLegal=function SideNavigationLinksLegal(_ref){var links=_ref.links;if(!links){return null;}return links.map(function(_ref2){var label=_ref2.label,url=_ref2.url;return React.createElement(SideNavigationItem,{key:url,href:url,label:label});});};SideNavigationLinksLegal.defaultProps={links:null,isFetching:false};export default connect(SideNavigationLinksLegal);
@@ -1,5 +1,6 @@
1
- import React from'react';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksQuicklinks.connector";/**
1
+ import React from'react';import PropTypes from'prop-types';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksQuicklinks.connector";/**
2
2
  *
3
3
  * @param {Object} props The component props
4
- * @returns {JSX}
5
- */var SideNavigationLinksQuicklinks=function SideNavigationLinksQuicklinks(_ref){var links=_ref.links;if(!links){return null;}return links.map(function(_ref2){var label=_ref2.label,url=_ref2.url;return React.createElement(SideNavigationItem,{key:url,href:url,label:label});});};SideNavigationLinksQuicklinks.defaultProps={links:null,isFetching:false};export default connect(SideNavigationLinksQuicklinks);
4
+ * @param {Array} props.links The quicklinks links
5
+ * @returns {*[]}
6
+ */var SideNavigationLinksQuicklinks=function SideNavigationLinksQuicklinks(_ref){var links=_ref.links;if(!links){return null;}return links.map(function(_ref2){var label=_ref2.label,url=_ref2.url;return React.createElement(SideNavigationItem,{key:url,href:url,label:label});});};SideNavigationLinksQuicklinks.defaultProps={links:null};export default connect(SideNavigationLinksQuicklinks);
@@ -1,4 +1,10 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useState,useCallback,useMemo,useEffect}from'react';import ArrowDrop from'@shopgate/pwa-ui-shared/icons/ArrowDropIcon';import{chevronButton,chevronUp,chevronDown,open}from"./SideNavigationCategoriesItem.style";import SideNavigationItem from"./SideNavigationItem";/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useState,useCallback,useMemo,useEffect}from'react';import ArrowDrop from'@shopgate/pwa-ui-shared/icons/ArrowDropIcon';import PropTypes from'prop-types';import{chevronButton,chevronUp,chevronDown,open}from"./SideNavigationCategoriesItem.style";import SideNavigationItem from"./SideNavigationItem";/**
2
2
  * The SideNavigationCategoriesItem component
3
- * @returns {JSX}
3
+ * @param {Object} props The component props.
4
+ * @param {number} props.level The nesting level.
5
+ * @param {string} props.label The item label.
6
+ * @param {string} props.href The item href.
7
+ * @param {JSX.Element} props.children The nested items.
8
+ * @param {boolean} props.forceActive Whether the item should be forced open.
9
+ * @returns {JSX.Element}
4
10
  */var SideNavigationNestedItem=function SideNavigationNestedItem(_ref){var level=_ref.level,label=_ref.label,href=_ref.href,children=_ref.children,forceActive=_ref.forceActive;var _useState=useState(forceActive),_useState2=_slicedToArray(_useState,2),isOpen=_useState2[0],setIsOpen=_useState2[1];useEffect(function(){if(forceActive){setIsOpen(true);}},[forceActive]);var handleClick=useCallback(function(){setIsOpen(!isOpen);},[isOpen]);var buttonRight=useMemo(function(){return React.createElement("button",{type:"button",onClick:handleClick,className:chevronButton},React.createElement(ArrowDrop,{className:(isOpen?chevronUp:chevronDown).toString()}));},[handleClick,isOpen]);return React.createElement(SideNavigationItem,{href:href,label:label,level:level,buttonRight:buttonRight,className:level===0&&isOpen?open:null,forceInactive:true},isOpen?children:null);};SideNavigationNestedItem.defaultProps={level:0,forceActive:false};export default SideNavigationNestedItem;
@@ -1,4 +1,13 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useState,useMemo,useEffect}from'react';import{CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN}from'@shopgate/pwa-common-commerce/category/constants';import{ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN}from'@shopgate/pwa-common-commerce/product/constants';import{hex2bin}from'@shopgate/pwa-common/helpers/data';import Context from"./SideNavigationProvider.context";import connect from"./SideNavigationProvider.connector";var categoryPatterns=[CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN];var itemPatterns=[ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN];/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useState,useMemo,useEffect}from'react';import PropTypes from'prop-types';import{CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN}from'@shopgate/pwa-common-commerce/category/constants';import{ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN}from'@shopgate/pwa-common-commerce/product/constants';import{hex2bin}from'@shopgate/pwa-common/helpers/data';import Context from"./SideNavigationProvider.context";import connect from"./SideNavigationProvider.connector";var categoryPatterns=[CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN];var itemPatterns=[ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN];/**
2
2
  * SideNavigation Provider
3
- * @returns {JSX}
4
- */var SideNavigationProvider=function SideNavigationProvider(_ref){var maxCategoryNesting=_ref.maxCategoryNesting,routePatternBlacklist=_ref.routePatternBlacklist,currentParams=_ref.currentParams,currentPathname=_ref.currentPathname,currentRoute=_ref.currentRoute,isLoggedIn=_ref.isLoggedIn,logout=_ref.logout,children=_ref.children;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),activeCategoryId=_useState2[0],setActiveCategoryId=_useState2[1];var _useState3=useState(true),_useState4=_slicedToArray(_useState3,2),isVisible=_useState4[0],setIsVisible=_useState4[1];useEffect(function(){if(!currentRoute){return;}var pattern=currentRoute.pattern;if(categoryPatterns.includes(pattern)){var categoryId=currentParams.categoryId;setActiveCategoryId(hex2bin(categoryId));}else if(!itemPatterns.includes(pattern)){setActiveCategoryId(null);}setIsVisible(!routePatternBlacklist.includes(pattern));});var value=useMemo(function(){return{maxCategoryNesting:maxCategoryNesting,currentParams:currentParams,currentPathname:currentPathname,currentRoute:currentRoute,isLoggedIn:isLoggedIn,logout:logout,activeCategoryId:activeCategoryId,isVisible:isVisible};},[activeCategoryId,currentParams,currentPathname,currentRoute,isLoggedIn,isVisible,logout,maxCategoryNesting]);return React.createElement(Context.Provider,{value:value},children);};SideNavigationProvider.defaultProps={currentParams:null,currentPathname:'',routePatternBlacklist:[],currentRoute:null};export default connect(SideNavigationProvider);
3
+ * @param {Object} props The component props.
4
+ * @param {number} props.maxCategoryNesting Maximum category nesting level.
5
+ * @param {Array} [props.routePatternBlacklist=[]] List of route patterns to blacklist.
6
+ * @param {Object} [props.currentParams=null] Current route parameters.
7
+ * @param {string} [props.currentPathname=''] Current pathname.
8
+ * @param {Object} [props.currentRoute=null] Current route object.
9
+ * @param {boolean} props.isLoggedIn Whether the user is logged in.
10
+ * @param {Function} props.logout Logout function.
11
+ * @param {React.ReactNode} props.children Child components.
12
+ * @returns {JSX.Element} The rendered component.
13
+ */var SideNavigationProvider=function SideNavigationProvider(_ref){var maxCategoryNesting=_ref.maxCategoryNesting,routePatternBlacklist=_ref.routePatternBlacklist,currentParams=_ref.currentParams,currentPathname=_ref.currentPathname,currentRoute=_ref.currentRoute,isLoggedIn=_ref.isLoggedIn,logout=_ref.logout,children=_ref.children;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),activeCategoryId=_useState2[0],setActiveCategoryId=_useState2[1];var _useState3=useState(true),_useState4=_slicedToArray(_useState3,2),isVisible=_useState4[0],setIsVisible=_useState4[1];useEffect(function(){if(!currentRoute){return;}var pattern=currentRoute.pattern;if(categoryPatterns.includes(pattern)){var categoryId=currentParams.categoryId;setActiveCategoryId(hex2bin(categoryId));}else if(!itemPatterns.includes(pattern)){setActiveCategoryId(null);}setIsVisible(!routePatternBlacklist.includes(pattern));},[currentRoute,currentParams,routePatternBlacklist]);var value=useMemo(function(){return{maxCategoryNesting:maxCategoryNesting,currentParams:currentParams,currentPathname:currentPathname,currentRoute:currentRoute,isLoggedIn:isLoggedIn,logout:logout,activeCategoryId:activeCategoryId,isVisible:isVisible};},[activeCategoryId,currentParams,currentPathname,currentRoute,isLoggedIn,isVisible,logout,maxCategoryNesting]);return React.createElement(Context.Provider,{value:value},children);};SideNavigationProvider.defaultProps={currentParams:null,currentPathname:'',routePatternBlacklist:[],currentRoute:null};export default connect(SideNavigationProvider);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @typedef {Object} MerchantSettings
3
+ * @property {string[]} enabledFulfillmentMethods
4
+ * @property {string[]} enabledFulfillmentMethodSelectionForEngage
5
+ */ /**
6
+ * @typedef {Object} ShopSettings
7
+ * @property {string[]} [supportedCountries]
8
+ * @property {string[]} [countrySortOrder]
9
+ */ /**
10
+ * @typedef {Object} ConfigState
11
+ * @property {boolean} isFetching
12
+ * @property {number} expires
13
+ * @property {MerchantSettings} merchantSettings
14
+ * @property {ShopSettings} shopSettings
15
+ */
@@ -5,7 +5,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
5
5
  * @param {Function} asyncFunction The function that will be executed to generate memoized output.
6
6
  * @param {Array} asyncFunctionDependencies
7
7
  * A list of dependencies (same behavior as with `React.useMemo`)
8
- * @param {Any} initialValue The initial value that is set before promise is fulfilled.
8
+ * @param {any} initialValue The initial value that is set before promise is fulfilled.
9
9
  * @returns {Array}
10
10
  */export function useAsyncMemo(asyncFunction){var asyncFunctionDependencies=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var initialValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var _React$useState=React.useState(initialValue),_React$useState2=_slicedToArray(_React$useState,2),value=_React$useState2[0],setValue=_React$useState2[1];var _React$useState3=React.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),error=_React$useState4[0],setError=_React$useState4[1];/* eslint-disable react-hooks/exhaustive-deps */React.useEffect(function(){/**
11
11
  * Wraps the async function as React doesn't allow direct async usage.
@@ -1,6 +1,6 @@
1
1
  import{useMemo}from'react';import{getCountryNames}from"./countries.helpers";/**
2
- * Returns the countries names as key value pairs.
3
- * @param {string[]} [countryCodes=[]] .
4
- * @param {Object} [defaultLocales={}] Default locales from third party.
5
- * @returns {Object|null}
6
- */export function useCountriesNames(){var countryCodes=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var defaultLocales=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return useMemo(function(){return getCountryNames(countryCodes,defaultLocales);},[countryCodes,defaultLocales]);}
2
+ * Custom hook to get country names as key-value pairs.
3
+ * @param {string[]} [countryCodes=[]] An array of country codes.
4
+ * @param {Object} [defaultLocales={}] Default locales from third-party sources.
5
+ * @returns {Object|null} An object containing country names as key-value pairs.
6
+ */export var useCountriesNames=function useCountriesNames(){var countryCodes=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var defaultLocales=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return useMemo(function(){return getCountryNames(countryCodes,defaultLocales);},[countryCodes,defaultLocales]);};
@@ -1,7 +1,14 @@
1
1
  import{SET_USER_SEARCH_COUNTRY_CODE}from"../constants";/**
2
+ * @typedef {Object} SetUserSearchCountryCodeActionType
3
+ * @property {string} type The action type.
4
+ * @property {string} countryCode The country code.
5
+ * @property {string|null} productId The product ID.
6
+ * @property {boolean} isStoreFinder Indicates if the action was dispatched for the store finder.
7
+ */ /**
2
8
  * Creates the dispatched SET_USER_SEARCH_COUNTRY_CODE action object.
3
- * @param {string} countryCode The countryCode.
4
- * @param {string} [productId=null] An optional product code.
5
- * @param {boolean} [isStoreFinder=false] Was the actions dispatched for the store finder
6
- * @returns {Object}
9
+ * @param {string} countryCode The country code.
10
+ * @param {string|null} [productId=null] An optional product code.
11
+ * @param {boolean} [isStoreFinder=false]
12
+ * Indicates if the action was dispatched for the store finder.
13
+ * @returns {SetUserSearchCountryCodeActionType} The action object.
7
14
  */var setUserSearchCountryCode=function setUserSearchCountryCode(countryCode){var productId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var isStoreFinder=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return{type:SET_USER_SEARCH_COUNTRY_CODE,countryCode:countryCode,productId:productId,isStoreFinder:isStoreFinder};};export default setUserSearchCountryCode;
@@ -1,7 +1,14 @@
1
1
  import{SET_USER_SEARCH_POSTAL_CODE}from"../constants";/**
2
+ * @typedef {Object} SetUserSearchPostalCodeActionType
3
+ * @property {string} type The action type.
4
+ * @property {string|null} postalCode The postal code.
5
+ * @property {string|null} productId The product ID.
6
+ * @property {boolean} isStoreFinder Indicates if the action was dispatched for the store finder.
7
+ */ /**
2
8
  * Creates the dispatched SET_USER_SEARCH_POSTAL_CODE action object.
3
- * @param {string} postalCode The postalCode.
4
- * @param {string} [productId=null] An optional product code.
5
- * @param {boolean} [isStoreFinder=false] Was the actions dispatched for the store finder
6
- * @returns {Object}
9
+ * @param {string|null} postalCode The postal code.
10
+ * @param {string|null} [productId=null] An optional product code.
11
+ * @param {boolean} [isStoreFinder=false]
12
+ * Indicates if the action was dispatched for the store finder.
13
+ * @returns {SetUserSearchPostalCodeActionType} The action object.
7
14
  */var setUserSearchPostalCode=function setUserSearchPostalCode(postalCode){var productId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var isStoreFinder=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return{type:SET_USER_SEARCH_POSTAL_CODE,postalCode:postalCode,productId:productId,isStoreFinder:isStoreFinder};};export default setUserSearchPostalCode;
@@ -1,4 +1,7 @@
1
1
  import{connect}from'react-redux';import{fetchProductLocations}from"../../actions";/**
2
+ * @typedef {import('./CartChangeFulfillmentMethod.types').OwnProps} OwnProps
3
+ * @typedef {import('./CartChangeFulfillmentMethod.types').DispatchProps} DispatchProps
4
+ */ /**
2
5
  * @param {Function} dispatch The redux dispatch function.
3
- * @return {Object} The extended component props.
6
+ * @returns {DispatchProps} The extended component props.
4
7
  */var mapDispatchToProps={fetchProductLocations:fetchProductLocations};export default connect(null,mapDispatchToProps);
@@ -1,8 +1,11 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import*as React from'react';import{FulfillmentSheet}from"../FulfillmentSheet";import connect from"./CartChangeFulfillmentMethod.connector";import{STAGE_FULFILLMENT_METHOD}from"../../constants";/**
2
- * @param {Object} props The component props.
3
- * @returns {JSX.Element}
4
- */function CartChangeFulfillmentMethod(props){var cartItem=props.cartItem,fetchProductLocations=props.fetchProductLocations,registerAction=props.registerAction;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),opened=_React$useState2[0],setOpened=_React$useState2[1];/**
5
- * Register cart item action
6
- */React.useEffect(function(){if(!registerAction||!cartItem){return;}registerAction('changeFulfillment',function(){fetchProductLocations(cartItem.product.id);setOpened(true);});},[cartItem,fetchProductLocations,registerAction]);/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useEffect,useState}from'react';import PropTypes from'prop-types';import{FulfillmentSheet}from"../FulfillmentSheet";import connect from"./CartChangeFulfillmentMethod.connector";import{STAGE_FULFILLMENT_METHOD}from"../../constants";/**
2
+ * @typedef {import('./CartChangeFulfillmentMethod.types').OwnProps} OwnProps
3
+ * @typedef {import('./CartChangeFulfillmentMethod.types').DispatchProps} DispatchProps
4
+ * @typedef {OwnProps & DispatchProps} Props
5
+ */ /**
6
+ * Renders the CartChangeFulfillmentMethod component.
7
+ * @param {Props} props The component props.
8
+ * @returns {JSX.Element|null}
9
+ */var CartChangeFulfillmentMethod=function CartChangeFulfillmentMethod(_ref){var cartItem=_ref.cartItem,fetchProductLocations=_ref.fetchProductLocations,registerAction=_ref.registerAction;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),opened=_useState2[0],setOpened=_useState2[1];useEffect(function(){if(!registerAction||!cartItem){return;}registerAction('changeFulfillment',function(){fetchProductLocations(cartItem.product.id);setOpened(true);});},[cartItem,fetchProductLocations,registerAction]);/**
7
10
  * Handles closing of the sheet.
8
- */function handleClose(){setOpened(false);}if(!opened){return null;}return React.createElement(FulfillmentSheet,{open:true,productId:cartItem.product.id,stage:STAGE_FULFILLMENT_METHOD,meta:{cartItem:cartItem},onClose:handleClose,updatePreferredLocation:true});}export default connect(CartChangeFulfillmentMethod);
11
+ */function handleClose(){setOpened(false);}if(!opened){return null;}return React.createElement(FulfillmentSheet,{open:true,productId:cartItem.product.id,stage:STAGE_FULFILLMENT_METHOD,meta:{cartItem:cartItem},onClose:handleClose,updatePreferredLocation:true});};CartChangeFulfillmentMethod.defaultProps={registerAction:null};export default connect(CartChangeFulfillmentMethod);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @typedef {import('../../../cart/cart.types').Item} Item
3
+ */ /**
4
+ * @typedef OwnProps
5
+ * @property {Item} cartItem
6
+ * @property {Function} [registerAction]
7
+ */ /**
8
+ * @typedef DispatchProps
9
+ * @property {Function} fetchProductLocations
10
+ */
@@ -1,6 +1,11 @@
1
- import React,{useMemo}from'react';import{hot}from'react-hot-loader/root';import{FulfillmentProvider}from"../../providers";import{FulfillmentSheetContent}from"../FulfillmentSheet/FulfillmentSheetContent";import CartContextMenuChangeFulfillmentContent from"./CartContextMenuChangeFulfillmentContent";/**
2
- * The CartContextMenuChangeFulfillmentContent component renders a context menu which enables
1
+ import React,{useMemo}from'react';import PropTypes from'prop-types';import{hot}from'react-hot-loader/root';import{FulfillmentProvider}from"../../providers";import{FulfillmentSheetContent}from"../FulfillmentSheet/FulfillmentSheetContent";import CartContextMenuChangeFulfillmentContent from"./CartContextMenuChangeFulfillmentContent";/**
2
+ * @typedef {import('../../../cart/cart.types').Item} Item
3
+ */ /**
4
+ * @typedef {Object} Props
5
+ * @property {Item} cartItem
6
+ */ /**
7
+ * The CartContextMenuChangeFulfillment component renders a context menu which enables
3
8
  * switching the active fulfillment method for a cart item.
4
- * @param {Object} props The component props.
5
- * @returns {JSX}
9
+ * @param {Props} props The component props.
10
+ * @returns {JSX.Element}
6
11
  */var CartContextMenuChangeFulfillment=function CartContextMenuChangeFulfillment(_ref){var cartItem=_ref.cartItem;var contextProps=useMemo(function(){return{productId:cartItem.product.id,meta:{cartItem:cartItem},updatePreferredLocation:true};},[cartItem]);return React.createElement(FulfillmentProvider,contextProps,React.createElement(CartContextMenuChangeFulfillmentContent,null),React.createElement(FulfillmentSheetContent,null));};export default hot(CartContextMenuChangeFulfillment);
@@ -1,7 +1,8 @@
1
- import*as React from'react';import noop from'lodash/noop';import{I18n,ContextMenu}from'@shopgate/engage/components';import{DIRECT_SHIP}from"../../constants";/**
1
+ import React from'react';import PropTypes from'prop-types';import noop from'lodash/noop';import{I18n,ContextMenu}from'@shopgate/engage/components';import{DIRECT_SHIP}from"../../constants";/**
2
+ * Renders the cart context menu item for changing the location.
2
3
  * @param {Object} props The component props.
3
- * @property {Object} props.cartItem cartItem
4
- * @property {Function} props.onClick onClick
5
- * @property {Function} props.closeMenu closeMenu
6
- * @returns {JSX}
7
- */export var CartContextMenuItemChangeLocation=function CartContextMenuItemChangeLocation(props){var cartItem=props.cartItem,onClick=props.onClick,closeMenu=props.closeMenu;if(!cartItem.fulfillment||cartItem.fulfillment.method===DIRECT_SHIP){return null;}return React.createElement(ContextMenu.Item,{onClick:onClick,closeMenu:closeMenu},React.createElement(I18n.Text,{string:"locations.change_location"}));};CartContextMenuItemChangeLocation.defaultProps={onClick:noop,closeMenu:noop};
4
+ * @param {Object} props.cartItem The cart item.
5
+ * @param {Function} [props.onClick=noop] The click handler.
6
+ * @param {Function} [props.closeMenu=noop] The menu close handler.
7
+ * @returns {JSX.Element|null} The rendered component or null.
8
+ */export var CartContextMenuItemChangeLocation=function CartContextMenuItemChangeLocation(_ref){var cartItem=_ref.cartItem,onClick=_ref.onClick,closeMenu=_ref.closeMenu;if(!cartItem.fulfillment||cartItem.fulfillment.method===DIRECT_SHIP){return null;}return React.createElement(ContextMenu.Item,{onClick:onClick,closeMenu:closeMenu},React.createElement(I18n.Text,{string:"locations.change_location"}));};CartContextMenuItemChangeLocation.defaultProps={onClick:noop,closeMenu:noop};
@@ -1,5 +1,8 @@
1
- import*as Redux from'redux';import{connect}from'react-redux';import{updateProductsInCart}from'@shopgate/engage/cart';import{fetchProductLocations}from"../../actions";/**
1
+ import{connect}from'react-redux';import{updateProductsInCart}from'@shopgate/engage/cart';import{fetchProductLocations}from"../../actions";/**
2
+ * @typedef {import('./CartItemProductChangeLocation.types').OwnProps} OwnProps
3
+ * @typedef {import('./CartItemProductChangeLocation.types').DispatchProps} DispatchProps
4
+ */ /**
2
5
  * Connects the dispatch function to a callable function in the props.
3
6
  * @param {Function} dispatch The redux dispatch function.
4
- * @return {Object} The extended component props.
7
+ * @returns {DispatchProps} The extended component props.
5
8
  */var mapDispatchToProps=function mapDispatchToProps(dispatch){return{fetchProductLocations:fetchProductLocations,updateProductInCart:function updateProductInCart(cartItemId,quantity,location,fulfillmentMethod){dispatch(updateProductsInCart([{cartItemId:cartItemId,quantity:quantity,fulfillment:{method:fulfillmentMethod,location:{code:location.code,name:location.name}}}]));}};};export default connect(null,mapDispatchToProps);
@@ -1,11 +1,14 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import*as React from'react';import noop from'lodash/noop';import{FulfillmentSheet}from"../FulfillmentSheet";import{isProductAvailable}from"../../helpers";import{STAGE_SELECT_STORE}from"../../constants";import connect from"./CartItemProductChangeLocation.connector";/**
2
- * @param {Object} props The component props.
3
- * @param {Object} cartItem cartItem
4
- * @param {Function} updateProduct updateProduct
5
- * @param {Function} fetchProductLocations fetchProductLocations
6
- * @returns {JSX}
7
- */var CartItemProductChangeLocation=function CartItemProductChangeLocation(props){var cartItem=props.cartItem,updateProductInCart=props.updateProductInCart,fetchProductLocations=props.fetchProductLocations,registerAction=props.registerAction;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),opened=_React$useState2[0],setOpened=_React$useState2[1];var _React$useState3=React.useState(null),_React$useState4=_slicedToArray(_React$useState3,2),fulfillmentMethod=_React$useState4[0],setFulfillmentMethod=_React$useState4[1];/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import noop from'lodash/noop';import React,{useEffect,useState,useCallback}from'react';import PropTypes from'prop-types';import{FulfillmentSheet}from"../FulfillmentSheet";import{isProductAvailable}from"../../helpers";import{STAGE_SELECT_STORE}from"../../constants";import connect from"./CartItemProductChangeLocation.connector";/**
2
+ * @typedef {import('./CartItemProductChangeLocation.types').OwnProps} OwnProps
3
+ * @typedef {import('./CartItemProductChangeLocation.types').DispatchProps} DispatchProps
4
+ */ /**
5
+ * @typedef {OwnProps & DispatchProps} Props
6
+ */ /**
7
+ * @param {Props} props The component props.
8
+ * @returns {JSX.Element|null}
9
+ */var CartItemProductChangeLocation=function CartItemProductChangeLocation(props){var cartItem=props.cartItem,updateProductInCart=props.updateProductInCart,fetchProductLocations=props.fetchProductLocations,registerAction=props.registerAction;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),opened=_useState2[0],setOpened=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),fulfillmentMethod=_useState4[0],setFulfillmentMethod=_useState4[1];/**
8
10
  * Register cart item action
9
- */React.useEffect(function(){if(!registerAction||!cartItem){return;}registerAction('changeLocation',function(currentFulfillmentMethod){fetchProductLocations(cartItem.product.id);setOpened(true);setFulfillmentMethod(currentFulfillmentMethod);});},[cartItem,fetchProductLocations,registerAction]);/**
11
+ */useEffect(function(){if(!registerAction||!cartItem){return;}registerAction('changeLocation',function(currentFulfillmentMethod){fetchProductLocations(cartItem.product.id);setOpened(true);setFulfillmentMethod(currentFulfillmentMethod);});},[cartItem,fetchProductLocations,registerAction]);/**
10
12
  * Select location callback
11
- */var onLocationSelect=React.useCallback(function(location){setTimeout(function(){return setOpened(false);},500);if(!location||!isProductAvailable(location,location===null||location===void 0?void 0:location.inventory)){return;}updateProductInCart(cartItem.id,cartItem.quantity,location,fulfillmentMethod);setFulfillmentMethod(fulfillmentMethod);},[cartItem.id,cartItem.quantity,fulfillmentMethod,updateProductInCart]);var fulfillment=cartItem.fulfillment;if(!opened||!fulfillment){return null;}return React.createElement(FulfillmentSheet,{stage:STAGE_SELECT_STORE,open:true,title:"locations.headline",changeOnly:true,productId:cartItem.product.id,updatePreferredLocation:true,onClose:onLocationSelect,isCart:true});};CartItemProductChangeLocation.defaultProps={registerAction:noop};export default connect(CartItemProductChangeLocation);
13
+ * @param {Object|null} location
14
+ */var onLocationSelect=useCallback(function(location){setTimeout(function(){return setOpened(false);},500);if(!location||!isProductAvailable(location,location===null||location===void 0?void 0:location.inventory)){return;}updateProductInCart(cartItem.id,cartItem.quantity,location,fulfillmentMethod);setFulfillmentMethod(fulfillmentMethod);},[cartItem.id,cartItem.quantity,fulfillmentMethod,updateProductInCart]);var fulfillment=cartItem.fulfillment;if(!opened||!fulfillment){return null;}return React.createElement(FulfillmentSheet,{stage:STAGE_SELECT_STORE,open:true,title:"locations.headline",changeOnly:true,productId:cartItem.product.id,updatePreferredLocation:true,onClose:onLocationSelect,isCart:true});};CartItemProductChangeLocation.defaultProps={registerAction:noop};export default connect(CartItemProductChangeLocation);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @typedef {Object} OwnProps
3
+ * @property {Object} cartItem
4
+ * @property {Function} [registerAction]
5
+ */ /**
6
+ * @typedef {Object} DispatchProps
7
+ * @property {Function} fetchProductLocations
8
+ * @property {Function} updateProductInCart
9
+ */
@@ -1,4 +1,7 @@
1
- import React from'react';import{RippleButton,I18n,SurroundPortals}from'@shopgate/engage/components';import{button,ripple}from"./ChangeLocationButton.style";import{PRODUCT_FULFILLMENT_CHANGE_LOCATION}from"../../constants/Portals";/**
2
- * @param {Object} props .
3
- * @returns {JSX}
1
+ import React from'react';import PropTypes from'prop-types';import{RippleButton,I18n,SurroundPortals}from'@shopgate/engage/components';import{button,ripple}from"./ChangeLocationButton.style";import{PRODUCT_FULFILLMENT_CHANGE_LOCATION}from"../../constants/Portals";/**
2
+ * Renders the Change Location button.
3
+ * @param {Object} props The component props.
4
+ * @param {Function} props.onClick The click handler.
5
+ * @param {boolean} [props.disabled=false] Whether the button is disabled.
6
+ * @returns {JSX.Element} The rendered component.
4
7
  */export var ChangeLocationButtonUnwrapped=function ChangeLocationButtonUnwrapped(_ref){var onClick=_ref.onClick,disabled=_ref.disabled;return React.createElement(SurroundPortals,{portalName:PRODUCT_FULFILLMENT_CHANGE_LOCATION,portalProps:{onClick:onClick,disabled:disabled}},React.createElement(RippleButton,{onClick:onClick,className:button,disabled:disabled,rippleClassName:ripple,type:"secondary",flat:true},React.createElement(I18n.Text,{string:"locations.change_location"})));};ChangeLocationButtonUnwrapped.defaultProps={disabled:false};export var ChangeLocationButton=React.memo(ChangeLocationButtonUnwrapped);
@@ -1,6 +1,8 @@
1
- var _excluded=["name","children"];function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import*as React from'react';import{i18n}from"../../../core";import{RadioGroupItem}from"../../../components";import{radioItem,itemLabel}from"./FulfillmentPath.style";/**
1
+ var _excluded=["name","children"];function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React from'react';import PropTypes from'prop-types';import{i18n}from"../../../core";import{RadioGroupItem}from"../../../components";import{radioItem,itemLabel}from"./FulfillmentPath.style";/**
2
2
  * Renders a RadioItem element to be used by the FulfillmentPathSelector component.
3
- * This component is meant to be rendered as child of a RadioGroup.
4
- * @param {Object} props All props required by the RadioGroupItem component to work.
5
- * @returns {JSX}
3
+ * This component is meant to be rendered as a child of a RadioGroup.
4
+ * @param {Object} props The component props required by the RadioGroupItem component.
5
+ * @param {React.ReactNode|null} [props.children=null] The child elements.
6
+ * @param {string} props.name The name of the radio item.
7
+ * @returns {JSX.Element} The rendered component.
6
8
  */export var FulfillmentPathItem=function FulfillmentPathItem(_ref){var name=_ref.name,children=_ref.children,rest=_objectWithoutProperties(_ref,_excluded);return React.createElement(RadioGroupItem,_extends({},rest,{name:name,className:radioItem,label:React.createElement("div",{className:itemLabel},React.createElement("span",null,i18n.text(name)),children)}));};FulfillmentPathItem.defaultProps={children:null};
@@ -1,9 +1,23 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{connect}from'react-redux';import{hasProductVariants,isProductOrderable,makeIsBaseProductActive}from'@shopgate/engage/product';import{DIRECT_SHIP,ROPIS,BOPIS}from"../../constants";import{makeGetEnabledFulfillmentMethods,makeGetFulfillmentPaths,makeUseLocationFulfillmentMethods}from"../../../core/config";import{getProductShowAlternativeLocation}from"../../../core/selectors";import{MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION}from"../../../core/constants";import{makeIsFulfillmentSelectorMethodEnabled,getPreferredLocation,makeGetLocationInventory,makeGetLocationFulfillmentMethods,getPreferredFulfillmentMethod,getProductFulfillmentMethods,getUserSearch}from"../../selectors";import{storeFulfillmentMethod}from"../../action-creators";/**
2
- * @return {Function} The extended component props.
3
- */function makeMapStateToProps(){/* eslint-disable require-jsdoc */var getLocationCode=function getLocationCode(state,props){var _getPreferredLocation;return(_getPreferredLocation=getPreferredLocation(state,props))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code;};var getProductCode=function getProductCode(_,props){return props.variantId||props.productId||null;};/* eslint-enable require-jsdoc */var getFulfillmentPaths=makeGetFulfillmentPaths();var isDirectShipEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,DIRECT_SHIP);var isROPISEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,ROPIS,// Set to true when fulfillment methods shall not be disabled that are not supported by location
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{connect}from'react-redux';import{hasProductVariants,isProductOrderable,makeIsBaseProductActive}from'@shopgate/engage/product';import{DIRECT_SHIP,ROPIS,BOPIS}from"../../constants";import{makeGetEnabledFulfillmentMethods,makeGetFulfillmentPaths,makeUseLocationFulfillmentMethods}from"../../../core/config";import{getProductShowAlternativeLocation}from"../../../core/selectors";import{MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION}from"../../../core/constants";import{makeIsFulfillmentSelectorMethodEnabled,getPreferredLocation,makeGetLocationInventory,makeGetLocationFulfillmentMethods,getPreferredFulfillmentMethod,getProductFulfillmentMethods,getUserSearch}from"../../selectors";import{storeFulfillmentMethod}from"../../action-creators";/* eslint-disable max-len */ /** @typedef {import('./FulfillmentSelector.types').OwnProps} OwnProps */ /** @typedef {import('./FulfillmentSelector.types').StateProps} StateProps */ /** @typedef {import('./FulfillmentSelector.types').DispatchProps} DispatchProps */ /**
2
+ * Maps state to props for the component.
3
+ * @returns {function(state: any, props: OwnProps): StateProps} A function that maps state and props to StateProps.
4
+ */var makeMapStateToProps=function makeMapStateToProps(){/**
5
+ * Retrieves the location code based on the state and props.
6
+ * @param {any} state The application state.
7
+ * @param {OwnProps} props The component props.
8
+ * @returns {string|null} The location code.
9
+ */var getLocationCode=function getLocationCode(state,props){var _getPreferredLocation;return(_getPreferredLocation=getPreferredLocation(state,props))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code;};/**
10
+ * Retrieves the product code based on the props.
11
+ * @param {any} _ Unused state parameter.
12
+ * @param {OwnProps} props The component props.
13
+ * @returns {string|null} The product code.
14
+ */var getProductCode=function getProductCode(_,props){return props.variantId||props.productId||null;};var getFulfillmentPaths=makeGetFulfillmentPaths();var isDirectShipEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,DIRECT_SHIP);var isROPISEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,ROPIS,// Set to true when fulfillment methods shall not be disabled that are not supported by location
4
15
  false);var isBOPISEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,BOPIS,// Set to true when fulfillment methods shall not be disabled that are not supported by location
5
16
  false);var getInventory=makeGetLocationInventory(getLocationCode,getProductCode);var getEnabledFulfillmentMethods=makeGetEnabledFulfillmentMethods();var getLocationFulfillmentMethods=makeGetLocationFulfillmentMethods(getLocationCode);var isBaseProductActive=makeIsBaseProductActive();var useLocationFulfillmentMethods=makeUseLocationFulfillmentMethods();/**
6
17
  * @param {Object} state The application state.
7
- * @param {Object} props The component props.
8
- * @returns {Object}
9
- */return function(state,props){var hasVariants=hasProductVariants(state,props);var baseProductActive=isBaseProductActive(state,props);return{merchantSettings:_defineProperty({},MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,getProductShowAlternativeLocation(state)),fulfillmentPaths:getFulfillmentPaths(state),shopFulfillmentMethods:getEnabledFulfillmentMethods(state),productFulfillmentMethods:getProductFulfillmentMethods(state,props),locationFulfillmentMethods:getLocationFulfillmentMethods(state,props),useLocationFulfillmentMethods:useLocationFulfillmentMethods(state,props),userFulfillmentMethod:getPreferredFulfillmentMethod(state,props),preferredLocation:getPreferredLocation(state,props),inventory:getInventory(state,props),isDirectShipEnabled:isDirectShipEnabled(state,props),isROPISEnabled:isROPISEnabled(state,props),isBOPISEnabled:isBOPISEnabled(state,props),isOrderable:isProductOrderable(state,props)||!!hasVariants,isReady:hasVariants!==null&&(!hasVariants||!baseProductActive),userSearch:getUserSearch(state)};};}var mapDispatchToProps={storeFulfillmentMethod:storeFulfillmentMethod};export default connect(makeMapStateToProps,mapDispatchToProps);
18
+ * @param {OwnProps} props The component props.
19
+ * @returns {StateProps} The mapped state props.
20
+ */return function(state,props){var hasVariants=hasProductVariants(state,props);var baseProductActive=isBaseProductActive(state,props);return{merchantSettings:_defineProperty({},MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,getProductShowAlternativeLocation(state)),fulfillmentPaths:getFulfillmentPaths(state),shopFulfillmentMethods:getEnabledFulfillmentMethods(state),productFulfillmentMethods:getProductFulfillmentMethods(state,props),locationFulfillmentMethods:getLocationFulfillmentMethods(state,props),useLocationFulfillmentMethods:useLocationFulfillmentMethods(state,props),userFulfillmentMethod:getPreferredFulfillmentMethod(state,props),preferredLocation:getPreferredLocation(state,props),inventory:getInventory(state,props),isDirectShipEnabled:isDirectShipEnabled(state,props),isROPISEnabled:isROPISEnabled(state,props),isBOPISEnabled:isBOPISEnabled(state,props),isOrderable:isProductOrderable(state,props)||!!hasVariants,isReady:hasVariants!==null&&(!hasVariants||!baseProductActive),userSearch:getUserSearch(state)};};};/* eslint-enable max-len */ /**
21
+ * Maps dispatch actions to props for the component.
22
+ * @type {DispatchProps}
23
+ */var mapDispatchToProps={storeFulfillmentMethod:storeFulfillmentMethod};export default connect(makeMapStateToProps,mapDispatchToProps);
@@ -1 +1,2 @@
1
- import{createContext}from'react';import{DIRECT_SHIP}from"../../constants";export var FulfillmentSelectorContext=createContext({selection:DIRECT_SHIP,selectedLocation:null,location:null,isDirectShipEnabled:false,isROPISEnabled:false,isBOPISEnabled:false,isReady:false,productId:null,handleChange:function handleChange(){},conditioner:{},fulfillmentPaths:[],userFulfillmentMethod:null,isOrderable:false,shopFulfillmentMethods:null,productFulfillmentMethods:null,locationFulfillmentMethods:null,useLocationFulfillmentMethods:false,merchantSettings:null});
1
+ // eslint-disable-next-line max-len
2
+ /** @typedef {import('./FulfillmentSelector.types').FulfillmentSelectorContextProps} FulfillmentSelectorContextProps */import{createContext}from'react';import{DIRECT_SHIP}from"../../constants";/** @type {FulfillmentSelectorContextProps} */export var FulfillmentSelectorContext=createContext({selection:DIRECT_SHIP,selectedLocation:null,location:null,isDirectShipEnabled:false,isROPISEnabled:false,isBOPISEnabled:false,isReady:false,productId:null,handleChange:function handleChange(){},conditioner:{},fulfillmentPaths:[],userFulfillmentMethod:null,isOrderable:false,shopFulfillmentMethods:null,productFulfillmentMethods:null,locationFulfillmentMethods:null,useLocationFulfillmentMethods:false,merchantSettings:null});
@@ -1,3 +1,4 @@
1
- import{useContext}from'react';import{FulfillmentSelectorContext}from"./FulfillmentSelector.context";/**
2
- * @returns {Object} The fulfillment selector context.
1
+ // eslint-disable-next-line max-len
2
+ /** @typedef {import('./FulfillmentSelector.types').FulfillmentSelectorContextProps} FulfillmentSelectorContextProps */import{useContext}from'react';import{FulfillmentSelectorContext}from"./FulfillmentSelector.context";/**
3
+ * @returns {FulfillmentSelectorContextProps} The fulfillment selector context.
3
4
  */export function useFulfillmentSelectorState(){return useContext(FulfillmentSelectorContext);}
@@ -1,20 +1,11 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{hot}from'react-hot-loader/root';import React,{useState,useEffect,useCallback,useMemo}from'react';import{SurroundPortals}from"../../../components";import{DIRECT_SHIP,ROPIS,BOPIS,STAGE_SELECT_STORE,PRODUCT_FULFILLMENT_SELECTOR}from"../../constants";import{FulfillmentSheet}from"../FulfillmentSheet";import{FulfillmentSelectorContext}from"./FulfillmentSelector.context";import{FulfillmentSelectorHeader}from"./FulfillmentSelectorHeader";import{FulfillmentSelectorItem}from"./FulfillmentSelectorItem";import{FulfillmentSelectorDirectShip}from"./FulfillmentSelectorDirectShip";import{FulfillmentSelectorBOPIS}from"./FulfillmentSelectorBOPIS";import{FulfillmentSelectorROPIS}from"./FulfillmentSelectorROPIS";import{FulfillmentSelectorAddToCart}from"./FulfillmentSelectorAddToCart";import{FulfillmentSelectorLocation}from"./FulfillmentSelectorLocation";import{container}from"./FulfillmentSelector.style";import connect from"./FulfillmentSelector.connector";/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{hot}from'react-hot-loader/root';import React,{useState,useEffect,useCallback,useMemo}from'react';import PropTypes from'prop-types';import{SurroundPortals}from"../../../components";import{DIRECT_SHIP,ROPIS,BOPIS,STAGE_SELECT_STORE,PRODUCT_FULFILLMENT_SELECTOR}from"../../constants";import{FulfillmentSheet}from"../FulfillmentSheet";import{FulfillmentSelectorContext}from"./FulfillmentSelector.context";import{FulfillmentSelectorHeader}from"./FulfillmentSelectorHeader";import{FulfillmentSelectorItem}from"./FulfillmentSelectorItem";import{FulfillmentSelectorDirectShip}from"./FulfillmentSelectorDirectShip";import{FulfillmentSelectorBOPIS}from"./FulfillmentSelectorBOPIS";import{FulfillmentSelectorROPIS}from"./FulfillmentSelectorROPIS";import{FulfillmentSelectorAddToCart}from"./FulfillmentSelectorAddToCart";import{FulfillmentSelectorLocation}from"./FulfillmentSelectorLocation";import{container}from"./FulfillmentSelector.style";import connect from"./FulfillmentSelector.connector";/* eslint-disable max-len */ /** @typedef {import('./FulfillmentSelector.types').FulfillmentSelectorContextProps} FulfillmentSelectorContextProps */ /** @typedef {import('./FulfillmentSelector.types').OwnProps} OwnProps */ /** @typedef {import('./FulfillmentSelector.types').StateProps} StateProps */ /** @typedef {import('./FulfillmentSelector.types').DispatchProps} DispatchProps */ /** @typedef {import('../../locations.types').UserLocationFulfillmentMethod} UserLocationFulfillmentMethod */ /* eslint-enable max-len */ /**
2
+ * @typedef {OwnProps & StateProps & DispatchProps} Props
3
+ */ /**
2
4
  * Renders the fulfillment selector radio button group.
3
- * @param {Object} props The component props.
4
- * @returns {JSX}
5
- */function FulfillmentSelector(props){var productId=props.productId,merchantSettings=props.merchantSettings,shopFulfillmentMethods=props.shopFulfillmentMethods,productFulfillmentMethods=props.productFulfillmentMethods,locationFulfillmentMethods=props.locationFulfillmentMethods,useLocationFulfillmentMethods=props.useLocationFulfillmentMethods,preferredLocation=props.preferredLocation,inventory=props.inventory,conditioner=props.conditioner,isDirectShipEnabled=props.isDirectShipEnabled,isROPISEnabled=props.isROPISEnabled,isBOPISEnabled=props.isBOPISEnabled,storeFulfillmentMethod=props.storeFulfillmentMethod,userFulfillmentMethod=props.userFulfillmentMethod,fulfillmentPaths=props.fulfillmentPaths,isOrderable=props.isOrderable,isReady=props.isReady;var _useState=useState(userFulfillmentMethod),_useState2=_slicedToArray(_useState,2),selection=_useState2[0],setSelection=_useState2[1];var _useState3=useState(preferredLocation),_useState4=_slicedToArray(_useState3,2),selectedLocation=_useState4[0],setSelectedLocation=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isOpen=_useState6[0],setIsOpen=_useState6[1];var usedLocation=selectedLocation||preferredLocation;// Initialize fo selection once it is available.
5
+ * @param {Props} props The component props.
6
+ * @returns {JSX.Element|null}
7
+ */var FulfillmentSelector=function FulfillmentSelector(props){var productId=props.productId,merchantSettings=props.merchantSettings,shopFulfillmentMethods=props.shopFulfillmentMethods,productFulfillmentMethods=props.productFulfillmentMethods,locationFulfillmentMethods=props.locationFulfillmentMethods,useLocationFulfillmentMethods=props.useLocationFulfillmentMethods,preferredLocation=props.preferredLocation,inventory=props.inventory,conditioner=props.conditioner,isDirectShipEnabled=props.isDirectShipEnabled,isROPISEnabled=props.isROPISEnabled,isBOPISEnabled=props.isBOPISEnabled,storeFulfillmentMethod=props.storeFulfillmentMethod,userFulfillmentMethod=props.userFulfillmentMethod,fulfillmentPaths=props.fulfillmentPaths,isOrderable=props.isOrderable,isReady=props.isReady;var _useState=useState(userFulfillmentMethod),_useState2=_slicedToArray(_useState,2),selection=_useState2[0],setSelection=_useState2[1];var _useState3=useState(preferredLocation),_useState4=_slicedToArray(_useState3,2),selectedLocation=_useState4[0],setSelectedLocation=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isOpen=_useState6[0],setIsOpen=_useState6[1];var usedLocation=selectedLocation||preferredLocation;// Initialize fo selection once it is available.
6
8
  useEffect(function(){if(!selection&&userFulfillmentMethod){setSelection(userFulfillmentMethod);}},[selection,userFulfillmentMethod]);// Initialize location selection once it is available.
7
- useEffect(function(){if(!selectedLocation&&preferredLocation){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation]);var fulfillmentMethodFallback=useMemo(function(){if(!shopFulfillmentMethods){return null;}var states=[isDirectShipEnabled,isBOPISEnabled,isROPISEnabled];return[DIRECT_SHIP,BOPIS,ROPIS].find(function(method,index){return states[index]&&shopFulfillmentMethods.includes(method);})||null;},[isBOPISEnabled,isDirectShipEnabled,isROPISEnabled,shopFulfillmentMethods]);/**
9
+ useEffect(function(){if(!selectedLocation&&preferredLocation){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation]);/** @type {UserLocationFulfillmentMethod} */var fulfillmentMethodFallback=useMemo(function(){if(!shopFulfillmentMethods){return null;}var states=[isDirectShipEnabled,isBOPISEnabled,isROPISEnabled];return[DIRECT_SHIP,BOPIS,ROPIS].find(function(method,index){return states[index]&&shopFulfillmentMethods.includes(method);})||null;},[isBOPISEnabled,isDirectShipEnabled,isROPISEnabled,shopFulfillmentMethods]);/**
8
10
  * Determine and set a default fulfillment method when none was set before.
9
- */useEffect(function(){if(!shopFulfillmentMethods){return;}/**
10
- * The user has already set a fulfillment method which is supported by the shop, so we don't
11
- * need to apply the fallback. We don't check against the product fulfillment methods to
12
- * avoid too much auto magic when navigating through catalogs with different set up products.
13
- */if(userFulfillmentMethod&&shopFulfillmentMethods.includes(userFulfillmentMethod)){return;}if(fulfillmentMethodFallback!==userFulfillmentMethod){setSelection(fulfillmentMethodFallback);storeFulfillmentMethod(fulfillmentMethodFallback);}},[fulfillmentMethodFallback,isBOPISEnabled,isDirectShipEnabled,isROPISEnabled,shopFulfillmentMethods,storeFulfillmentMethod,userFulfillmentMethod]);useEffect(function(){if((preferredLocation===null||preferredLocation===void 0?void 0:preferredLocation.code)!==(selectedLocation===null||selectedLocation===void 0?void 0:selectedLocation.code)){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation,shopFulfillmentMethods]);/**
14
- * Updates the selected location when the sheet closes.
15
- */var handleClose=useCallback(function(newLocationData){setIsOpen(false);if(!newLocationData&&(!usedLocation||!usedLocation.code)){// Reset the UI back to directShip if there was no location selected already
16
- setSelection(fulfillmentMethodFallback);return;}if(newLocationData){// Update the selected location only when the selection was done for the same product.
17
- setSelectedLocation(newLocationData.location);}},[fulfillmentMethodFallback,usedLocation]);/**
18
- * Whenever the pick-up selection is made, open the
19
- * store selector sheet and use the new location.
20
- */var handleChange=useCallback(function(method){var changeOnly=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;conditioner.without('fulfillment-inventory').check().then(function(passed){if(!passed){return;}setSelection(method);storeFulfillmentMethod(method);var isValidRopeSelection=[ROPIS,BOPIS].includes(method)&&!!preferredLocation&&!!preferredLocation.code;if(!changeOnly&&(isOpen||isValidRopeSelection)){return;}if(method===DIRECT_SHIP){setSelectedLocation(null);return;}setIsOpen(true);FulfillmentSheet.open({stage:STAGE_SELECT_STORE,callback:handleClose,changeOnly:changeOnly});});},[conditioner,handleClose,isOpen,preferredLocation,storeFulfillmentMethod]);var shopHasRopeMethods=useMemo(function(){if(!Array.isArray(shopFulfillmentMethods)){return false;}return shopFulfillmentMethods.filter(function(method){return method!==DIRECT_SHIP;}).length>0;},[shopFulfillmentMethods]);if(!shopHasRopeMethods){return null;}var context={selection:selection,selectedLocation:selectedLocation,inventory:inventory,preferredLocation:preferredLocation,isDirectShipEnabled:isDirectShipEnabled,isBOPISEnabled:isBOPISEnabled,isROPISEnabled:isROPISEnabled,isReady:isReady,productId:productId,handleChange:handleChange,conditioner:conditioner,merchantSettings:merchantSettings,fulfillmentPaths:fulfillmentPaths,userFulfillmentMethod:userFulfillmentMethod,isOrderable:isOrderable,shopFulfillmentMethods:shopFulfillmentMethods,productFulfillmentMethods:productFulfillmentMethods,locationFulfillmentMethods:locationFulfillmentMethods,useLocationFulfillmentMethods:useLocationFulfillmentMethods};return React.createElement(FulfillmentSelectorContext.Provider,{value:context},React.createElement(SurroundPortals,{portalName:PRODUCT_FULFILLMENT_SELECTOR},React.createElement("div",{className:container,role:"radiogroup",tabIndex:"0"},React.createElement(FulfillmentSelectorHeader,null),shopFulfillmentMethods.includes(DIRECT_SHIP)&&React.createElement(FulfillmentSelectorItem,{name:DIRECT_SHIP,onChange:handleChange,disabled:!isReady||!isDirectShipEnabled},React.createElement(FulfillmentSelectorDirectShip,null)),shopFulfillmentMethods.includes(BOPIS)&&React.createElement(FulfillmentSelectorItem,{name:BOPIS,onChange:handleChange,disabled:!isReady||!isBOPISEnabled},React.createElement(FulfillmentSelectorBOPIS,null)),shopFulfillmentMethods.includes(ROPIS)&&React.createElement(FulfillmentSelectorItem,{name:ROPIS,onChange:handleChange,disabled:!isReady||!isROPISEnabled},React.createElement(FulfillmentSelectorROPIS,null)))),React.createElement(FulfillmentSelectorLocation,null),React.createElement(FulfillmentSelectorAddToCart,null));}export default hot(connect(React.memo(FulfillmentSelector)));
11
+ */useEffect(function(){if(!shopFulfillmentMethods){return;}if(userFulfillmentMethod&&shopFulfillmentMethods.includes(userFulfillmentMethod)){return;}if(fulfillmentMethodFallback!==userFulfillmentMethod){setSelection(fulfillmentMethodFallback);storeFulfillmentMethod(fulfillmentMethodFallback);}},[fulfillmentMethodFallback,isBOPISEnabled,isDirectShipEnabled,isROPISEnabled,shopFulfillmentMethods,storeFulfillmentMethod,userFulfillmentMethod]);useEffect(function(){if((preferredLocation===null||preferredLocation===void 0?void 0:preferredLocation.code)!==(selectedLocation===null||selectedLocation===void 0?void 0:selectedLocation.code)){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation,shopFulfillmentMethods]);var handleClose=useCallback(function(newLocationData){setIsOpen(false);if(!newLocationData&&(!usedLocation||!usedLocation.code)){setSelection(fulfillmentMethodFallback);return;}if(newLocationData){setSelectedLocation(newLocationData.location);}},[fulfillmentMethodFallback,usedLocation]);var handleChange=useCallback(function(method){var changeOnly=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;conditioner.without('fulfillment-inventory').check().then(function(passed){if(!passed){return;}setSelection(method);storeFulfillmentMethod(method);var isValidRopeSelection=[ROPIS,BOPIS].includes(method)&&!!preferredLocation&&!!preferredLocation.code;if(!changeOnly&&(isOpen||isValidRopeSelection)){return;}if(method===DIRECT_SHIP){setSelectedLocation(null);return;}setIsOpen(true);FulfillmentSheet.open({stage:STAGE_SELECT_STORE,callback:handleClose,changeOnly:changeOnly});});},[conditioner,handleClose,isOpen,preferredLocation,storeFulfillmentMethod]);var shopHasRopeMethods=useMemo(function(){if(!Array.isArray(shopFulfillmentMethods)){return false;}return shopFulfillmentMethods.filter(function(method){return method!==DIRECT_SHIP;}).length>0;},[shopFulfillmentMethods]);if(!shopHasRopeMethods){return null;}var context=/** @type {FulfillmentSelectorContextProps} */{selection:selection,selectedLocation:selectedLocation,inventory:inventory,preferredLocation:preferredLocation,isDirectShipEnabled:isDirectShipEnabled,isBOPISEnabled:isBOPISEnabled,isROPISEnabled:isROPISEnabled,isReady:isReady,productId:productId,handleChange:handleChange,conditioner:conditioner,merchantSettings:merchantSettings,fulfillmentPaths:fulfillmentPaths,userFulfillmentMethod:userFulfillmentMethod,isOrderable:isOrderable,shopFulfillmentMethods:shopFulfillmentMethods,productFulfillmentMethods:productFulfillmentMethods,locationFulfillmentMethods:locationFulfillmentMethods,useLocationFulfillmentMethods:useLocationFulfillmentMethods};return React.createElement(FulfillmentSelectorContext.Provider,{value:context},React.createElement(SurroundPortals,{portalName:PRODUCT_FULFILLMENT_SELECTOR},React.createElement("div",{className:container,role:"radiogroup",tabIndex:"0"},React.createElement(FulfillmentSelectorHeader,null),shopFulfillmentMethods.includes(DIRECT_SHIP)&&React.createElement(FulfillmentSelectorItem,{name:DIRECT_SHIP,onChange:handleChange,disabled:!isReady||!isDirectShipEnabled},React.createElement(FulfillmentSelectorDirectShip,null)),shopFulfillmentMethods.includes(BOPIS)&&React.createElement(FulfillmentSelectorItem,{name:BOPIS,onChange:handleChange,disabled:!isReady||!isBOPISEnabled},React.createElement(FulfillmentSelectorBOPIS,null)),shopFulfillmentMethods.includes(ROPIS)&&React.createElement(FulfillmentSelectorItem,{name:ROPIS,onChange:handleChange,disabled:!isReady||!isROPISEnabled},React.createElement(FulfillmentSelectorROPIS,null)))),React.createElement(FulfillmentSelectorLocation,null),React.createElement(FulfillmentSelectorAddToCart,null));};FulfillmentSelector.defaultProps={merchantSettings:null,shopFulfillmentMethods:null,productFulfillmentMethods:null,locationFulfillmentMethods:null,useLocationFulfillmentMethods:false,preferredLocation:null,inventory:null,userFulfillmentMethod:null};export default hot(connect(React.memo(FulfillmentSelector)));
@@ -1 +1 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var container=css({padding:"".concat(variables.gap.small,"px ").concat(variables.gap.big,"px")});
1
+ import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var container=css({padding:"".concat(variables.gap.small,"px ").concat(variables.gap.big,"px")}).toString();
@@ -1 +1,57 @@
1
- import{DIRECT_SHIP,ROPIS,BOPIS}from"../../constants";
1
+ /* eslint-disable max-len */ /** @typedef {import('../../locations.types').Location} Location */ /** @typedef {import('../../locations.types').UserLocationFulfillmentMethod} UserLocationFulfillmentMethod */ /**
2
+ * @typedef {(
3
+ * typeof import('../../constants').DIRECT_SHIP |
4
+ * typeof import('../../constants').ROPIS |
5
+ * typeof import('../../constants').BOPIS |
6
+ * null
7
+ * )} Selection
8
+ */ /**
9
+ * @typedef {Object} UserSearch
10
+ * @property {null} geolocation
11
+ * @property {null} postalCode
12
+ */ /**
13
+ * @typedef {Object} FulfillmentSelectorContextProps
14
+ * @property {Selection} selection
15
+ * @property {Location|null} selectedLocation
16
+ * @property {Location|null} [location]
17
+ * @property {boolean} isDirectShipEnabled
18
+ * @property {boolean} isROPISEnabled
19
+ * @property {boolean} isBOPISEnabled
20
+ * @property {boolean} isReady
21
+ * @property {string} productId
22
+ * @property {function(Selection, boolean): void} handleChange
23
+ * @property {any} conditioner
24
+ * @property {string[]} fulfillmentPaths
25
+ * @property {Object} merchantSettings
26
+ * @property {string|null} userFulfillmentMethod
27
+ * @property {boolean} isOrderable
28
+ * @property {string[]|null} [shopFulfillmentMethods]
29
+ * @property {string[]|null} productFulfillmentMethods
30
+ * @property {string[]|null} locationFulfillmentMethods
31
+ * @property {boolean} useLocationFulfillmentMethods
32
+ * @property {Object} [inventory]
33
+ * @property {Object} [preferredLocation]
34
+ */ /**
35
+ * @typedef {Object} OwnProps
36
+ * @property {any} conditioner
37
+ * @property {string} productId
38
+ */ /**
39
+ * @typedef {Object} StateProps
40
+ * @property {Object} [merchantSettings]
41
+ * @property {string[]|null} [shopFulfillmentMethods]
42
+ * @property {string[]|null} productFulfillmentMethods
43
+ * @property {string[]|null} locationFulfillmentMethods
44
+ * @property {boolean} useLocationFulfillmentMethods
45
+ * @property {boolean} isDirectShipEnabled
46
+ * @property {boolean} isROPISEnabled
47
+ * @property {boolean} isBOPISEnabled
48
+ * @property {Location|null} preferredLocation
49
+ * @property {Object} inventory
50
+ * @property {string|null} userFulfillmentMethod
51
+ * @property {string[]} fulfillmentPaths
52
+ * @property {boolean} isOrderable
53
+ * @property {boolean} isReady
54
+ */ /**
55
+ * @typedef {Object} DispatchProps
56
+ * @property {function(UserLocationFulfillmentMethod): void} storeFulfillmentMethod
57
+ */ /* eslint-enable max-len */