@shopgate/engage 7.3.3-beta.2 → 7.3.4-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.
@@ -1,5 +1,5 @@
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,useContext,useRef,useCallback}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{useScroll}from'@shopgate/engage/core';import{header,hidden}from"./style";import{ViewContext}from"../View";/**
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,useContext,useRef,useCallback,useEffect}from'react';import PropTypes from'prop-types';import classNames from'classnames';import get from'lodash/get';import{useScroll,hasWebBridge}from'@shopgate/engage/core';import{header,hidden}from"./style";import{ViewContext}from"../View";/**
2
2
  * Scroll Header component
3
3
  * @param {Object} props props
4
4
  * @returns {JSX}
5
- */function ScrollHeader(_ref){var className=_ref.className,children=_ref.children;var ref=useRef();var _useState=useState(false),_useState2=_slicedToArray(_useState,2),shouldHideHeader=_useState2[0],setShouldHideHeader=_useState2[1];var _useContext=useContext(ViewContext),contentRef=_useContext.contentRef;var _useState3=useState(0),_useState4=_slicedToArray(_useState3,2),offset=_useState4[0],setOffset=_useState4[1];var onScroll=useCallback(function(callbackData){var previousScrollTop=callbackData.previousScrollTop,currentScrollTop=callbackData.currentScrollTop;if(previousScrollTop!==currentScrollTop){var isScrolledDown=previousScrollTop<currentScrollTop;var box=ref.current.getBoundingClientRect();var stickHeader=currentScrollTop>=offset+100;if(!previousScrollTop){setOffset(currentScrollTop+box.top);}setShouldHideHeader(isScrolledDown&&stickHeader);}},[offset]);useScroll(onScroll,contentRef===null||contentRef===void 0?void 0:contentRef.current);return React.createElement("div",{ref:ref,className:classNames(header,shouldHideHeader&&hidden,className)},children);}ScrollHeader.defaultProps={className:null};export default ScrollHeader;
5
+ */function ScrollHeader(_ref){var className=_ref.className,children=_ref.children;var ref=useRef();var _useState=useState(false),_useState2=_slicedToArray(_useState,2),shouldHideHeader=_useState2[0],setShouldHideHeader=_useState2[1];var _useContext=useContext(ViewContext),contentRef=_useContext.contentRef;var _useState3=useState(0),_useState4=_slicedToArray(_useState3,2),offset=_useState4[0],setOffset=_useState4[1];var _useState5=useState(0),_useState6=_slicedToArray(_useState5,2),offsetTop=_useState6[0],setOffsetTop=_useState6[1];var onScroll=useCallback(function(callbackData){var previousScrollTop=callbackData.previousScrollTop,currentScrollTop=callbackData.currentScrollTop;if(previousScrollTop!==currentScrollTop){var isScrolledDown=previousScrollTop<currentScrollTop;var box=ref.current.getBoundingClientRect();var stickHeader=currentScrollTop>=offset+100;if(!previousScrollTop){setOffset(currentScrollTop+box.top);}setShouldHideHeader(isScrolledDown&&stickHeader);}},[offset]);useScroll(onScroll,contentRef===null||contentRef===void 0?void 0:contentRef.current);useEffect(function(){if(!hasWebBridge()){var currentOffset=get(ref,'current.offsetTop');setOffsetTop(currentOffset);}},[]);return React.createElement("div",{ref:ref,className:classNames(header,shouldHideHeader&&hidden,className),style:offsetTop?{top:offsetTop}:{}},children);}ScrollHeader.defaultProps={className:null};export default ScrollHeader;
@@ -1 +1 @@
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{css}from'glamor';import{responsiveMediaQuery}from'@shopgate/engage/styles';export var header=css(_defineProperty({position:'sticky',top:0,left:0,backgroundColor:'#fff',transform:'translateY(0)',transition:'transform 0.3s ease'},responsiveMediaQuery('<=xs',{appAlways:true}),{boxShadow:'rgba(0, 0, 0, 0.118) 0px 1px 6px, rgba(0, 0, 0, 0.118) 0px 1px 4px'})).toString();export var hidden=css({transform:'translateY(-110%)'}).toString();
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{css}from'glamor';import{responsiveMediaQuery}from'@shopgate/engage/styles';export var header=css(_defineProperty({position:'sticky',left:0,backgroundColor:'#fff',transform:'translateY(0)',transition:'transform 0.3s ease'},responsiveMediaQuery('<=xs',{appAlways:true}),{boxShadow:'rgba(0, 0, 0, 0.118) 0px 1px 6px, rgba(0, 0, 0, 0.118) 0px 1px 4px'})).toString();export var hidden=css({transform:'translateY(-250%)'}).toString();
@@ -0,0 +1,6 @@
1
+ import{getThemeConfig}from"./getThemeConfig";/**
2
+ * Retrieves the global theme styles. Returns undefined when the given key doesn't exist there.
3
+ *
4
+ * @param {string|null} [key=null] settings key
5
+ * @returns {Object|undefined|*}
6
+ */export function getThemeStyles(){var key=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var _getThemeConfig=getThemeConfig(),_getThemeConfig$style=_getThemeConfig.styles,styles=_getThemeConfig$style===void 0?{}:_getThemeConfig$style;return key?styles[key]:styles;}
@@ -1 +1 @@
1
- export{default as subscriptions}from"./config.subscriptions";export{default as reducers}from"./config.reducers";export{fetchConfig}from"./config.actions";export{makeGetConfig,makeGetMerchantSettings,makeGetFulfillmentPaths,makeGetEnabledFulfillmentMethods,makeGetEnabledFulfillmentMethodsCount,makeUseLocationFulfillmentMethods,getShopSettings,getConfigFetching}from"./config.selectors";export{requestCoreConfig$,receiveCoreConfig$,errorCoreConfig$}from"./config.streams";export{getPageConfig}from"./getPageConfig";export{getPageSettings}from"./getPageSettings";export{getThemeAssets}from"./getThemeAssets";export{getThemeColors}from"./getThemeColors";export{getThemeConfig}from"./getThemeConfig";export{getThemeSettings}from"./getThemeSettings";export{getWidgetConfig}from"./getWidgetConfig";export{getWidgetSettings}from"./getWidgetSettings";
1
+ export{default as subscriptions}from"./config.subscriptions";export{default as reducers}from"./config.reducers";export{fetchConfig}from"./config.actions";export{makeGetConfig,makeGetMerchantSettings,makeGetFulfillmentPaths,makeGetEnabledFulfillmentMethods,makeGetEnabledFulfillmentMethodsCount,makeUseLocationFulfillmentMethods,getShopSettings,getConfigFetching}from"./config.selectors";export{requestCoreConfig$,receiveCoreConfig$,errorCoreConfig$}from"./config.streams";export{getPageConfig}from"./getPageConfig";export{getPageSettings}from"./getPageSettings";export{getThemeAssets}from"./getThemeAssets";export{getThemeColors}from"./getThemeColors";export{getThemeConfig}from"./getThemeConfig";export{getThemeSettings}from"./getThemeSettings";export{getThemeStyles}from"./getThemeStyles";export{getWidgetConfig}from"./getWidgetConfig";export{getWidgetSettings}from"./getWidgetSettings";
@@ -1,8 +1,8 @@
1
- import{useWidgetConfig}from"./useWidgetConfig";/**
1
+ import defaultsDeep from'lodash/defaultsDeep';import{useWidgetConfig}from"./useWidgetConfig";import{getThemeStyles}from"../config";/**
2
2
  * Retrieves the styles for a specific widget by its id. Returns an empty object when no styles
3
3
  * exist.
4
4
  *
5
5
  * @param {string} widgetId The ID of the widget to look for.
6
6
  * @param {number|undefined} [index=0] The optional index of the widget.
7
7
  * @returns {Object}
8
- */export function useWidgetStyles(widgetId){var index=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var _useWidgetConfig=useWidgetConfig(widgetId,index),_useWidgetConfig$styl=_useWidgetConfig.styles,styles=_useWidgetConfig$styl===void 0?{}:_useWidgetConfig$styl;return styles;}
8
+ */export function useWidgetStyles(widgetId){var index=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var _useWidgetConfig=useWidgetConfig(widgetId,index),_useWidgetConfig$styl=_useWidgetConfig.styles,styles=_useWidgetConfig$styl===void 0?{}:_useWidgetConfig$styl;var globalStyles=getThemeStyles(widgetId);return defaultsDeep(styles,globalStyles);}
@@ -1,3 +1,3 @@
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,{useContext,useMemo}from'react';import classNames from'classnames';import{ResponsiveContainer}from'@shopgate/engage/components';import{StoreContext}from"./Store.context";import{StoreFinderContext}from"../../locations.context";import StoreFinderLocationHeader from"./StoreFinderLocationHeader";import StoreFinderLocationDetails from"./StoreFinderLocationDetails";import StoreFinderGetDirectionsButton from"./StoreFinderGetDirectionsButton";import{container,selected,directionsButton}from"./StoreFinderLocation.style";/**
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,{useContext,useMemo}from'react';import classNames from'classnames';import{ResponsiveContainer}from'@shopgate/engage/components';import{StoreContext}from"./Store.context";import{StoreFinderContext}from"../../locations.context";import StoreFinderLocationHeader from"./StoreFinderLocationHeader";import StoreFinderLocationDetails from"./StoreFinderLocationDetails";import StoreFinderGetDirectionsButton from"./StoreFinderGetDirectionsButton";import{container,selected,directionsButton}from"./StoreFinderLocation.style";import{StoreFinderSelectLocationButton}from"./StoreFinderSelectLocationButton";/**
2
2
  * @returns {JSX}
3
- */var StoreFinderLocation=function StoreFinderLocation(){var store=useContext(StoreContext);var _useContext=useContext(StoreFinderContext),selectedLocation=_useContext.selectedLocation;var isSelected=useMemo(function(){var _ref=selectedLocation||{},code=_ref.code;return store.code===code;},[selectedLocation,store.code]);return React.createElement("div",{className:classNames(container,_defineProperty({},selected,isSelected)),"data-location-code":store.code},React.createElement(StoreFinderLocationHeader,null),React.createElement(ResponsiveContainer,{breakpoint:"<=sm",appAlways:true},React.createElement(StoreFinderLocationDetails,null),React.createElement(StoreFinderGetDirectionsButton,{address:store.address,className:directionsButton})));};export default StoreFinderLocation;
3
+ */var StoreFinderLocation=function StoreFinderLocation(){var store=useContext(StoreContext);var _useContext=useContext(StoreFinderContext),selectedLocation=_useContext.selectedLocation;var isSelected=useMemo(function(){var _ref=selectedLocation||{},code=_ref.code;return store.code===code;},[selectedLocation,store.code]);return React.createElement("div",{className:classNames(container,_defineProperty({},selected,isSelected)),"data-location-code":store.code},React.createElement(StoreFinderLocationHeader,null),React.createElement(ResponsiveContainer,{breakpoint:"<=sm",appAlways:true},React.createElement(StoreFinderLocationDetails,null),React.createElement(StoreFinderSelectLocationButton,null),React.createElement(StoreFinderGetDirectionsButton,{address:store.address,className:directionsButton})));};export default StoreFinderLocation;
@@ -1,3 +1,3 @@
1
- import _isEmpty from"lodash/isEmpty";import _every from"lodash/every";import React,{Fragment,useMemo,useContext}from'react';import{Grid,I18n}from'@shopgate/engage/components';import{StoreFinderContext}from"../../locations.context";import{StoreAddress}from"../StoreList/StoreAddress";import{StoreOpeningHours}from"../StoreList/StoreOpeningHours";import{StoreHoursToday}from"../StoreList/StoreHoursToday";import{StoreDistance}from"../StoreList/StoreDistance";import StoreFinderGetDirectionsButton from"./StoreFinderGetDirectionsButton";import StoreFinderLocationHeaderPhoneNumber from"./StoreFinderLocationHeaderPhoneNumber";import{container,headingLine,storeName,storeHours,storeDistance,storeDetailsLine,storeAddress,storePhoneNumber,storeOpeningHours,directionButton}from"./StoreFinderLocationDetailsWide.style";/**
1
+ import _isEmpty from"lodash/isEmpty";import _every from"lodash/every";import React,{Fragment,useMemo,useContext}from'react';import{Grid,I18n}from'@shopgate/engage/components';import{StoreFinderContext}from"../../locations.context";import{StoreAddress}from"../StoreList/StoreAddress";import{StoreOpeningHours}from"../StoreList/StoreOpeningHours";import{StoreHoursToday}from"../StoreList/StoreHoursToday";import{StoreDistance}from"../StoreList/StoreDistance";import StoreFinderGetDirectionsButton from"./StoreFinderGetDirectionsButton";import StoreFinderLocationHeaderPhoneNumber from"./StoreFinderLocationHeaderPhoneNumber";import{container,headingLine,storeName,storeHours,storeDistance,storeDetailsLine,storeAddress,storePhoneNumber,storeOpeningHours,directionButton}from"./StoreFinderLocationDetailsWide.style";import{StoreFinderSelectLocationButton}from"./StoreFinderSelectLocationButton";import{StoreContext}from"./Store.context";/**
2
2
  * @returns {JSX}
3
- */var StoreFinderLocationDetailsWide=function StoreFinderLocationDetailsWide(){var _useContext=useContext(StoreFinderContext),location=_useContext.selectedLocation,locations=_useContext.locations;var hasOperationHours=useMemo(function(){var _ref=location||{},operationHours=_ref.operationHours;return operationHours&&!_every(operationHours,_isEmpty);},[location]);if(!location||locations.length===0){return null;}return React.createElement("div",{className:container},React.createElement(Grid,{className:headingLine},React.createElement(Grid.Item,{grow:1},React.createElement("div",{className:storeName},location.name),React.createElement("div",{className:storeHours},React.createElement(StoreHoursToday,{hours:location.operationHours,longLabel:true}))),React.createElement(Grid.Item,null,React.createElement("div",{className:storeDistance},React.createElement(StoreDistance,{distance:location.distance,unitSystem:location.unitSystem})),React.createElement(StoreFinderGetDirectionsButton,{address:location.address,className:directionButton}))),React.createElement(Grid,{className:storeDetailsLine},React.createElement(Grid.Item,null,React.createElement("div",{className:storeAddress},React.createElement(StoreAddress,{pure:true,address:location.address})),location.address.phoneNumber&&React.createElement("div",{className:storePhoneNumber},React.createElement(I18n.Text,{string:"locations.phone"}),': ',React.createElement(StoreFinderLocationHeaderPhoneNumber,{phone:location.address.phoneNumber,pure:true}))),React.createElement(Grid.Item,{className:storeOpeningHours},hasOperationHours&&React.createElement(Fragment,null,React.createElement(I18n.Text,{string:"locations.store_hours"}),':',React.createElement(StoreOpeningHours,{pure:true,hours:location.operationHours})))));};export default StoreFinderLocationDetailsWide;
3
+ */var StoreFinderLocationDetailsWide=function StoreFinderLocationDetailsWide(){var _useContext=useContext(StoreFinderContext),location=_useContext.selectedLocation,locations=_useContext.locations;var hasOperationHours=useMemo(function(){var _ref=location||{},operationHours=_ref.operationHours;return operationHours&&!_every(operationHours,_isEmpty);},[location]);if(!location||locations.length===0){return null;}return React.createElement(StoreContext.Provider,{value:location},React.createElement("div",{className:container},React.createElement(Grid,{className:headingLine},React.createElement(Grid.Item,{grow:1},React.createElement("div",{className:storeName},location.name),React.createElement("div",{className:storeHours},React.createElement(StoreHoursToday,{hours:location.operationHours,longLabel:true}))),React.createElement(Grid.Item,null,React.createElement("div",{className:storeDistance},React.createElement(StoreDistance,{distance:location.distance,unitSystem:location.unitSystem})),React.createElement(StoreFinderSelectLocationButton,null),React.createElement(StoreFinderGetDirectionsButton,{address:location.address,className:directionButton}))),React.createElement(Grid,{className:storeDetailsLine},React.createElement(Grid.Item,null,React.createElement("div",{className:storeAddress},React.createElement(StoreAddress,{pure:true,address:location.address})),location.address.phoneNumber&&React.createElement("div",{className:storePhoneNumber},React.createElement(I18n.Text,{string:"locations.phone"}),': ',React.createElement(StoreFinderLocationHeaderPhoneNumber,{phone:location.address.phoneNumber,pure:true}))),React.createElement(Grid.Item,{className:storeOpeningHours},hasOperationHours&&React.createElement(Fragment,null,React.createElement(I18n.Text,{string:"locations.store_hours"}),':',React.createElement(StoreOpeningHours,{pure:true,hours:location.operationHours}))))));};export default StoreFinderLocationDetailsWide;
@@ -1,3 +1,3 @@
1
1
  import React,{useContext,useCallback}from'react';import{Grid,ResponsiveContainer}from'@shopgate/engage/components';import{StoreContext}from"./Store.context";import{StoreFinderContext}from"../../locations.context";import{StoreDistance}from"../StoreList/StoreDistance";import{StoreHoursToday}from"../StoreList/StoreHoursToday";import{StoreAddress}from"../StoreList/StoreAddress";import StoreFinderLocationHeaderPhoneNumber from"./StoreFinderLocationHeaderPhoneNumber";import{container,storeName,storeDistance,storeHoursToday,clickable}from"./StoreFinderLocationHeader.style";/**
2
2
  * @returns {JSX}
3
- */var StoreFinderLocationHeader=function StoreFinderLocationHeader(){var store=useContext(StoreContext);var name=store.name,distance=store.distance,unitSystem=store.unitSystem,operationHours=store.operationHours,address=store.address;var _useContext=useContext(StoreFinderContext),selectLocation=_useContext.selectLocation;var handleClick=useCallback(function(){selectLocation(store);},[selectLocation,store]);return React.createElement("div",{className:container},React.createElement("div",{className:clickable,role:"button",tabIndex:"0",onClick:handleClick,onKeyDown:handleClick},React.createElement(Grid,null,React.createElement(Grid.Item,{grow:1,className:storeName},name),React.createElement(Grid.Item,{className:storeDistance},React.createElement(StoreDistance,{distance:distance,unitSystem:unitSystem}))),React.createElement(ResponsiveContainer,{breakpoint:">sm",webOnly:true},React.createElement("div",{className:storeHoursToday},React.createElement(StoreHoursToday,{hours:operationHours,longLabel:true})),React.createElement(StoreAddress,{address:address,pure:true})),React.createElement(ResponsiveContainer,{breakpoint:"<=sm",appAlways:true},React.createElement("div",{className:storeHoursToday},React.createElement(StoreHoursToday,{hours:operationHours})),React.createElement(StoreAddress,{address:address}))),React.createElement(ResponsiveContainer,{breakpoint:"<=sm",appAlways:true},React.createElement(StoreFinderLocationHeaderPhoneNumber,{phone:address.phoneNumber})));};export default StoreFinderLocationHeader;
3
+ */var StoreFinderLocationHeader=function StoreFinderLocationHeader(){var store=useContext(StoreContext);var name=store.name,distance=store.distance,unitSystem=store.unitSystem,operationHours=store.operationHours,address=store.address;var _useContext=useContext(StoreFinderContext),changeLocation=_useContext.changeLocation;var handleClick=useCallback(function(){changeLocation(store);},[changeLocation,store]);return React.createElement("div",{className:container},React.createElement("div",{className:clickable,role:"button",tabIndex:"0",onClick:handleClick,onKeyDown:handleClick},React.createElement(Grid,null,React.createElement(Grid.Item,{grow:1,className:storeName},name),React.createElement(Grid.Item,{className:storeDistance},React.createElement(StoreDistance,{distance:distance,unitSystem:unitSystem}))),React.createElement(ResponsiveContainer,{breakpoint:">sm",webOnly:true},React.createElement("div",{className:storeHoursToday},React.createElement(StoreHoursToday,{hours:operationHours,longLabel:true})),React.createElement(StoreAddress,{address:address,pure:true})),React.createElement(ResponsiveContainer,{breakpoint:"<=sm",appAlways:true},React.createElement("div",{className:storeHoursToday},React.createElement(StoreHoursToday,{hours:operationHours})),React.createElement(StoreAddress,{address:address}))),React.createElement(ResponsiveContainer,{breakpoint:"<=sm",appAlways:true},React.createElement(StoreFinderLocationHeaderPhoneNumber,{phone:address.phoneNumber})));};export default StoreFinderLocationHeader;
@@ -1,4 +1,4 @@
1
1
  import React,{useContext,useMemo,useCallback}from'react';import PropTypes from'prop-types';import"../../assets/leaflet.css";import'leaflet-gesture-handling/dist/leaflet-gesture-handling.css';import Leaflet from'leaflet';import{GestureHandling}from'leaflet-gesture-handling';import{Map,Marker,TileLayer}from'react-leaflet';import{renderToString}from'react-dom/server';import MapMarkerIcon from'@shopgate/pwa-ui-shared/icons/MapMarkerIcon';import{StoreFinderContext}from"../../locations.context";import{container,marker,markerSelected,userPosition as userPositionStyle}from"./StoreFinderMap.style";Leaflet.Map.addInitHook('addHandler','gestureHandling',GestureHandling);/**
2
2
  * @param {Object} props The component props
3
3
  * @returns {JSX}
4
- */var StoreFinderMap=function StoreFinderMap(_ref){var showUserPosition=_ref.showUserPosition;var _useContext=useContext(StoreFinderContext),locations=_useContext.locations,selectedLocation=_useContext.selectedLocation,selectLocation=_useContext.selectLocation,userSearch=_useContext.userSearch;var iconHTML=useMemo(function(){return renderToString(React.createElement(MapMarkerIcon,null));},[]);var makerIcon=useMemo(function(){return Leaflet.divIcon({html:iconHTML,className:marker,iconSize:[40,40]});},[iconHTML]);var markerIconSelected=useMemo(function(){return Leaflet.divIcon({html:iconHTML,className:markerSelected,iconSize:[40,40]});},[iconHTML]);var userPositionIcon=useMemo(function(){return Leaflet.divIcon({html:'<div/>',className:userPositionStyle,iconSize:[20,20]});},[]);var positions=useMemo(function(){return locations.map(function(location){var code=location.code,latitude=location.latitude,longitude=location.longitude;var _ref2=selectedLocation||{},selectedCode=_ref2.code;var icon=selectedCode===code?markerIconSelected:makerIcon;return{code:code,location:location,icon:icon,position:[latitude,longitude]};});},[locations,makerIcon,markerIconSelected,selectedLocation]);var userPosition=useMemo(function(){var geolocation=userSearch.geolocation;if(!geolocation||!showUserPosition){return null;}var latitude=geolocation.latitude,longitude=geolocation.longitude;return{icon:userPositionIcon,position:[latitude,longitude]};},[showUserPosition,userPositionIcon,userSearch]);var viewport=useMemo(function(){var _ref3=selectedLocation||locations[0]||{},latitude=_ref3.latitude,longitude=_ref3.longitude;if(!latitude||!longitude){return(userPosition===null||userPosition===void 0?void 0:userPosition.position)||null;}return[latitude,longitude];},[locations,selectedLocation,userPosition]);var onMarkerClick=useCallback(function(event,location){selectLocation(location,true);},[selectLocation]);return React.createElement("div",{className:container},React.createElement(Map,{center:viewport,zoom:15,className:container,gestureHandling:Leaflet.Browser.mobile,touchZoom:true},React.createElement(TileLayer,{attribution:"&copy <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors",url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),positions.map(function(_ref4){var position=_ref4.position,code=_ref4.code,location=_ref4.location,icon=_ref4.icon;return React.createElement(Marker,{key:code,icon:icon,position:position,onclick:function onclick(e){onMarkerClick(e,location);}});}),userPosition&&React.createElement(Marker,{key:"user-position",icon:userPosition.icon,position:userPosition.position})));};StoreFinderMap.defaultProps={showUserPosition:true};export default StoreFinderMap;
4
+ */var StoreFinderMap=function StoreFinderMap(_ref){var showUserPosition=_ref.showUserPosition;var _useContext=useContext(StoreFinderContext),locations=_useContext.locations,selectedLocation=_useContext.selectedLocation,changeLocation=_useContext.changeLocation,userSearch=_useContext.userSearch;var iconHTML=useMemo(function(){return renderToString(React.createElement(MapMarkerIcon,null));},[]);var makerIcon=useMemo(function(){return Leaflet.divIcon({html:iconHTML,className:marker,iconSize:[40,40]});},[iconHTML]);var markerIconSelected=useMemo(function(){return Leaflet.divIcon({html:iconHTML,className:markerSelected,iconSize:[40,40]});},[iconHTML]);var userPositionIcon=useMemo(function(){return Leaflet.divIcon({html:'<div/>',className:userPositionStyle,iconSize:[20,20]});},[]);var positions=useMemo(function(){return locations.map(function(location){var code=location.code,latitude=location.latitude,longitude=location.longitude;var _ref2=selectedLocation||{},selectedCode=_ref2.code;var icon=selectedCode===code?markerIconSelected:makerIcon;return{code:code,location:location,icon:icon,position:[latitude,longitude]};});},[locations,makerIcon,markerIconSelected,selectedLocation]);var userPosition=useMemo(function(){var geolocation=userSearch.geolocation;if(!geolocation||!showUserPosition){return null;}var latitude=geolocation.latitude,longitude=geolocation.longitude;return{icon:userPositionIcon,position:[latitude,longitude]};},[showUserPosition,userPositionIcon,userSearch]);var viewport=useMemo(function(){var _ref3=selectedLocation||locations[0]||{},latitude=_ref3.latitude,longitude=_ref3.longitude;if(!latitude||!longitude){return(userPosition===null||userPosition===void 0?void 0:userPosition.position)||null;}return[latitude,longitude];},[locations,selectedLocation,userPosition]);var onMarkerClick=useCallback(function(event,location){changeLocation(location,true);},[changeLocation]);return React.createElement("div",{className:container},React.createElement(Map,{center:viewport,zoom:15,className:container,gestureHandling:Leaflet.Browser.mobile,touchZoom:true},React.createElement(TileLayer,{attribution:"&copy <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors",url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),positions.map(function(_ref4){var position=_ref4.position,code=_ref4.code,location=_ref4.location,icon=_ref4.icon;return React.createElement(Marker,{key:code,icon:icon,position:position,onclick:function onclick(e){onMarkerClick(e,location);}});}),userPosition&&React.createElement(Marker,{key:"user-position",icon:userPosition.icon,position:userPosition.position})));};StoreFinderMap.defaultProps={showUserPosition:true};export default StoreFinderMap;
@@ -0,0 +1,5 @@
1
+ import React,{useCallback,useContext}from'react';import{RippleButton}from'@shopgate/engage/components';import{StoreContext}from"./Store.context";import{i18n}from"../../../core";import{StoreFinderContext}from"../../locations.context";import{selectLocationButton,selectLocationButtonWrapper}from"../StoreList/Store.style";/**
2
+ * The StoreFinderSelectLocationButton component.
3
+ * Renders if route query.selectLocation param is passed
4
+ * @returns {JSX}
5
+ */export var StoreFinderSelectLocationButton=function StoreFinderSelectLocationButton(){var store=useContext(StoreContext);var _useContext=useContext(StoreFinderContext),selectLocation=_useContext.selectLocation,isLoading=_useContext.isLoading;var handleClick=useCallback(function(e){e.stopPropagation();selectLocation(store);},[selectLocation,store]);return React.createElement("div",{className:selectLocationButtonWrapper},React.createElement(RippleButton,{onClick:handleClick,className:selectLocationButton.toString(),disabled:isLoading||(store===null||store===void 0?void 0:store.isComingSoon)},i18n.text('locations.select_location')));};
@@ -1,3 +1,3 @@
1
- import{connect}from'react-redux';import{getShopSettings}from'@shopgate/engage/core/config';import{makeGetLocationsForStoreFinder,getIsFetching,getUserSearch,getStoreFinderSearch}from"../selectors";/**
1
+ import{connect}from'react-redux';import{getShopSettings}from'@shopgate/engage/core/config';import{getIsFetching,getStoreFinderSearch,getUserSearch,makeGetLocationsForStoreFinder}from"../selectors";import{selectGlobalLocation,selectLocation}from"../action-creators";/**
2
2
  * @returns {Function}
3
- */var makeMapStateToProps=function makeMapStateToProps(){var getLocationsForStoreFinder=makeGetLocationsForStoreFinder();return function(state,props){return{locations:getLocationsForStoreFinder(state,props),isFetching:getIsFetching(state),shopSettings:getShopSettings(state),userSearch:getUserSearch(state),storeFinderSearch:getStoreFinderSearch(state,props)};};};export default connect(makeMapStateToProps);
3
+ */var makeMapStateToProps=function makeMapStateToProps(){var getLocationsForStoreFinder=makeGetLocationsForStoreFinder();return function(state,props){return{locations:getLocationsForStoreFinder(state,props),isFetching:getIsFetching(state),shopSettings:getShopSettings(state),userSearch:getUserSearch(state),storeFinderSearch:getStoreFinderSearch(state,props)};};};var mapDispatchToProps={selectLocation:selectLocation,selectGlobalLocation:selectGlobalLocation};export default connect(makeMapStateToProps,mapDispatchToProps);
@@ -1,6 +1,7 @@
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,{useMemo,useState,useCallback,useEffect}from'react';import PropTypes from'prop-types';import{LoadingProvider}from'@shopgate/pwa-common/providers';import{STORE_FINDER_PATTERN}from"../constants";import{StoreFinderContext}from"../locations.context";import connect from"./StoreFinder.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 React,{useMemo,useState,useCallback,useEffect}from'react';import PropTypes from'prop-types';import{LoadingProvider}from'@shopgate/pwa-common/providers';import{STORE_FINDER_PATTERN}from"../constants";import{StoreFinderContext}from"../locations.context";import connect from"./StoreFinder.connector";import{useNavigation}from"../../core";/**
2
2
  * @param {Object} props The component props
3
3
  * @returns {JSX}
4
- */var StoreFinderProvider=function StoreFinderProvider(_ref){var children=_ref.children,locations=_ref.locations,isFetching=_ref.isFetching,shopSettings=_ref.shopSettings,userSearch=_ref.userSearch,storeFinderSearch=_ref.storeFinderSearch,storeListRef=_ref.storeListRef;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),selectedLocation=_useState2[0],setSelectedLocation=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),locationsHash=_useState4[0],setLocationsHash=_useState4[1];var selectLocation=useCallback(function(location){var scrollIntoView=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;setSelectedLocation(location);if(scrollIntoView&&storeListRef.current){var container=storeListRef.current;var element=container.querySelector("[data-location-code=\"".concat(location.code,"\"]"));var scrollParams={top:element.parentNode.offsetTop-container.offsetTop-10,behavior:'smooth'};var _getComputedStyle=getComputedStyle(container),overflowY=_getComputedStyle.overflowY;if(overflowY==='scroll'){container.scroll(scrollParams);}else{window.scroll(scrollParams);}}},[storeListRef]);useEffect(function(){var hash=JSON.stringify(locations.map(function(_ref2){var code=_ref2.code;return code;}));if(hash!==locationsHash){setLocationsHash(hash);selectLocation(locations[0]);}});/**
4
+ */var StoreFinderProvider=function StoreFinderProvider(_ref){var children=_ref.children,locations=_ref.locations,isFetching=_ref.isFetching,shopSettings=_ref.shopSettings,userSearch=_ref.userSearch,storeFinderSearch=_ref.storeFinderSearch,storeListRef=_ref.storeListRef,selectGlobalLocation=_ref.selectGlobalLocation,selectLocation=_ref.selectLocation;var _useNavigation=useNavigation(),pop=_useNavigation.pop;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),selectedLocation=_useState2[0],setSelectedLocation=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),locationsHash=_useState4[0],setLocationsHash=_useState4[1];var changeLocation=useCallback(function(location){var scrollIntoView=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;setSelectedLocation(location);if(scrollIntoView&&storeListRef.current){var container=storeListRef.current;var element=container.querySelector("[data-location-code=\"".concat(location.code,"\"]"));var scrollParams={top:element.parentNode.offsetTop-container.offsetTop-10,behavior:'smooth'};var _getComputedStyle=getComputedStyle(container),overflowY=_getComputedStyle.overflowY;if(overflowY==='scroll'){container.scroll(scrollParams);}else{window.scroll(scrollParams);}}},[storeListRef]);var selectLocationCb=useCallback(function(location){setSelectedLocation(location);selectLocation(location);selectGlobalLocation(location);// Back navigation
5
+ pop();},[selectLocation,selectGlobalLocation,pop]);useEffect(function(){var hash=JSON.stringify(locations.map(function(_ref2){var code=_ref2.code;return code;}));if(hash!==locationsHash){setLocationsHash(hash);changeLocation(locations[0]);}});/**
5
6
  * @param {bool} loading
6
- */var setIsLoading=useCallback(function(loading){if(loading){LoadingProvider.setLoading(STORE_FINDER_PATTERN);return;}LoadingProvider.unsetLoading(STORE_FINDER_PATTERN);},[]);var value=useMemo(function(){return{locations:locations,selectedLocation:selectedLocation,selectLocation:selectLocation,isFetching:isFetching,shopSettings:shopSettings,userSearch:userSearch,storeFinderSearch:storeFinderSearch,setIsLoading:setIsLoading};},[isFetching,locations,selectLocation,selectedLocation,shopSettings,storeFinderSearch,userSearch,setIsLoading]);return React.createElement(StoreFinderContext.Provider,{value:value},children);};StoreFinderProvider.defaultProps={children:null,locations:[],storeListRef:null,isFetching:false,shopSettings:null,userSearch:null,storeFinderSearch:null};export default connect(StoreFinderProvider);
7
+ */var setIsLoading=useCallback(function(loading){if(loading){LoadingProvider.setLoading(STORE_FINDER_PATTERN);return;}LoadingProvider.unsetLoading(STORE_FINDER_PATTERN);},[]);var value=useMemo(function(){return{locations:locations,selectedLocation:selectedLocation,changeLocation:changeLocation,selectLocation:selectLocationCb,isFetching:isFetching,shopSettings:shopSettings,userSearch:userSearch,storeFinderSearch:storeFinderSearch,setIsLoading:setIsLoading};},[isFetching,locations,changeLocation,selectLocationCb,selectedLocation,shopSettings,storeFinderSearch,userSearch,setIsLoading]);return React.createElement(StoreFinderContext.Provider,{value:value},children);};StoreFinderProvider.defaultProps={children:null,locations:[],storeListRef:null,isFetching:false,shopSettings:null,userSearch:null,storeFinderSearch:null};export default connect(StoreFinderProvider);
@@ -8,7 +8,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
8
8
  * @param {Function} subscribe The subscribe function.
