@shopgate/engage 7.26.0-beta.1 → 7.26.0-beta.2
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.
- package/a11y/action-creators/index.js +9 -0
- package/a11y/components/FocusTrap/index.js +1 -0
- package/a11y/components/ModalStateTracker/index.js +14 -0
- package/a11y/components/Section/index.js +3 -3
- package/a11y/components/index.js +1 -1
- package/a11y/constants/index.js +1 -1
- package/a11y/hooks/index.js +37 -0
- package/a11y/index.js +1 -1
- package/a11y/reducers/index.js +6 -0
- package/a11y/selectors/index.js +8 -0
- package/cart/components/CartItem/CartItemProductLayout.style.js +1 -1
- package/cart/components/CartItem/CartItemProductProvider.js +1 -1
- package/cart/components/CartItem/CartItemProductTitle.js +2 -2
- package/cart/components/CartItem/CartItemQuantityPicker.js +1 -1
- package/components/Menu/components/Item/index.js +2 -2
- package/components/SheetDrawer/index.js +4 -3
- package/components/View/components/Content/index.js +2 -2
- package/components/View/provider.js +7 -4
- package/core/events/index.js +1 -0
- package/core/helpers/index.js +1 -1
- package/core/index.js +2 -4
- package/favorites/components/List/List.js +1 -1
- package/locations/action-creators/selectLocation.js +2 -1
- package/locations/actions/fetchLocations.js +1 -1
- package/locations/components/FulfillmentSheet/FulfillmentSheet.js +4 -3
- package/locations/components/FulfillmentSheet/FulfillmentSheetContent.js +5 -3
- package/locations/components/StockInfo/StockInfo.js +2 -2
- package/locations/components/StockInfo/StockInfoInventory.js +2 -2
- package/locations/components/StoreDetails/components/FindMoreStores.js +4 -0
- package/locations/components/StoreDetails/components/GetDirectionsButton.js +7 -0
- package/locations/components/StoreDetails/components/StoreDetails.js +5 -0
- package/locations/components/StoreDetails/components/StoreFinderMap.js +20 -0
- package/locations/components/StoreDetails/components/StoreFinderMap.style.js +1 -0
- package/locations/components/StoreDetails/components/StoreLocationMap.js +4 -0
- package/locations/components/StoreDetails/components/StoresNearby.js +4 -0
- package/locations/components/StoreDetails/components/StoresNearbyListItem.js +9 -0
- package/locations/components/StoreDetails/index.js +4 -0
- package/locations/components/StoreFinder/StoreFinder.js +3 -3
- package/locations/components/StoreFinder/StoreFinder.style.js +1 -2
- package/locations/components/StoreFinder/StoreFinderLocation.js +2 -2
- package/locations/components/StoreFinder/StoreFinderLocation.style.js +1 -1
- package/locations/components/StoreFinder/StoreFinderLocationHeader.js +2 -2
- package/locations/components/StoreFinder/StoreFinderLocationHeader.style.js +1 -1
- package/locations/components/StoreFinder/StoreFinderLocations.style.js +1 -2
- package/locations/components/StoreFinder/StoreFinderSearch.style.js +1 -1
- package/locations/components/StoreFinder/StoreFinderSelectLocationButton.js +2 -2
- package/locations/components/StoreFinder/StoreFinderStoreInfoButton.js +8 -0
- package/locations/components/StoreList/Store.style.js +1 -1
- package/locations/components/StoreList/StoreAddress.js +5 -3
- package/locations/components/StoreList/StoreAddressShort.js +5 -3
- package/locations/components/StoreList/StoreCard.js +2 -2
- package/locations/components/StoreList/StoreDetailsLine.js +6 -2
- package/locations/components/StoreList/StoreDistance.js +4 -2
- package/locations/components/StoreList/StoreHeader.js +2 -2
- package/locations/components/StoreList/StoreHoursToday.js +4 -2
- package/locations/components/StoreList/StoreListLocations.js +1 -1
- package/locations/components/StoreList/StoreListProduct.js +1 -1
- package/locations/components/StoreList/StoreListSearch.js +1 -1
- package/locations/components/StoreList/StoreOpeningHours.js +5 -3
- package/locations/components/StoreList/StoreOpeningHoursLine.js +4 -2
- package/locations/components/StoreList/StorePhoneNumber.js +4 -3
- package/locations/components/StoreList/StoreSelectLocationButton.js +1 -1
- package/locations/components/index.js +1 -1
- package/locations/constants/Portals.js +1 -1
- package/locations/constants/index.js +3 -1
- package/locations/constants/routes.js +1 -1
- package/locations/locations.streams.js +1 -1
- package/locations/providers/StoreDetailsContext.js +1 -0
- package/locations/providers/StoreDetailsProvider.js +4 -0
- package/locations/providers/StoreFinderProvider.js +4 -4
- package/locations/providers/index.js +1 -1
- package/locations/selectors/index.js +7 -2
- package/locations/subscriptions.js +3 -3
- package/login/components/ForgotPassword/ForgotPassword.style.js +1 -1
- package/package.json +12 -11
- package/product/components/Characteristics/Characteristic/components/Sheet/index.js +2 -2
- package/product/components/Characteristics/Characteristic/index.js +3 -2
- package/product/components/ProductBadges/index.js +1 -1
- package/product/components/ProductCard/index.js +2 -2
- package/product/components/ProductDiscountBadge/index.js +2 -2
- package/product/components/ProductImage/index.js +2 -2
- package/product/components/ProductProperties/Row.js +1 -1
- package/product/components/Rating/index.js +2 -2
- package/push-opt-in/components/PushOptInModal/index.js +1 -1
- package/push-opt-in/subscriptions/optInTrigger.js +1 -1
- package/reviews/components/Reviews/components/Header/components/AverageRating/index.js +6 -4
- package/reviews/components/Reviews/components/Header/components/NoReviews/index.js +3 -3
- package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/index.js +3 -3
- package/reviews/components/Reviews/components/Header/components/WriteReviewLink/index.js +3 -3
- package/reviews/components/Reviews/components/Header/components/WriteReviewLink/spec.js +2 -2
- package/reviews/components/Reviews/components/Header/index.js +5 -3
- package/reviews/components/Reviews/components/Header/spec.js +1 -1
- package/reviews/components/Reviews/components/ReviewsInfo/index.js +1 -2
- package/styles/reset/root.js +2 -1
- package/tracking/components/CookieConsentModal/index.js +1 -1
- package/locations/components/StoreFinder/StoreFinderLocationDetailsWide.js +0 -3
- package/locations/components/StoreFinder/StoreFinderLocationDetailsWide.style.js +0 -1
- package/locations/components/StoreFinder/StoreFinderMap.js +0 -4
- package/locations/components/StoreFinder/StoreFinderMap.style.js +0 -2
- package/locations/components/StoreFinder/StoreFinderStoresNear.js +0 -3
- package/locations/components/StoreFinder/StoreFinderStoresNear.style.js +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{A11Y_INCREASE_MODAL_COUNT,A11Y_DECREASE_MODAL_COUNT}from"../constants";/**
|
|
2
|
+
* Increases the modal count inside the A11Y state. Used to determine if parts of the app needs to
|
|
3
|
+
* be hidden for screen readers to improve accessibility.
|
|
4
|
+
* @returns {Object} The Redux action object
|
|
5
|
+
*/export var increaseModalCount=function increaseModalCount(){return{type:A11Y_INCREASE_MODAL_COUNT};};/**
|
|
6
|
+
* Decreases the modal count inside the A11Y state. Used to determine if parts of the app needs to
|
|
7
|
+
* be hidden for screen readers to improve accessibility.
|
|
8
|
+
* @returns {Object} The Redux action object
|
|
9
|
+
*/export var decreaseModalCount=function decreaseModalCount(){return{type:A11Y_DECREASE_MODAL_COUNT};};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FocusTrap}from'focus-trap-react';export default FocusTrap;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import PropTypes from'prop-types';import{useTrackModalState}from'@shopgate/engage/a11y/hooks';/**
|
|
2
|
+
* Helper component to be used inside modal-like class components to track their visibility and
|
|
3
|
+
* apply a11y optimizations to the app.
|
|
4
|
+
*
|
|
5
|
+
* Wrap the children of your modal-like component with this component to track its visibility
|
|
6
|
+
*
|
|
7
|
+
* For functional components, please use the `useTrackModalState` hook instead.
|
|
8
|
+
* @param {Object} props The component props.
|
|
9
|
+
* @param {boolean} [props.isVisible] Optional visibility flag to be set by the parent component
|
|
10
|
+
* when it uses a visibility prop or state to toggle its visibility. Can be omitted if the
|
|
11
|
+
* component mounts/unmounts based on visibility.
|
|
12
|
+
* @param {ReactNode} props.children The component children.
|
|
13
|
+
* @returns {JSX.Element}
|
|
14
|
+
*/var ModalStateTracker=function ModalStateTracker(_ref){var children=_ref.children,isVisible=_ref.isVisible;useTrackModalState(isVisible);return children;};ModalStateTracker.propTypes={children:PropTypes.node.isRequired,isVisible:PropTypes.bool};ModalStateTracker.defaultProps={isVisible:undefined};export default ModalStateTracker;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded=["title","titleParams","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 _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;}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,{useRef,useState,useMemo,useLayoutEffect}from'react';import PropTypes from'prop-types';import kebabCase from'lodash/kebabCase';import{I18n}from'@shopgate/engage/components';/**
|
|
1
|
+
var _excluded=["title","titleParams","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 _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;}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,{useRef,useState,useMemo,useLayoutEffect}from'react';import PropTypes from'prop-types';import kebabCase from'lodash/kebabCase';import{I18n}from'@shopgate/engage/components';import VisuallyHidden from"../VisuallyHidden";/**
|
|
2
2
|
* Checks the section ref has suitable child nodes.
|
|
3
3
|
* @param {Object} ref A React ref.
|
|
4
4
|
* @param {string} headlineId The ID of the section headline.
|
|
@@ -13,5 +13,5 @@ var childNodes=[].filter.call(ref.current.childNodes,function(el){return el.getA
|
|
|
13
13
|
* @param {Object} [props.titleParams={}] Additional parameters for the title placeholder.
|
|
14
14
|
* @param {Object} [props.className=null] A class name for the section.
|
|
15
15
|
* @param {NodeList} [props.children=null] Component children.
|
|
16
|
-
* @returns {JSX}
|
|
17
|
-
*/function Section(props){var title=props.title,titleParams=props.titleParams,children=props.children,rest=_objectWithoutProperties(props,_excluded);var contentRef=useRef(null);var _useState=useState(false),_useState2=_slicedToArray(_useState,2),hasContent=_useState2[0],setHasContent=_useState2[1];var id=useMemo(function(){return kebabCase(title);},[title]);var observer=useMemo(function(){return new MutationObserver(function(){setHasContent(hasChildNodes(contentRef,id));});},[contentRef,id]);useLayoutEffect(function(){setHasContent(hasChildNodes(contentRef,id));observer.observe(contentRef.current,{childList:true});return function(){observer.disconnect();};},[contentRef,id,observer]);if(!hasContent){return React.createElement("section",_extends({},rest,{ref:contentRef}),children);}return React.createElement("section",_extends({},rest,{ref:contentRef,"aria-labelledby":id}),React.createElement("h2",{id:id
|
|
16
|
+
* @returns {JSX.Element}
|
|
17
|
+
*/function Section(props){var title=props.title,titleParams=props.titleParams,children=props.children,rest=_objectWithoutProperties(props,_excluded);var contentRef=useRef(null);var _useState=useState(false),_useState2=_slicedToArray(_useState,2),hasContent=_useState2[0],setHasContent=_useState2[1];var id=useMemo(function(){return kebabCase(title);},[title]);var observer=useMemo(function(){return new MutationObserver(function(){setHasContent(hasChildNodes(contentRef,id));});},[contentRef,id]);useLayoutEffect(function(){setHasContent(hasChildNodes(contentRef,id));observer.observe(contentRef.current,{childList:true});return function(){observer.disconnect();};},[contentRef,id,observer]);if(!hasContent){return React.createElement("section",_extends({},rest,{ref:contentRef}),children);}return React.createElement("section",_extends({},rest,{ref:contentRef,"aria-labelledby":id}),React.createElement(VisuallyHidden,null,React.createElement("h2",{id:id},React.createElement(I18n.Text,{string:title,params:titleParams}))),children);}Section.defaultProps={children:null,className:'',titleParams:{}};export default Section;
|
package/a11y/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as LiveMessage}from"./LiveMessage";export{default as LiveMessenger}from"./LiveMessenger";export{default as Navigation}from"./Navigation";export{default as Section}from"./Section";export{default as VisuallyHidden}from"./VisuallyHidden";
|
|
1
|
+
export{default as LiveMessage}from"./LiveMessage";export{default as LiveMessenger}from"./LiveMessenger";export{default as Navigation}from"./Navigation";export{default as ModalStateTracker}from"./ModalStateTracker";export{default as Section}from"./Section";export{default as VisuallyHidden}from"./VisuallyHidden";export{default as FocusTrap}from"./FocusTrap";
|
package/a11y/constants/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"../components/LiveMessenger/constants";
|
|
1
|
+
export*from"../components/LiveMessenger/constants";export var A11Y_INCREASE_MODAL_COUNT='A11Y_INCREASE_MODAL_COUNT';export var A11Y_DECREASE_MODAL_COUNT='A11Y_DECREASE_MODAL_COUNT';
|
|
@@ -0,0 +1,37 @@
|
|
|
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{useEffect,useState,useRef}from'react';import{useDispatch}from'react-redux';import{increaseModalCount,decreaseModalCount}from"../action-creators";/**
|
|
2
|
+
* The useReduceMotion hook
|
|
3
|
+
* to determine whether the user selected reduced motion in the phone settings
|
|
4
|
+
* @returns {boolean} whether the user prefers reduced motions in the settings
|
|
5
|
+
*/export var useReduceMotion=function useReduceMotion(){var _useState=useState(window.matchMedia('(prefers-reduced-motion: reduce)').matches),_useState2=_slicedToArray(_useState,2),matches=_useState2[0],setMatch=_useState2[1];useEffect(function(){var mq=window.matchMedia('(prefers-reduced-motion: reduce)');// eslint-disable-next-line require-jsdoc
|
|
6
|
+
var handleChange=function handleChange(){setMatch(mq.matches);};handleChange();mq.addEventListener('change',handleChange);return function(){mq.removeEventListener('change',handleChange);};},[]);return matches;};/**
|
|
7
|
+
* Tracks when a modal-like component is considered "visible", and dispatches Redux
|
|
8
|
+
* actions accordingly. This is useful for global tracking of visible overlays,
|
|
9
|
+
* modals, drawers, or any component with a similar behavior.
|
|
10
|
+
*
|
|
11
|
+
* Dispatches `increaseModalCount()` when the component becomes visible
|
|
12
|
+
* Dispatches `decreaseModalCount()` when the component becomes hidden
|
|
13
|
+
* Dispatches `decreaseModalCount()` on unmount if the component was still visible
|
|
14
|
+
*
|
|
15
|
+
* Call this hook inside any modal like component that:
|
|
16
|
+
* - Mounts/unmounts based on visibility (like a modal or tooltip)
|
|
17
|
+
* - OR uses a visibility prop (e.g. `isVisible`)
|
|
18
|
+
*
|
|
19
|
+
* @param {boolean} isVisible Optional visibility flag.
|
|
20
|
+
* If omitted, visibility is assumed `true` while mounted.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Component that uses isVisible prop
|
|
24
|
+
* function MyModal({ isVisible }) {
|
|
25
|
+
* useTrackModalState(isVisible);
|
|
26
|
+
* return <div className="my_modal">...</div>;
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Component that appears/disappears via mounting
|
|
31
|
+
* function MyModal() {
|
|
32
|
+
* useTrackModalState(); // defaults to `true`
|
|
33
|
+
* return <div className="tooltip">Hello!</div>;
|
|
34
|
+
* }
|
|
35
|
+
*/export function useTrackModalState(){var isVisible=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var dispatch=useDispatch();var wasVisible=useRef(false);// React to changes in visibility
|
|
36
|
+
useEffect(function(){if(isVisible&&!wasVisible.current){dispatch(increaseModalCount());wasVisible.current=true;}else if(!isVisible&&wasVisible.current){dispatch(decreaseModalCount());wasVisible.current=false;}},[isVisible,dispatch]);// On unmount, dispatch hide if it was still visible
|
|
37
|
+
useEffect(function(){return function(){if(wasVisible.current){dispatch(decreaseModalCount());wasVisible.current=false;}};},[dispatch]);}
|
package/a11y/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/** @module a11y */export
|
|
1
|
+
/** @module a11y */export{LiveMessage,LiveMessenger,Navigation,Section,VisuallyHidden}from"./components";export*from"./constants";export*from"./helpers";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{produce}from'immer';import{isDev,logger}from'@shopgate/engage/core/helpers';import{A11Y_INCREASE_MODAL_COUNT,A11Y_DECREASE_MODAL_COUNT}from"../constants";var defaultState={modalCount:0};/**
|
|
2
|
+
* Stores a11y state
|
|
3
|
+
* @param {Object} [state={}] The current state.
|
|
4
|
+
* @param {Object} action The action object.
|
|
5
|
+
* @returns {Object} The new state.
|
|
6
|
+
*/export default function a11y(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case A11Y_INCREASE_MODAL_COUNT:{draft.modalCount+=1;break;}case A11Y_DECREASE_MODAL_COUNT:{draft.modalCount-=1;if(draft.modalCount<0){if(isDev){logger.warn('Modal count is negative, resetting to 0');}draft.modalCount=0;}break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{createSelector}from'reselect';/**
|
|
2
|
+
* Retrieves the a11y state from the store.
|
|
3
|
+
* @param {Object} state The current application state.
|
|
4
|
+
* @return {Object} The a11y state.
|
|
5
|
+
*/var getState=function getState(state){return state.a11y;};/**
|
|
6
|
+
* Creates a selector that returns the number of currently open modals.
|
|
7
|
+
* @type {(state: any) => number}
|
|
8
|
+
*/export var getModalCount=createSelector(getState,function(a11y){return a11y.modalCount;});
|
|
@@ -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{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables,colors=themeConfig.colors;var leftColumnWidth=72;var item=css({padding:variables.gap.big,/** Row is DOM reversed for a11y navigation */flexDirection:'row-reverse'}).toString();var leftColumn=css({width:leftColumnWidth}).toString();var image=css({background:colors.placeholder,marginBottom:variables.gap.small*1.25,height:leftColumnWidth,width:leftColumnWidth}).toString();var content=css({display:'flex',flexDirection:'column',paddingLeft:variables.gap.big}).toString();var info=css({fontSize:'0.875rem',marginTop:variables.gap.big*0.875,marginBottom:variables.gap.small*0.25,flexGrow:1,alignItems:'flex-end',justifyContent:'space-between'}).toString();var promotionLine=css({marginTop:0}).toString();var promotionLineItem=css({width:'100%'}).toString();var priceInfo=css({textAlign:'right',wordBreak:'break-word'}).toString();var disclaimerSpacer=css({width:10}).toString();var price=css({display:'flex',marginLeft:'1em',alignItems:'flex-end',flexDirection:'column'}).toString();var properties=css(_defineProperty({wordBreak:'break-word',alignSelf:'flex-start',fontSize:'0.875rem',color:colors.
|
|
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{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables,colors=themeConfig.colors;var leftColumnWidth=72;var item=css({padding:variables.gap.big,/** Row is DOM reversed for a11y navigation */flexDirection:'row-reverse'}).toString();var leftColumn=css({width:leftColumnWidth}).toString();var image=css({background:colors.placeholder,marginBottom:variables.gap.small*1.25,height:leftColumnWidth,width:leftColumnWidth}).toString();var content=css({display:'flex',flexDirection:'column',paddingLeft:variables.gap.big}).toString();var info=css({fontSize:'0.875rem',marginTop:variables.gap.big*0.875,marginBottom:variables.gap.small*0.25,flexGrow:1,alignItems:'flex-end',justifyContent:'space-between'}).toString();var promotionLine=css({marginTop:0}).toString();var promotionLineItem=css({width:'100%'}).toString();var priceInfo=css({textAlign:'right',wordBreak:'break-word'}).toString();var disclaimerSpacer=css({width:10}).toString();var price=css({display:'flex',marginLeft:'1em',alignItems:'flex-end',flexDirection:'column'}).toString();var properties=css(_defineProperty({wordBreak:'break-word',alignSelf:'flex-start',fontSize:'0.875rem',color:"var(--color-text-medium-emphasis, ".concat(colors.shade6,")"),lineHeight:1.3},":not(:empty) + .".concat(price),{textAlign:'right',maxWidth:'40%'})).toString();var itemInactive=css(_defineProperty({' *':{color:'var(--color-text-low-emphasis) !important'}}," .".concat(image),{opacity:0.7})).toString();var orderDetailsSubtotalLabel=css({color:"var(--color-text-low-emphasis, ".concat(colors.shade9,")")}).toString();export default{item:item,itemInactive:itemInactive,leftColumn:leftColumn,image:image,content:content,info:info,promotionLine:promotionLine,promotionLineItem:promotionLineItem,disclaimerSpacer:disclaimerSpacer,priceInfo:priceInfo,price:price,properties:properties,orderDetailsSubtotalLabel:orderDetailsSubtotalLabel};
|
|
@@ -4,7 +4,7 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
|
|
|
4
4
|
* @returns {JSX}
|
|
5
5
|
*/var CartItemProductProvider=function CartItemProductProvider(_ref){var currency=_ref.currency,deleteProduct=_ref.deleteProduct,updateProduct=_ref.updateProduct,onFocus=_ref.onFocus,cartItem=_ref.cartItem,isEditable=_ref.isEditable,children=_ref.children,isAndroid=_ref.isAndroid,currencyOverride=_ref.currencyOverride;var id=cartItem.id,product=cartItem.product,quantity=cartItem.quantity,_cartItem$fulfillment=cartItem.fulfillment,fulfillment=_cartItem$fulfillment===void 0?null:_cartItem$fulfillment,_cartItem$messages=cartItem.messages,messages=_cartItem$messages===void 0?[]:_cartItem$messages,status=cartItem.status,subStatus=cartItem.subStatus,orderedQuantity=cartItem.orderedQuantity,unitPromoAmount=cartItem.unitPromoAmount,unitDiscountAmount=cartItem.unitDiscountAmount,price=cartItem.price,promoAmount=cartItem.promoAmount,discountAmount=cartItem.discountAmount,extendedPrice=cartItem.extendedPrice,appliedPromotions=cartItem.appliedPromotions;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),editMode=_useState2[0],setEditMode=_useState2[1];var cartItemRef=useRef();var handleRemove=useCallback(function(){deleteProduct(id);},[deleteProduct,id]);var handleUpdate=useCallback(function(updatedQuantity){updateProduct(id,updatedQuantity);},[id,updateProduct]);var toggleEditMode=useCallback(function(isEnabled){if(isAndroid&&isEnabled){/**
|
|
6
6
|
* When the user focuses the quantity input, the keyboard will pop up an overlap the input.
|
|
7
|
-
*
|
|
7
|
+
* Therefor the input has to be scrolled into the viewport again. Since between the focus and
|
|
8
8
|
* the keyboard appearance some time ticks away, the execution of the scroll code is delayed.
|
|
9
9
|
*
|
|
10
10
|
* This should not happen on iOS devices, since their web views behave different.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React,{useCallback}from'react';import PropTypes from'prop-types';import{Grid,I18n,ContextMenu,SurroundPortals,TextLink}from'@shopgate/engage/components';import{CART_ITEM_CONTEXT_MENU,
|
|
1
|
+
import React,{useCallback}from'react';import PropTypes from'prop-types';import{Grid,I18n,ContextMenu,SurroundPortals,TextLink}from'@shopgate/engage/components';import{CART_ITEM_CONTEXT_MENU,CART_ITEM_CONTEXT_MENU_ITEM_REMOVE,CART_ITEM_NAME}from'@shopgate/engage/cart';import{CartContextMenuItemChangeLocation,CartContextMenuItemChangeFulfillment}from'@shopgate/engage/locations';import{ITEM_PATH,ProductName}from'@shopgate/engage/product';import{bin2hex}from'@shopgate/pwa-common/helpers/data';import{useCartItem,useCartItemProduct}from"./CartItem.hooks";import{menuToggleButton,menuToggleContainer,title,menuContainer}from"./CartItemProductTitle.style";import{ConditionalWrapper}from"../../../components";var contextMenuClasses={button:menuToggleButton,container:menuToggleContainer};/**
|
|
2
2
|
* The Cart Product Title component.
|
|
3
3
|
* @param {Object} props The component properties.
|
|
4
4
|
* @param {string} props.value The product name
|
|
5
5
|
* @param {string} props.productId The product id
|
|
6
6
|
* @returns {JSX.Element}
|
|
7
|
-
*/export function CartItemProductTitle(_ref){var value=_ref.value,productId=_ref.productId;var _useCartItem=useCartItem(),invokeFulfillmentAction=_useCartItem.invokeFulfillmentAction;var context=useCartItemProduct();var handleRemove=context.handleRemove,toggleEditMode=context.toggleEditMode,cartItem=context.cartItem,isEditable=context.isEditable;var
|
|
7
|
+
*/export function CartItemProductTitle(_ref){var value=_ref.value,productId=_ref.productId;var _useCartItem=useCartItem(),invokeFulfillmentAction=_useCartItem.invokeFulfillmentAction;var context=useCartItemProduct();var handleRemove=context.handleRemove,toggleEditMode=context.toggleEditMode,cartItem=context.cartItem,isEditable=context.isEditable;var handleChangeLocationClick=useCallback(function(){if(!cartItem||!cartItem.fulfillment||!cartItem.fulfillment.method){return;}var method=cartItem.fulfillment.method;invokeFulfillmentAction('changeLocation',method);},[cartItem,invokeFulfillmentAction]);var handleChangeFulfillmentClick=useCallback(function(){invokeFulfillmentAction('changeFulfillment');},[invokeFulfillmentAction]);return React.createElement(Grid,null,React.createElement(Grid.Item,{grow:1},React.createElement(ConditionalWrapper,{condition:isEditable,wrapper:function wrapper(children){return React.createElement(TextLink,{href:"".concat(ITEM_PATH,"/").concat(bin2hex(productId))},children);}},React.createElement(ProductName,{name:value,className:title,portalName:CART_ITEM_NAME,portalProps:context,testId:value,ellipsis:false}))),isEditable&&React.createElement(Grid.Item,{className:menuContainer,shrink:0},React.createElement(SurroundPortals,{portalName:CART_ITEM_CONTEXT_MENU,portalProps:{context:context,handleRemove:handleRemove,toggleEditMode:toggleEditMode}},React.createElement(ContextMenu,{classes:contextMenuClasses},React.createElement(SurroundPortals,{portalName:CART_ITEM_CONTEXT_MENU_ITEM_REMOVE,portalProps:{context:context,handleRemove:handleRemove}},React.createElement("div",{"data-test-id":"cartItemContextMenuItemRemove"},React.createElement(ContextMenu.Item,{onClick:handleRemove},React.createElement(I18n.Text,{string:"cart.remove"})))),React.createElement(CartContextMenuItemChangeLocation,{cartItem:context.cartItem,onClick:handleChangeLocationClick}),React.createElement(CartContextMenuItemChangeFulfillment,{cartItem:context.cartItem,onClick:handleChangeFulfillmentClick})))));}
|
|
@@ -11,7 +11,7 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
|
|
|
11
11
|
* @param {Object} event The event object.
|
|
12
12
|
*/_defineProperty(_this2,"handleInputClick",function(event){// Prevent the native focus event ...
|
|
13
13
|
event.stopPropagation();event.preventDefault();if(_this2.props.onToggleEditMode){_this2.props.onToggleEditMode(true);}});/**
|
|
14
|
-
* Event handler for the
|
|
14
|
+
* Event handler for the onFocus event of the input.
|
|
15
15
|
*/_defineProperty(_this2,"handleInputFocus",function(){if(_this2.props.onToggleEditMode){_this2.props.onToggleEditMode(true);}});/**
|
|
16
16
|
* Event handler for the onSubmit event of the form which wraps the input.
|
|
17
17
|
* @param {Object} event The event object.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React,{useCallback}from'react';import PropTypes from'prop-types';import compose from'lodash/fp/compose';import Glow from'@shopgate/pwa-ui-shared/Glow';import{getItemClass}from"./style";/**
|
|
2
2
|
* A delay in ms after that the closeMenu callback gets triggered.
|
|
3
3
|
* @type {number}
|
|
4
4
|
*/var CLOSE_DELAY=250;/**
|
|
5
5
|
* The Context Menu Item component.
|
|
6
6
|
* @param {Object} props The component props.
|
|
7
7
|
* @returns {JSX.Element}
|
|
8
|
-
*/var Item=function Item(_ref){var children=_ref.children,closeMenu=_ref.closeMenu,onClick=_ref.onClick;var handleClick=compose(onClick,function(){return setTimeout(closeMenu,CLOSE_DELAY);});return React.createElement(Glow,null,React.createElement("
|
|
8
|
+
*/var Item=function Item(_ref){var children=_ref.children,closeMenu=_ref.closeMenu,onClick=_ref.onClick;var handleClick=compose(onClick,function(){return setTimeout(closeMenu,CLOSE_DELAY);});var handleKeyPress=useCallback(function(event){if(event.key==='Enter'||event.key===' '){event.preventDefault();handleClick(event);}},[handleClick]);return React.createElement(Glow,null,React.createElement("div",{className:getItemClass(),onClick:handleClick,role:"button","data-test-id":"contextMenuButton",onKeyDown:handleKeyPress,tabIndex:0},children));};Item.defaultProps={children:null,closeMenu:function closeMenu(){},onClick:function onClick(){}};export default Item;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React from'react';import{createPortal}from'react-dom';import
|
|
1
|
+
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);}import React from'react';import{createPortal}from'react-dom';import classNames from'classnames';import{useTrackModalState}from'@shopgate/engage/a11y/hooks';import{Sheet}from'@shopgate/engage/components';var node=document.getElementById('portals');/**
|
|
2
2
|
* @param {Object} props The props to be passed to the Sheet.
|
|
3
|
-
* @returns {JSX}
|
|
4
|
-
*/function SheetDrawer(props){
|
|
3
|
+
* @returns {JSX.Element}
|
|
4
|
+
*/function SheetDrawer(props){// Track modal visibility for accessibility purposes.
|
|
5
|
+
useTrackModalState(props.isOpen);return createPortal(React.createElement(Sheet,_extends({},props,{className:classNames(props.className,'engage__sheet-drawer')})),node);}export default SheetDrawer;
|
|
@@ -24,5 +24,5 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
24
24
|
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){var scrollTop;if(this.ref.current===window){scrollTop=window.scrollY;}else{scrollTop=this.ref.current.scrollTop;}router.update(this.context.id,{scrollTop:scrollTop},false);event.removeCallback(EVENT_KEYBOARD_WILL_CHANGE,this.handleKeyboardChange);}/**
|
|
25
25
|
* @returns {Object}
|
|
26
26
|
*/},{key:"style",get:function get(){var noScrollOnKeyboard=this.props.noScrollOnKeyboard;var keyboardHeight=this.state.keyboardHeight;var overflow='inherit';if(this.scrollContainer){overflow=noScrollOnKeyboard&&keyboardHeight>0?'hidden':'auto';}return{overflow:overflow,paddingBottom:"calc(var(--tabbar-height) + ".concat(keyboardHeight,"px)")};}},{key:"render",value:/**
|
|
27
|
-
* @return {JSX}
|
|
28
|
-
*/function render(){return React.createElement(Swipeable,{onSwiped:this.handleSwipe,flickThreshold:0.6,delta:10},React.createElement("article",{className:"".concat(styles," engage__view__content ").concat(this.props.className),ref:this.scrollContainer?this.ref:null,style:this.style},React.createElement(Helmet,{title:appConfig.shopName}),React.createElement(Above,null),React.createElement(ResponsiveContainer,{breakpoint:">xs",webOnly:true},this.props.visible?React.createElement("div",{id:"PageHeaderBelow"}):null),React.createElement(ConditionalWrapper,{condition:!this.props.noContentPortal,wrapper:function wrapper(children){return React.createElement(SurroundPortals,{portalName:VIEW_CONTENT},children);}},this.props.children),React.createElement(Below,null)));}}],[{key:"getDerivedStateFromProps",value:function getDerivedStateFromProps(props,state){if(props.visible||state.keyboardHeight===0){return null;}return{keyboardHeight:0};}}]);}(Component);_defineProperty(ViewContent,"contextType",RouteContext);_defineProperty(ViewContent,"defaultProps",{className:'',children:null,noScrollOnKeyboard:false,noContentPortal:false,noKeyboardListener:false});export default(function(props){return React.createElement(RouteContext.Consumer,null,function(_ref2){var visible=_ref2.visible,_ref2$pattern=_ref2.pattern,pattern=_ref2$pattern===void 0?'':_ref2$pattern,_ref2$is=_ref2.is404,is404=_ref2$is===void 0?false:_ref2$is;return React.createElement(ViewContent,_extends({},props,{visible:visible,className:"route_".concat(is404?'404':pattern.replace(/[:/]/g,'_'))}));});});
|
|
27
|
+
* @return {JSX.Element}
|
|
28
|
+
*/function render(){return React.createElement(Swipeable,{onSwiped:this.handleSwipe,flickThreshold:0.6,delta:10},React.createElement("article",{className:"".concat(styles," engage__view__content ").concat(this.props.className),ref:this.scrollContainer?this.ref:null,style:this.style,role:"none"},React.createElement(Helmet,{title:appConfig.shopName}),React.createElement(Above,null),React.createElement(ResponsiveContainer,{breakpoint:">xs",webOnly:true},this.props.visible?React.createElement("div",{id:"PageHeaderBelow"}):null),React.createElement(ConditionalWrapper,{condition:!this.props.noContentPortal,wrapper:function wrapper(children){return React.createElement(SurroundPortals,{portalName:VIEW_CONTENT},children);}},this.props.children),React.createElement(Below,null)));}}],[{key:"getDerivedStateFromProps",value:function getDerivedStateFromProps(props,state){if(props.visible||state.keyboardHeight===0){return null;}return{keyboardHeight:0};}}]);}(Component);_defineProperty(ViewContent,"contextType",RouteContext);_defineProperty(ViewContent,"defaultProps",{className:'',children:null,noScrollOnKeyboard:false,noContentPortal:false,noKeyboardListener:false});export default(function(props){return React.createElement(RouteContext.Consumer,null,function(_ref2){var visible=_ref2.visible,_ref2$pattern=_ref2.pattern,pattern=_ref2$pattern===void 0?'':_ref2$pattern,_ref2$is=_ref2.is404,is404=_ref2$is===void 0?false:_ref2$is;return React.createElement(ViewContent,_extends({},props,{visible:visible,className:"route_".concat(is404?'404':pattern.replace(/[:/]/g,'_'))}));});});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{Component}from'react';import PropTypes from'prop-types';import delay from'lodash/delay';import
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{Component}from'react';import PropTypes from'prop-types';import delay from'lodash/delay';import{connect}from'react-redux';import{UIEvents}from'@shopgate/engage/core/events';import{getModalCount}from'@shopgate/engage/a11y/selectors';import{emitScrollEvents}from'@shopgate/engage/core/streams';import{MODAL_EVENTS}from'@shopgate/engage/components';import{ViewContext}from"./context";/**
|
|
2
|
+
* @param {Object} state State
|
|
3
|
+
* @returns {Object}
|
|
4
|
+
*/var mapStateToProps=function mapStateToProps(state){return{modalCount:getModalCount(state)};};/**
|
|
2
5
|
* The ViewProvider component.
|
|
3
6
|
*/var ViewProvider=/*#__PURE__*/function(_Component){function ViewProvider(props){var _this2;_classCallCheck(this,ViewProvider);_this2=_callSuper(this,ViewProvider,[props]);_defineProperty(_this2,"handleModalShow",function(){_this2.activeElement=document.activeElement;_this2.setAriaHidden(true);});_defineProperty(_this2,"handleModalHide",function(){if(_this2.activeElement&&_this2.activeElement.focus){_this2.activeElement.focus();}_this2.setAriaHidden(false);});/**
|
|
4
7
|
* @param {number} value The new top value;
|
|
@@ -17,9 +20,9 @@ delay(function(){return emitScrollEvents(ref.current);},250);});/**
|
|
|
17
20
|
*/_defineProperty(_this2,"scrollTop",function(){var value=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var current=_this2.state.contentRef.current;if(current){current.scrollTop=value;}});/**
|
|
18
21
|
* @param {string} property The state property to set.
|
|
19
22
|
* @param {*} value The value to set.
|
|
20
|
-
*/_defineProperty(_this2,"set",function(property,value){if(_this2.state[property]!==value){_this2.setState(_defineProperty({},property,value));}});_this2.state={top:0,bottom:0,contentRef:{current:null},ariaHidden:
|
|
21
|
-
_this2.activeElement=null;return _this2;}/** @inheritDoc */_inherits(ViewProvider,_Component);return _createClass(ViewProvider,[{key:"componentDidMount",value:function componentDidMount(){UIEvents.addListener(MODAL_EVENTS.SHOW,this.handleModalShow);UIEvents.addListener(MODAL_EVENTS.HIDE,this.handleModalHide);}/** @inheritDoc */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(MODAL_EVENTS.SHOW,this.handleModalShow);UIEvents.removeListener(MODAL_EVENTS.HIDE,this.handleModalHide);}/**
|
|
23
|
+
*/_defineProperty(_this2,"set",function(property,value){if(_this2.state[property]!==value){_this2.setState(_defineProperty({},property,value));}});_this2.state={top:0,bottom:0,contentRef:{current:null},ariaHidden:props.modalCount>0};// Last view active element
|
|
24
|
+
_this2.activeElement=null;return _this2;}/** @inheritDoc */_inherits(ViewProvider,_Component);return _createClass(ViewProvider,[{key:"componentDidMount",value:function componentDidMount(){UIEvents.addListener(MODAL_EVENTS.SHOW,this.handleModalShow);UIEvents.addListener(MODAL_EVENTS.HIDE,this.handleModalHide);}/** @inheritDoc */},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(prevProps.modalCount!==this.props.modalCount){this.setAriaHidden(this.props.modalCount>0);}}/** @inheritDoc */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(MODAL_EVENTS.SHOW,this.handleModalShow);UIEvents.removeListener(MODAL_EVENTS.HIDE,this.handleModalHide);}/**
|
|
22
25
|
* @returns {Object}
|
|
23
26
|
*/},{key:"providerContext",get:function get(){return _extends({},this.state,{set:this.set,setTop:this.setTop,setBottom:this.setBottom,setAriaHidden:this.setAriaHidden,setContentRef:this.setContentRef,getContentRef:this.getContentRef,scrollTop:this.scrollTop});}},{key:"render",value:/**
|
|
24
27
|
* @returns {JSX}
|
|
25
|
-
*/function render(){return React.createElement(ViewContext.Provider,{value:this.providerContext},this.props.children);}}]);}(Component);export default ViewProvider;
|
|
28
|
+
*/function render(){return React.createElement(ViewContext.Provider,{value:this.providerContext},this.props.children);}}]);}(Component);export default connect(mapStateToProps)(ViewProvider);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as UIEvents}from'@shopgate/pwa-core/emitters/ui';
|
package/core/helpers/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @module core */import{getCurrentRoute as getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString}from'@shopgate/pwa-common/helpers/router';export*from"./environment";export*from"./appFeatures";export*from"./appPermissions";export*from"./baseUrl";export*from"./bridge";export{isBeta}from"../config/isBeta";export{getFullImageSource}from"./getFullImageSource";export{getImageFormat}from"./getImageFormat";export{i18n,getWeekDaysOrder}from"./i18n";export{updateLegacyNavigationBar}from"./updateLegacyNavigationBar";export{default as nl2br}from"./nl2br";export*from"./string";export{isIOSTheme}from"./isIOSTheme";export{isTouchDevice}from"./isTouchDevice";export{generateGoogleMapsDirectionsUrl}from"./googleMaps";export{useScrollContainer}from"./scrollContainer";export{getDeviceTypeForCms}from"./deviceType";export*from"./featureFlag";// --------------- CORE --------------- //
|
|
2
|
-
export{logger,ajaxUrl,hasSGJavaScriptBridge,useBrowserConnector,hasWebBridgeCore,logDeprecationMessage}from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export{env,isDev,isProd,isRemote,isStaging}from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
2
|
+
export{logger,ajaxUrl,hasSGJavaScriptBridge,useBrowserConnector,hasWebBridgeCore,logDeprecationMessage}from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export{env,isDev,isProd,isRemote,isStaging,isWindows}from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
3
3
|
/*
|
|
4
4
|
export { default as portalCollection } from '@shopgate/pwa-common/helpers/portals/portalCollection';
|
|
5
5
|
export { default as routePortals } from '@shopgate/pwa-common/helpers/portals/routePortals';
|
package/core/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @module core */ // ---------------
|
|
2
|
-
// Emitters
|
|
3
|
-
export{default as UIEvents}from'@shopgate/pwa-core/emitters/ui';// --------------- STORE --------------- //
|
|
1
|
+
/** @module core */ // --------------- STORE --------------- //
|
|
4
2
|
export*from'@shopgate/pwa-common/store';// --------------- CONFIG --------------- //
|
|
5
|
-
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";export*from"./actions";export*from"./action-creators";export*from"./classes";export*from"./collections";export*from"./commands";export*from"./constants";export*from"./contexts";export*from"./helpers";export*from"./hocs";export*from"./hooks";export*from"./initialization";export*from"./providers";export*from"./selectors";export*from"./streams";export*from"./validation";
|
|
3
|
+
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";export*from"./actions";export*from"./action-creators";export*from"./classes";export*from"./collections";export*from"./commands";export*from"./constants";export*from"./contexts";export*from"./events";export*from"./helpers";export*from"./hocs";export*from"./hooks";export*from"./initialization";export*from"./providers";export*from"./selectors";export*from"./streams";export*from"./validation";
|
|
@@ -23,4 +23,4 @@ return items;},[items,offset,useGetFavoriteIdsPipeline]);var allFavoritesLoaded=
|
|
|
23
23
|
* In case of getFavorites pipeline is used, and all favorites are always loaded, "false" as
|
|
24
24
|
* return value might seem a bit weird, but the value is actually used to determine if the
|
|
25
25
|
* load more button is supposed to be shown (not needed if all favorites are already present).
|
|
26
|
-
*/return false;},[filteredItems.length,items.length,useGetFavoriteIdsPipeline]);var _useState3=useState(allFavoritesLoaded),_useState4=_slicedToArray(_useState3,2),showLoadMoreButton=_useState4[0],setShowLoadMoreButton=_useState4[1];var handleLoadMore=useCallback(function(){setOffset(offset+FAVORITES_SHOW_LIMIT);},[offset]);useEffect(function(){setShowLoadMoreButton(allFavoritesLoaded);},[offset,allFavoritesLoaded]);return React.createElement(ConditionalWrapper,{condition:hasMultipleFavoritesListsSupport,wrapperFalsy:function wrapperFalsy(children){return React.createElement("div",{className:styles.rootNoFavoritesLists},children);},wrapper:function wrapper(children){return React.createElement(Card,{className:styles.root},React.createElement(Accordion,{className:"",
|
|
26
|
+
*/return false;},[filteredItems.length,items.length,useGetFavoriteIdsPipeline]);var _useState3=useState(allFavoritesLoaded),_useState4=_slicedToArray(_useState3,2),showLoadMoreButton=_useState4[0],setShowLoadMoreButton=_useState4[1];var handleLoadMore=useCallback(function(){setOffset(offset+FAVORITES_SHOW_LIMIT);},[offset]);useEffect(function(){setShowLoadMoreButton(allFavoritesLoaded);},[offset,allFavoritesLoaded]);return React.createElement(ConditionalWrapper,{condition:hasMultipleFavoritesListsSupport,wrapperFalsy:function wrapperFalsy(children){return React.createElement("div",{className:styles.rootNoFavoritesLists},children);},wrapper:function wrapper(children){return React.createElement(Card,{className:styles.root},React.createElement(Accordion,{className:"",renderAdditionalHeaderContent:function renderAdditionalHeaderContent(){return React.createElement(ListAccordionHeader,{rename:function rename(newName){return _rename(id,newName);},remove:remove,id:id});},renderLabel:function renderLabel(){return React.createElement(ListAccordionLabel,{title:name});},chevronPosition:"left",startOpened:true},children));}},React.createElement(ListContent,{listId:id,items:filteredItems,removeItem:removeItem,addToCart:addToCart,onLoadMore:handleLoadMore,showLoadMoreButton:showLoadMoreButton}));};FavoriteList.defaultProps={hasMultipleFavoritesListsSupport:false,useGetFavoriteIdsPipeline:false};export default connect(makeMapStateToProps,mapDispatchToProps)(FavoriteList);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import{SELECT_LOCATION}from"../constants";/**
|
|
2
2
|
* Creates the dispatched SELECT_LOCATION action object.
|
|
3
3
|
* @param {Object} location The location data to store for the use.
|
|
4
|
+
* @param {boolean} showToast Whether to show a toast message.
|
|
4
5
|
* @returns {Object}
|
|
5
|
-
*/var selectLocation=function selectLocation(location){return{type:SELECT_LOCATION,location:location};};export default selectLocation;
|
|
6
|
+
*/var selectLocation=function selectLocation(location,showToast){return{type:SELECT_LOCATION,location:location,showToast:showToast};};export default selectLocation;
|
|
@@ -16,4 +16,4 @@ import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shop
|
|
|
16
16
|
* @param {boolean} [params.enableInLocationFinder=false] When set to `true` only locations are
|
|
17
17
|
* returned which are enabled for the location finder.
|
|
18
18
|
* @returns {Function} A redux thunk.
|
|
19
|
-
*/function fetchLocations(params){return function(dispatch){dispatch(requestLocations(params));var filters={countryCode:params.countryCode};if(params.geolocation){filters.longitude=params.geolocation.longitude;filters.latitude=params.geolocation.latitude;}if(params.postalCode){filters.postalCode=params.postalCode;}if(params.enableInLocationFinder){filters.enableInLocationFinder=params.enableInLocationFinder;}if(params.radius){filters.radius=params.radius;}if(params.codes){filters.codes=params.codes;}var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_LOCATIONS).setInput(filters).dispatch();request.then(function(result){dispatch(receiveLocations(filters,result.locations));})["catch"](function(error){logger.error(error);dispatch(errorLocations(params,error));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchLocations);
|
|
19
|
+
*/function fetchLocations(params){return function(dispatch){dispatch(requestLocations(params));var filters={countryCode:params.countryCode};if(params.geolocation){filters.longitude=params.geolocation.longitude;filters.latitude=params.geolocation.latitude;}if(params.postalCode){filters.postalCode=params.postalCode;}if(params.enableInLocationFinder){filters.enableInLocationFinder=params.enableInLocationFinder;}if(params.radius){filters.radius=params.radius;}if(params.codes){filters.codes=params.codes;}if(params.limit){filters.limit=params.limit;}if(params.offset){filters.offset=params.offset;}var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_LOCATIONS).setInput(filters).dispatch();request.then(function(result){dispatch(receiveLocations(filters,result.locations));})["catch"](function(error){logger.error(error);dispatch(errorLocations(params,error));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchLocations);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
var _excluded=["allowClose"];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{FulfillmentProvider,openSheet}from"../../providers";import{FulfillmentSheetContent}from"./FulfillmentSheetContent";/**
|
|
1
|
+
var _excluded=["allowClose"];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 PropTypes from'prop-types';import{FulfillmentProvider,openSheet}from"../../providers";import{FulfillmentSheetContent}from"./FulfillmentSheetContent";/**
|
|
2
2
|
* Renders the fulfillment sheet.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
|
-
* @
|
|
5
|
-
|
|
4
|
+
* @param {boolean} props.allowClose Whether the sheet can be closed via a button
|
|
5
|
+
* @returns {JSX.Element}
|
|
6
|
+
*/export var FulfillmentSheet=function FulfillmentSheet(_ref){var _ref$allowClose=_ref.allowClose,allowClose=_ref$allowClose===void 0?true:_ref$allowClose,props=_objectWithoutProperties(_ref,_excluded);return React.createElement(FulfillmentProvider,props,React.createElement(FulfillmentSheetContent,{allowClose:allowClose}));};FulfillmentSheet.defaultProps={allowClose:true};FulfillmentSheet.open=openSheet;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import*as React from'react';import{FulfillmentContext}from"../../locations.context";import{STAGE_SELECT_STORE,STAGE_RESERVE_FORM,STAGE_RESPONSE_SUCCESS,STAGE_RESPONSE_ERROR,STAGE_FULFILLMENT_METHOD}from"../../constants";import SheetDrawer from"../../../components/SheetDrawer";import{StoreList}from"../StoreList";import{ReserveForm}from"../ReserveForm";import{ReservationSuccess,ReservationError}from"../ReservationResponses";import{FulfillmentPath}from"../FulfillmentPath";import{sheet}from"./FulfillmentSheet.style";/**
|
|
1
|
+
import*as React from'react';import PropTypes from'prop-types';import{FulfillmentContext}from"../../locations.context";import{STAGE_SELECT_STORE,STAGE_RESERVE_FORM,STAGE_RESPONSE_SUCCESS,STAGE_RESPONSE_ERROR,STAGE_FULFILLMENT_METHOD}from"../../constants";import SheetDrawer from"../../../components/SheetDrawer";import{StoreList}from"../StoreList";import{ReserveForm}from"../ReserveForm";import{ReservationSuccess,ReservationError}from"../ReservationResponses";import{FulfillmentPath}from"../FulfillmentPath";import{sheet}from"./FulfillmentSheet.style";/**
|
|
2
2
|
* Renders the content of the fulfillment sheet.
|
|
3
|
-
* @
|
|
4
|
-
|
|
3
|
+
* @param {Object} props The component props.
|
|
4
|
+
* @param {boolean} props.allowClose Whether the sheet can be closed via a button
|
|
5
|
+
* @return {JSX.Element}
|
|
6
|
+
*/export var FulfillmentSheetContent=function FulfillmentSheetContent(_ref){var _ref$allowClose=_ref.allowClose,allowClose=_ref$allowClose===void 0?true:_ref$allowClose;var _React$useContext=React.useContext(FulfillmentContext),isStage=_React$useContext.isStage,title=_React$useContext.title,isOpen=_React$useContext.isOpen,handleClose=_React$useContext.handleClose,isLoading=_React$useContext.isLoading;return React.createElement(SheetDrawer,{isOpen:isOpen,title:title,onDidClose:handleClose,allowClose:allowClose,isLoading:isLoading},React.createElement("div",{className:sheet},isStage(STAGE_SELECT_STORE)&&React.createElement(StoreList,null),isStage(STAGE_RESERVE_FORM)&&React.createElement(ReserveForm,null),isStage(STAGE_RESPONSE_SUCCESS)&&React.createElement(ReservationSuccess,null),isStage(STAGE_RESPONSE_ERROR)&&React.createElement(ReservationError,null),isStage(STAGE_FULFILLMENT_METHOD)&&React.createElement(FulfillmentPath,null)));};FulfillmentSheetContent.defaultProps={allowClose:true};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import*as React from'react';import{css}from'glamor';import{connect}from'react-redux';import classNames from'classnames';import defaultsDeep from'lodash/defaultsDeep';import{makeGetLocationInventory}from"../../selectors";import{getThemeSettings}from"../../../core";import{SurroundPortals}from"../../../components";import{PRODUCT_LOCATION_STOCK_INFO}from"../../constants";import{getAvailabilitySettings}from"../../helpers";import defaultSettings from"./StockInfo.defaultSettings";import{StockInfoInventory}from"./StockInfoInventory";/**
|
|
1
|
+
import*as React from'react';import{css}from'glamor';import{connect}from'react-redux';import classNames from'classnames';import defaultsDeep from'lodash/defaultsDeep';import PropTypes from'prop-types';import{makeGetLocationInventory}from"../../selectors";import{getThemeSettings}from"../../../core";import{SurroundPortals}from"../../../components";import{PRODUCT_LOCATION_STOCK_INFO}from"../../constants";import{getAvailabilitySettings}from"../../helpers";import defaultSettings from"./StockInfo.defaultSettings";import{StockInfoInventory}from"./StockInfoInventory";/**
|
|
2
2
|
* Creates a mapper for redux.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/var makeMapStateToProps=function makeMapStateToProps(){var getInventory=makeGetLocationInventory(function(_,props){var _props$location;return(_props$location=props.location)===null||_props$location===void 0?void 0:_props$location.code;},function(_,props){var _props$product;return props.productId||((_props$product=props.product)===null||_props$product===void 0?void 0:_props$product.id);});return function(state,props){return{inventory:getInventory(state,props)};};};/**
|
|
5
5
|
* Renders visible stock information based on the given location.
|
|
6
6
|
* @param {Object} props The component props.
|
|
7
7
|
* @return {JSX}
|
|
8
|
-
*/var StockInfoUnwrapped=function StockInfoUnwrapped(_ref){var location=_ref.location,inventory=_ref.inventory,className=_ref.className;var _ref2=getThemeSettings('product')||{},locationStockInfo=_ref2.locationStockInfo;var settings=defaultsDeep(locationStockInfo,defaultSettings);var _getAvailabilitySetti=getAvailabilitySettings(settings,location,inventory),_getAvailabilitySetti2=_getAvailabilitySetti.availabilityText,availabilityText=_getAvailabilitySetti2===void 0?'':_getAvailabilitySetti2,_getAvailabilitySetti3=_getAvailabilitySetti.availabilityTextColor,availabilityTextColor=_getAvailabilitySetti3===void 0?'inherit':_getAvailabilitySetti3,_getAvailabilitySetti4=_getAvailabilitySetti.comingSoon,comingSoon=_getAvailabilitySetti4===void 0?false:_getAvailabilitySetti4;var defaultClassName=css({color:availabilityTextColor,fontSize:'0.75rem',margin:0,':not(:empty) ~ *':{marginLeft:14}}).toString();var portalProps=React.useMemo(function(){return{location:location,inventory:inventory,comingSoon:comingSoon,settings:settings,className:className,availabilityText:availabilityText,availabilityTextColor:availabilityTextColor};},[availabilityText,availabilityTextColor,className,comingSoon,inventory,location,settings]);return React.createElement(SurroundPortals,{portalName:PRODUCT_LOCATION_STOCK_INFO,portalProps:portalProps},React.createElement("span",{className:classNames(defaultClassName,css(className).toString())},React.createElement(StockInfoInventory,{availabilityText:availabilityText,comingSoon:comingSoon,location:location,inventory:inventory,maxNumberVisible:settings.maxNumberOfVisibleInventory,aboveMaxExtension:settings.aboveMaxExtension})));};StockInfoUnwrapped.defaultProps={className:null};export var StockInfo=connect(makeMapStateToProps)(StockInfoUnwrapped);
|
|
8
|
+
*/var StockInfoUnwrapped=function StockInfoUnwrapped(_ref){var location=_ref.location,inventory=_ref.inventory,className=_ref.className;var _ref2=getThemeSettings('product')||{},locationStockInfo=_ref2.locationStockInfo;var settings=defaultsDeep(locationStockInfo,defaultSettings);var _getAvailabilitySetti=getAvailabilitySettings(settings,location,inventory),_getAvailabilitySetti2=_getAvailabilitySetti.availabilityText,availabilityText=_getAvailabilitySetti2===void 0?'':_getAvailabilitySetti2,_getAvailabilitySetti3=_getAvailabilitySetti.availabilityTextColor,availabilityTextColor=_getAvailabilitySetti3===void 0?'inherit':_getAvailabilitySetti3,_getAvailabilitySetti4=_getAvailabilitySetti.comingSoon,comingSoon=_getAvailabilitySetti4===void 0?false:_getAvailabilitySetti4;var defaultClassName=css({color:availabilityTextColor,fontSize:'0.75rem',margin:0,':not(:empty) ~ *':{marginLeft:14}}).toString();var portalProps=React.useMemo(function(){return{location:location,inventory:inventory,comingSoon:comingSoon,settings:settings,className:className,availabilityText:availabilityText,availabilityTextColor:availabilityTextColor};},[availabilityText,availabilityTextColor,className,comingSoon,inventory,location,settings]);return React.createElement(SurroundPortals,{portalName:PRODUCT_LOCATION_STOCK_INFO,portalProps:portalProps},React.createElement("span",{className:classNames(defaultClassName,css(className).toString())},React.createElement(StockInfoInventory,{availabilityText:availabilityText,comingSoon:comingSoon,location:location,inventory:inventory,maxNumberVisible:settings.maxNumberOfVisibleInventory,aboveMaxExtension:settings.aboveMaxExtension})));};StockInfoUnwrapped.defaultProps={className:null,inventory:null};export var StockInfo=connect(makeMapStateToProps)(StockInfoUnwrapped);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as React from'react';import{I18n}from"../../../components";/**
|
|
1
|
+
import*as React from'react';import PropTypes from'prop-types';import{I18n}from"../../../components";/**
|
|
2
2
|
* Renders the inventory given by the location into a given translation string.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @param {string} props.availabilityText The translation string to use.
|
|
@@ -6,4 +6,4 @@ import*as React from'react';import{I18n}from"../../../components";/**
|
|
|
6
6
|
* @param {number|undefined} props.maxNumberVisible The component props.
|
|
7
7
|
* @param {string} props.aboveMaxExtension The component props.
|
|
8
8
|
* @return {JSX}
|
|
9
|
-
*/export function StockInfoInventory(props){var availabilityText=props.availabilityText,comingSoon=props.comingSoon,location=props.location,inventory=props.inventory,maxNumberVisible=props.maxNumberVisible,aboveMaxExtension=props.aboveMaxExtension;var visibleInventory=React.useMemo(function(){if(!location||!inventory){return null;}if(inventory.visible!==null&&inventory.visible>maxNumberVisible){return"".concat(maxNumberVisible).concat(aboveMaxExtension);}return inventory.visible;},[aboveMaxExtension,inventory,location,maxNumberVisible]);if((!location||!availabilityText||!inventory)&&!comingSoon){return null;}return React.createElement(I18n.Text,{string:availabilityText,params:{visibleInventory:visibleInventory}});}StockInfoInventory.defaultProps={comingSoon:false};
|
|
9
|
+
*/export function StockInfoInventory(props){var availabilityText=props.availabilityText,comingSoon=props.comingSoon,location=props.location,inventory=props.inventory,maxNumberVisible=props.maxNumberVisible,aboveMaxExtension=props.aboveMaxExtension;var visibleInventory=React.useMemo(function(){if(!location||!inventory){return null;}if(inventory.visible!==null&&inventory.visible>maxNumberVisible){return"".concat(maxNumberVisible).concat(aboveMaxExtension);}return inventory.visible;},[aboveMaxExtension,inventory,location,maxNumberVisible]);if((!location||!availabilityText||!inventory)&&!comingSoon){return null;}return React.createElement(I18n.Text,{string:availabilityText,params:{visibleInventory:visibleInventory}});}StockInfoInventory.defaultProps={comingSoon:false,inventory:null};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from'react';import{css}from'glamor';import{i18n}from'@shopgate/engage/core/helpers';import{MagnifierIcon,LocatorIcon,Link}from'@shopgate/engage/components';import{themeColors}from'@shopgate/pwa-common/helpers/config';import classNames from'classnames';import{STORE_FINDER_PATTERN}from"../../../constants";var styles={container:css({margin:'16px 0px'}),title:css({fontSize:'20px',fontWeight:'500',color:'var(--color-primary)',marginBottom:'8px'}),inputCell:css({gridArea:'input'}),inputContainer:css({position:'relative',background:themeColors.light,border:"1px solid ".concat(themeColors.shade7),borderRadius:4,display:'flex',alignItems:'center',width:'100%'}),inputIcon:css({padding:0,margin:'0 8px',color:themeColors.shade9,fontSize:'1.23rem',flexShrink:0,outline:0}),input:css({margin:'3px 0',width:'100%',lineHeight:'28px',outline:'none',verticalAlign:'middle',WebkitAppearance:'none'}),inputOverlay:css({position:'absolute',height:'100%',width:'100%'})};/**
|
|
2
|
+
* Find more stores component.
|
|
3
|
+
* @returns {JSX}
|
|
4
|
+
* */var FindMoreStores=function FindMoreStores(){return React.createElement("div",{className:styles.container},React.createElement("div",{className:styles.title,"aria-hidden":true},i18n.text('location.findMoreStores')),React.createElement("div",{className:styles.inputCell},React.createElement("div",{className:styles.inputContainer},React.createElement("span",{className:styles.inputIcon,"aria-hidden":true},React.createElement(MagnifierIcon,null)),React.createElement("input",{name:"postalCode",className:styles.input,disabled:true,type:"search",autoComplete:"off",autoCorrect:"off",placeholder:"","aria-hidden":true}),React.createElement("div",{className:styles.inputIcon},React.createElement(LocatorIcon,null)),React.createElement(Link,{href:STORE_FINDER_PATTERN,className:classNames(styles.inputOverlay),role:"button","aria-label":i18n.text('location.findMoreStores')},React.createElement("div",null)))));};export default FindMoreStores;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React,{useMemo}from'react';import{css}from'glamor';import{historyPush}from'@shopgate/pwa-common/actions/router';import PropTypes from'prop-types';import{Button}from'@shopgate/engage/components';import{generateGoogleMapsDirectionsUrl,i18n}from'@shopgate/engage/core';import{useDispatch}from'react-redux';var styles={container:css({}),buttonText:css({color:'var(--color-primary)'})};/**
|
|
2
|
+
* @param {Object} props The component props
|
|
3
|
+
* @param {Object} props.address The address object.
|
|
4
|
+
* @returns {JSX}
|
|
5
|
+
*/var GetDirectionsButton=function GetDirectionsButton(_ref){var address=_ref.address;var dispatch=useDispatch();var url=useMemo(function(){return address&&generateGoogleMapsDirectionsUrl(address);},[address]);/**
|
|
6
|
+
* Handles the button click.
|
|
7
|
+
*/var handleClick=function handleClick(){dispatch(historyPush({pathname:url,state:{target:'_blank'}}));};return React.createElement("div",{className:styles.container},React.createElement(Button,{onClick:handleClick,role:"button",type:"plain"},React.createElement("span",{className:styles.buttonText},i18n.text('location.getDirections'))));};GetDirectionsButton.defaultProps={address:null};export default GetDirectionsButton;
|
|
@@ -0,0 +1,5 @@
|
|
|
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{css}from'glamor';import{LocationIcon,Button,Link,ConditionalWrapper}from'@shopgate/engage/components';import{getWeekDaysOrder}from'@shopgate/engage/core';import{i18n}from'@shopgate/engage/core/helpers';import classNames from'classnames';import moment from'moment';import{StoreDetailsContext}from"../../../providers/StoreDetailsContext";import GetDirectionsButton from"./GetDirectionsButton";var styles={headerWrapper:css({display:'flex'}),headerIcon:css({color:'var(--color-primary)',fontSize:20,alignContent:'center',marginRight:4}),header:css({color:'var(--color-primary)',fontWeight:'600',fontSize:20}),locationName:css({fontSize:20,fontWeight:'600',marginBottom:8}),locationRow:css({display:'flex',gap:8,flexWrap:'wrap'}),locationColumn:css({flex:1,minWidth:'200px','& > p':{margin:0}}),storeHoursColumn:css({flex:1,minWidth:'250px',maxWidth:'455px'}),storeHours:css({fontSize:17,fontWeight:'600'}),storeHoursLine:css({}),storeHoursWeekday:css({textAlign:'left'}),bold:css({fontWeight:'600'}),storeHoursOpeningTime:css({textAlign:'right'}),phone:css({fontSize:17,fontWeight:'600'}),phoneNumber:css({textDecoration:'underline'}),makeMyStoreButton:css({color:'var(--color-primary)'}),comingSoon:css({fontStyle:'italic'}),buttonRow:css({display:'flex',alignItems:'center',gap:'8px 30px',flexWrap:'wrap',margin:'8px 0'})};/**
|
|
2
|
+
* Store details component.
|
|
3
|
+
* @returns {JSX}
|
|
4
|
+
*/var StoreDetails=function StoreDetails(){var _useContext=useContext(StoreDetailsContext),selectLocation=_useContext.selectLocation,routeLocation=_useContext.routeLocation,isRouteLocationPreferred=_useContext.isRouteLocationPreferred;var _ref=routeLocation||{},_ref$address=_ref.address,address=_ref$address===void 0?{}:_ref$address,_ref$operationHours=_ref.operationHours,operationHours=_ref$operationHours===void 0?{}:_ref$operationHours,isComingSoon=_ref.isComingSoon;var currentDay=moment().format('ddd').toLowerCase();// Check if there are any opening hours to hide the section if not
|
|
5
|
+
var hasOpeningHours=useMemo(function(){return Object.keys(operationHours).length>0&&Object.values(operationHours).some(function(value){return value&&typeof value==='string'&&value.length>0;});},[operationHours]);if(!routeLocation){return null;}return React.createElement("div",null,React.createElement(ConditionalWrapper,{condition:!isRouteLocationPreferred,wrapper:function wrapper(children){return React.createElement(Button,{onClick:function onClick(){return selectLocation(routeLocation,true);},role:"button",type:"plain"},children);}},React.createElement("div",{className:styles.headerWrapper},React.createElement("div",{className:styles.headerIcon},React.createElement(LocationIcon,{className:styles.icon,size:20})),React.createElement("div",{className:styles.header},isRouteLocationPreferred?i18n.text('location.myStore'):i18n.text('location.makeMyStore')))),React.createElement("div",{className:styles.locationName},routeLocation.name),React.createElement("div",{className:styles.locationRow},React.createElement("div",{className:styles.locationColumn},React.createElement("p",null,address===null||address===void 0?void 0:address.street),(address===null||address===void 0?void 0:address.street2)&&address.street2!==''&&React.createElement("p",null,address.street2),(address===null||address===void 0?void 0:address.street3)&&address.street3!==''&&React.createElement("p",null,address.street3),(address===null||address===void 0?void 0:address.street4)&&address.street4!==''&&React.createElement("p",null,address.street4),React.createElement("p",null,i18n.text('locations.address',address)),React.createElement("div",{className:styles.buttonRow},React.createElement(GetDirectionsButton,{address:address}),!isComingSoon&&!isRouteLocationPreferred&&React.createElement(Button,{onClick:function onClick(){return selectLocation(routeLocation,true);},role:"button",type:"plain",className:classNames(styles.makeMyStoreButton)},React.createElement("span",null,i18n.text('location.makeMyStore'))),isComingSoon&&React.createElement("div",{className:styles.comingSoon},i18n.text('location.comingSoon'))),(address===null||address===void 0?void 0:address.phoneNumber)&&React.createElement(React.Fragment,null,React.createElement("div",{className:styles.phone},"".concat(i18n.text('location.phone'),": ")),React.createElement("div",{className:styles.phoneNumber},React.createElement(Link,{href:"tel:".concat(address.phoneNumber),className:classNames(styles.phoneNumber),target:"_blank",role:"button","aria-label":address.phoneNumber},address.phoneNumber)))),hasOpeningHours&&React.createElement("div",{className:styles.storeHoursColumn},React.createElement("div",{className:styles.storeHours},"".concat(i18n.text('location.storeHours'),":")),React.createElement("table",null,React.createElement("tbody",null,getWeekDaysOrder().map(function(weekDay){if(!operationHours[weekDay]){return null;}return React.createElement("tr",{className:styles.storeHoursLine,key:weekDay,"aria-label":"".concat(i18n.text("locations.".concat(weekDay)),": ").concat(operationHours[weekDay]),tabIndex:0},React.createElement("td",{className:classNames(styles.storeHoursWeekday,_defineProperty({},styles.bold,weekDay===currentDay)),"aria-hidden":true},"".concat(i18n.text("locations.".concat(weekDay)),":")),React.createElement("td",{className:classNames(styles.storeHoursOpeningTime,_defineProperty({},styles.bold,weekDay===currentDay)),"aria-hidden":true},operationHours[weekDay]));}))))));};export default StoreDetails;
|
|
@@ -0,0 +1,20 @@
|
|
|
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,{useCallback,useMemo,useContext,useRef,useEffect}from'react';import{useDispatch}from'react-redux';import{Circle,MapContainer,Marker,TileLayer}from'react-leaflet';import{GestureHandling}from'leaflet-gesture-handling';import"../../../assets/leaflet.css";import'leaflet-gesture-handling/dist/leaflet-gesture-handling.css';import Leaflet from'leaflet';import{renderToString}from'react-dom/server';import MapMarkerIcon from'@shopgate/pwa-ui-shared/icons/MapMarkerIcon';import{historyPush}from'@shopgate/engage/core';import{container,markerSelected}from"./StoreFinderMap.style";import{MAP_RADIUS_KM}from"../../../constants";import{StoreDetailsContext}from"../../../providers/StoreDetailsContext";Leaflet.Map.addInitHook('addHandler','gestureHandling',GestureHandling);/**
|
|
2
|
+
* @returns {JSX.Element}
|
|
3
|
+
*/var StoreFinderMap=function StoreFinderMap(){var mapContainerRef=useRef(null);var dispatch=useDispatch();/**
|
|
4
|
+
* Handles the click on the OpenStreetMap copyright
|
|
5
|
+
* Cause the copyright is only a plain a tag
|
|
6
|
+
* this causes weird routing in the app
|
|
7
|
+
* To prevent this we need to handle the click on the a tag
|
|
8
|
+
* @param {Event} e The event
|
|
9
|
+
* @returns {void}
|
|
10
|
+
* */var handleOpenStreetMapCopyrightClick=useCallback(function(e){if(e.target.tagName==='A'&&e.target.href){e.preventDefault();dispatch(historyPush({pathname:e.target.href}));}},[dispatch]);// check the mapContainerRef if any a tag is clicked
|
|
11
|
+
// to catch the click on the OpenStreetMap copyright
|
|
12
|
+
useEffect(function(){if(mapContainerRef.current){mapContainerRef.current.addEventListener('click',handleOpenStreetMapCopyrightClick);}return function(){if(mapContainerRef.current){mapContainerRef.current.removeEventListener('click',handleOpenStreetMapCopyrightClick);}};},[handleOpenStreetMapCopyrightClick]);var _useContext=useContext(StoreDetailsContext),routeLocation=_useContext.routeLocation;var iconHTML=useMemo(function(){return renderToString(React.createElement(MapMarkerIcon,null));},[]);var markerIconSelected=useMemo(function(){return Leaflet.divIcon({html:iconHTML,className:markerSelected,iconSize:[40,40]});},[iconHTML]);var _ref=routeLocation||{},code=_ref.code,latitude=_ref.latitude,longitude=_ref.longitude;var viewport=useMemo(function(){if(!latitude||!longitude){return null;}return[latitude,longitude];},[latitude,longitude]);/**
|
|
13
|
+
* Enables touch and gestures on the map
|
|
14
|
+
* @param {Object} map available parameters for the map
|
|
15
|
+
*/var handleMapCreated=function handleMapCreated(map){map.gestureHandling.enable();map.attributionControl.setPrefix('');if(Leaflet.Browser.mobile){map.touchZoom.enable();}};/**
|
|
16
|
+
* Creates coordinates for a bounding box around a center point
|
|
17
|
+
* @param {Array} center The center point
|
|
18
|
+
* @param {number} distanceInMeter The distance in meters
|
|
19
|
+
* @returns {Array} The bounds
|
|
20
|
+
*/var createBounds=useCallback(function(_ref2,distanceInMeter){var _ref3=_slicedToArray(_ref2,2),lat=_ref3[0],lng=_ref3[1];var EARTH_RADIUS_KM=6371;var distanceInKm=distanceInMeter/1000;var distanceToBoundaryInKm=distanceInKm/2;var latInRadians=lat*(Math.PI/180);var deltaLat=distanceToBoundaryInKm/EARTH_RADIUS_KM*(180/Math.PI);var deltaLng=distanceToBoundaryInKm/EARTH_RADIUS_KM*(180/Math.PI)/Math.cos(latInRadians);return[[lat-deltaLat,lng-deltaLng],[lat+deltaLat,lng+deltaLng]];},[]);var radiusinMeters=MAP_RADIUS_KM*1000;var bounds=useMemo(function(){if(!viewport||!MAP_RADIUS_KM){return null;}return createBounds(viewport,radiusinMeters);},[createBounds,radiusinMeters,viewport]);var debug=false;if(!routeLocation){return null;}return React.createElement("div",{className:container,"aria-hidden":true,ref:mapContainerRef},React.createElement(MapContainer,{center:viewport,bounds:bounds,className:container,whenCreated:handleMapCreated},debug&&React.createElement(Circle,{center:viewport,radius:radiusinMeters,color:"blue"}),React.createElement(TileLayer,{attribution:"© <a href=\"https://osm.org/copyright\">OpenStreetMap</a>",url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),React.createElement(Marker,{key:code,icon:markerIconSelected,position:[latitude,longitude]})));};export default StoreFinderMap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';export var container=css({height:'100%',width:'100%'});export var markerSelected=css({' svg':{height:40,width:40,fontSize:'1.5rem',color:"var(--color-primary, ".concat(themeColors.primary,")")}}).toString();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React,{useRef}from'react';import{css}from'glamor';import{SurroundPortals}from'@shopgate/engage/components';import StoreFinderMap from"./StoreFinderMap";import{StoreFinderProvider}from"../../../providers";import{STORE_DETAILS_LOCATION_MAP}from"../../../constants/Portals";var styles={container:css({maxHeight:'250px',height:'250px',width:'100%',marginTop:'10px',marginBottom:'10px'}).toString()};/**
|
|
2
|
+
* Store location map component.
|
|
3
|
+
* @returns {JSX.Element}
|
|
4
|
+
*/var StoreLocationMap=function StoreLocationMap(){var storeListRef=useRef(null);return React.createElement(StoreFinderProvider,{storeListRef:storeListRef},React.createElement(SurroundPortals,{portalName:STORE_DETAILS_LOCATION_MAP},React.createElement("div",{className:styles.container},React.createElement(StoreFinderMap,null))));};export default StoreLocationMap;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React,{useContext}from'react';import{css}from'glamor';import{i18n}from'@shopgate/engage/core/helpers';import StoresNearbyListItem from"./StoresNearbyListItem";import{StoreDetailsContext}from"../../../providers/StoreDetailsContext";var styles={title:css({fontSize:20,fontWeight:'600',marginBottom:12}),table:css({width:'100%'})};/**
|
|
2
|
+
* Show stores nearby selected location
|
|
3
|
+
* @returns {JSX}
|
|
4
|
+
*/var StoresNearby=function StoresNearby(){var _useContext=useContext(StoreDetailsContext),nearbyLocations=_useContext.nearbyLocations;return React.createElement("div",null,React.createElement("div",{className:styles.title},i18n.text('location.storesNearby')),nearbyLocations.length>0&&React.createElement("table",{className:styles.table},React.createElement("tbody",null,nearbyLocations.map(function(location){return React.createElement(StoresNearbyListItem,{location:location,key:location.code});}))),nearbyLocations.length===0&&React.createElement("div",null,i18n.text('location.noStoresNearby')));};export default StoresNearby;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React,{useContext}from'react';import{useDispatch}from'react-redux';import PropTypes from'prop-types';import{css}from'glamor';import{Button}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core/helpers';import{historyPush}from'@shopgate/engage/core';import formatDistance from"../../../helpers/formatDistance";import{STORE_DETAILS_PATH}from"../../../constants";import{StoreDetailsContext}from"../../../providers/StoreDetailsContext";var styles={button:css({fontSize:'14px !important',padding:'0px !important'}).toString(),locationRow:css({borderBottom:'1px solid #e8e8e8',borderTop:'1px solid #e8e8e8','> td:first-child > div':{paddingLeft:0},'> td:last-child > div':{paddingRight:0}}),distance:css({textWrapMode:'nowrap',alignContent:'center',verticalAlign:'middle',fontWeight:'500'}),makeMyStore:css({textWrapMode:'nowrap',alignContent:'center',verticalAlign:'middle'}),storeInfo:css({textWrapMode:'nowrap',alignContent:'center',verticalAlign:'middle'}),name:css({textAlign:'start'}),cellContainer:css({padding:'8px',textAlign:'end'}),cell:css({verticalAlign:'middle'}),buttonContainer:css({display:'flex',gap:'4px 16px',flexWrap:'wrap',justifyContent:'flex-end'})};/**
|
|
2
|
+
* Shows a location in a row
|
|
3
|
+
* @param {Object} props Props
|
|
4
|
+
* @param {Object} props.location Location
|
|
5
|
+
* @returns {JSX}
|
|
6
|
+
*/var StoresNearbyListItem=function StoresNearbyListItem(_ref){var location=_ref.location;var dispatch=useDispatch();var _useContext=useContext(StoreDetailsContext),preferredLocation=_useContext.preferredLocation,selectLocation=_useContext.selectLocation;var name=location.name,distance=location.distance,unitSystem=location.unitSystem,code=location.code,isComingSoon=location.isComingSoon;var isPreferredLocation=preferredLocation&&preferredLocation.code===code;/**
|
|
7
|
+
* Opens the store details page
|
|
8
|
+
* @param {string} locationCode Location code
|
|
9
|
+
*/var openStoreDetails=function openStoreDetails(locationCode){dispatch(historyPush({pathname:"".concat(STORE_DETAILS_PATH,"/").concat(locationCode)}));};return React.createElement("tr",{className:styles.locationRow},React.createElement("td",{className:styles.cell},React.createElement("div",{className:styles.cellContainer},React.createElement("div",{className:styles.name},name))),React.createElement("td",{className:styles.cell},React.createElement("div",{className:styles.cellContainer},React.createElement("div",{className:styles.distance},formatDistance(distance||0,unitSystem==='imperial')))),React.createElement("td",{className:styles.cell},React.createElement("div",{className:styles.cellContainer},React.createElement("div",{className:styles.buttonContainer},React.createElement("div",{className:styles.makeMyStore},!isComingSoon&&React.createElement(Button,{className:styles.button,onClick:function onClick(){return selectLocation(location,true);},role:"button",type:"primary",flat:true,disabled:isPreferredLocation,wrapContent:false},"".concat(i18n.text('location.makeMyStore'))),isComingSoon&&React.createElement(Button,{className:styles.button,role:"button",type:"primary",flat:true,disabled:true,wrapContent:false},i18n.text('location.comingSoon'))),React.createElement("div",{className:styles.storeInfo},React.createElement(Button,{className:styles.button,role:"button",type:"primary",flat:true,onClick:function onClick(){return openStoreDetails(code);},wrapContent:false},i18n.text('locations.details')))))));};export default StoresNearbyListItem;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from'react';import{css}from'glamor';import{themeConfig}from'@shopgate/engage';import StoreDetails from"./components/StoreDetails";import StoreLocationMap from"./components/StoreLocationMap";import StoresNearby from"./components/StoresNearby";import FindMoreStores from"./components/FindMoreStores";import{StoreDetailsProvider}from"../../providers";var styles={page:css({padding:"".concat(themeConfig.variables.gap.small,"px ").concat(themeConfig.variables.gap.big,"px")}).toString()};/**
|
|
2
|
+
* @param {Object} props .
|
|
3
|
+
* @returns {JSX}
|
|
4
|
+
*/var StoreDetailsContent=function StoreDetailsContent(){return React.createElement(StoreDetailsProvider,null,React.createElement("div",{className:styles.page},React.createElement(StoreDetails,null),React.createElement(StoreLocationMap,null),React.createElement(StoresNearby,null),React.createElement(FindMoreStores,null)));};export default StoreDetailsContent;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React,{useRef}from'react';import{hot}from'react-hot-loader/root';import{
|
|
2
|
-
* @returns {JSX}
|
|
3
|
-
*/var StoreFinder=function StoreFinder(){var storeListRef=useRef(null);return React.createElement(StoreFinderProvider,{storeListRef:storeListRef},React.createElement("div",{className:container},React.createElement("div",{className:storeSearch},React.createElement(StoreFinderSearch,null)
|
|
1
|
+
import React,{useRef}from'react';import{hot}from'react-hot-loader/root';import{StoreFinderProvider}from"../../providers";import StoreFinderSearch from"./StoreFinderSearch";import StoreFinderLocations from"./StoreFinderLocations";import{container,storeSearch,storeList}from"./StoreFinder.style";/**
|
|
2
|
+
* @returns {JSX.Element}
|
|
3
|
+
*/var StoreFinder=function StoreFinder(){var storeListRef=useRef(null);return React.createElement(StoreFinderProvider,{storeListRef:storeListRef},React.createElement("div",{className:container},React.createElement("div",{className:storeSearch},React.createElement(StoreFinderSearch,null)),React.createElement("div",{className:storeList},React.createElement(StoreFinderLocations,{ref:storeListRef}))));};export default hot(StoreFinder);
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
height:'inherit'}));export var storeSearch=css({gridArea:'search',padding:"".concat(variables.gap.big,"px 4px 0 4px"),' select':{color:'var(--color-text-medium-emphasis)'}});export var storeList=css(_defineProperty({gridArea:'store-list',width:'100%',overflow:'hidden'},responsiveMediaQuery('<=sm',{appAlways:true}),{width:'100%'}));export var storeDetailsMap=css(_defineProperty({gridArea:'map',paddingBottom:variables.gap.big},responsiveMediaQuery('>sm',{webOnly:true}),{paddingRight:variables.gap.big,paddingTop:variables.gap.big,paddingBottom:0}));export var storeDetails=css(_defineProperty({gridArea:'store-details',paddingRight:variables.gap.big,paddingTop:variables.gap.big},responsiveMediaQuery('<=sm',{appAlways:true}),{display:'none'}));
|
|
1
|
+
import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var container=css({display:'grid',gridTemplateColumns:'1fr',gridTemplateRows:'auto 1fr',gridTemplateAreas:'"search" "store-list"',height:'inherit'});export var storeSearch=css({gridArea:'search',padding:"".concat(variables.gap.big,"px 4px 0 4px"),' select':{color:'var(--color-text-medium-emphasis)'}});export var storeList=css({gridArea:'store-list',width:'100%',overflow:'hidden',padding:'0 12px 8px 12px'});
|
|
@@ -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{
|
|
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{StoreContext}from"./Store.context";import{StoreFinderContext}from"../../locations.context";import StoreFinderLocationHeader from"./StoreFinderLocationHeader";import{container,selected}from"./StoreFinderLocation.style";import{StoreFinderSelectLocationButton}from"./StoreFinderSelectLocationButton";import StoreFinderStoreInfoButton from"./StoreFinderStoreInfoButton";/**
|
|
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(
|
|
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(StoreFinderSelectLocationButton,null),React.createElement(StoreFinderStoreInfoButton,null));};export default StoreFinderLocation;
|