9
9
  */function locationsSubscriber(subscribe){subscribe(appDidStart$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3){var dispatch,getState,userSearch,_ref5,locations,preferredLocation,code,hasLocation,_ref6,preferredLocationDefault,locationToPreselect;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:dispatch=_ref3.dispatch,getState=_ref3.getState;// Fetch merchants locations.
10
10
  userSearch=getUserSearch(getState());_context2.prev=2;_context2.next=5;return dispatch(fetchLocations(userSearch));case 5:_ref5=_context2.sent;locations=_ref5.locations;preferredLocation=getPreferredLocation(getState());if(!preferredLocation){_context2.next=14;break;}code=preferredLocation.code;// Check if the preferred location is included within the fetched locations
11
- hasLocation=!!locations.find(function(location){return location.code===code;});if(hasLocation){_context2.next=14;break;}_context2.next=14;return dispatch(fetchLocations(_extends({},userSearch,{codes:[code]})));case 14:// Preset preferredLocation if configured
11
+ hasLocation=!!locations.find(function(location){return location.code===code;});if(hasLocation){_context2.next=14;break;}_context2.next=14;return dispatch(fetchLocations({codes:[code]}));case 14:// Preset preferredLocation if configured
12
12
  _ref6=getThemeSettings('@shopgate/engage/locations')||{},preferredLocationDefault=_ref6.preferredLocationDefault;if(preferredLocationDefault){// check if there is already a preferredLocation for the user, if not set one
13
13
  if(!preferredLocation){locationToPreselect=locations.find(function(l){return l.code===preferredLocationDefault;});if(locationToPreselect){dispatch(selectLocation({code:preferredLocationDefault}));}}}initialLocationsResolve(locations);_context2.next=22;break;case 19:_context2.prev=19;_context2.t0=_context2["catch"](2);initialLocationsReject(_context2.t0);case 22:UIEvents.addListener(EVENT_SET_OPEN,function(){var route=getCurrentRoute(getState());if(!route.params.productId&&!route.state.productId){return;}var productId=route.state.productId||hex2bin(route.params.productId);if(productId){dispatch(fetchProductLocations(productId,getUserSearch(getState())));}});case 23:case"end":return _context2.stop();}}},_callee2,null,[[2,19]]);}));return function(_x3){return _ref4.apply(this,arguments);};}());subscribe(userSearchChanged$,/*#__PURE__*/function(){var _ref8=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref7){var dispatch,getState,action,productId,isStoreFinder,silent,state,userSearch,storeFinderSearch;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:dispatch=_ref7.dispatch,getState=_ref7.getState,action=_ref7.action;productId=action.productId,isStoreFinder=action.isStoreFinder,silent=action.silent;if(!(silent===true)){_context3.next=4;break;}return _context3.abrupt("return");case 4:state=getState();userSearch=getUserSearch(state);if(!(isStoreFinder||action.type===SET_STORE_FINDER_SEARCH_RADIUS)){_context3.next=12;break;}storeFinderSearch=getStoreFinderSearch(state);_context3.next=10;return dispatch(fetchLocations(_extends({},userSearch,{},storeFinderSearch,{enableInLocationFinder:true})));case 10:_context3.next=19;break;case 12:if(productId){_context3.next=17;break;}_context3.next=15;return dispatch(fetchLocations(userSearch));case 15:_context3.next=19;break;case 17:_context3.next=19;return dispatch(fetchProductLocations(productId,userSearch));case 19:case"end":return _context3.stop();}}},_callee3);}));return function(_x4){return _ref8.apply(this,arguments);};}());var productInventoryNeedsUpdate$=productIsReady$.merge(variantDidChange$).merge(preferredLocationDidUpdateOnPDP$).debounceTime(200);subscribe(productInventoryNeedsUpdate$,function(_ref9){var action=_ref9.action,dispatch=_ref9.dispatch,getState=_ref9.getState;var productData=action.productData;// Skip if no fulfillment methods are set.
14
14
  if(!productData||!productData.fulfillmentMethods||productData.fulfillmentMethods.length===0){return;}var state=getState();var preferredLocation=getPreferredLocation(state);if(!preferredLocation){return;}// Fetch inventories for this specific product.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.3.3-beta.2",
3
+ "version": "7.3.4-beta.3",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,12 +16,12 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@shopgate/native-modules": "1.0.0-beta.18",
19
- "@shopgate/pwa-common": "7.3.3-beta.2",
20
- "@shopgate/pwa-common-commerce": "7.3.3-beta.2",
21
- "@shopgate/pwa-core": "7.3.3-beta.2",
22
- "@shopgate/pwa-ui-ios": "7.3.3-beta.2",
23
- "@shopgate/pwa-ui-material": "7.3.3-beta.2",
24
- "@shopgate/pwa-ui-shared": "7.3.3-beta.2",
19
+ "@shopgate/pwa-common": "7.3.4-beta.3",
20
+ "@shopgate/pwa-common-commerce": "7.3.4-beta.3",
21
+ "@shopgate/pwa-core": "7.3.4-beta.3",
22
+ "@shopgate/pwa-ui-ios": "7.3.4-beta.3",
23
+ "@shopgate/pwa-ui-material": "7.3.4-beta.3",
24
+ "@shopgate/pwa-ui-shared": "7.3.4-beta.3",
25
25
  "@stripe/react-stripe-js": "^1.1.2",
26
26
  "@stripe/stripe-js": "^1.3.1",
27
27
  "@virtuous/conductor": "~2.5.0",