@shopgate/engage 7.25.0-beta.5 → 7.25.0

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.
@@ -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,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"../index";/**
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,hidden:true},React.createElement(I18n.Text,{string:title,params:titleParams})),children);}Section.defaultProps={children:null,className:'',titleParams:{}};export default Section;
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;
@@ -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";export{default as FocusTrap}from"./FocusTrap";
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";
@@ -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';
@@ -1,6 +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}from'react';/**
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
2
  * The useReduceMotion hook
3
3
  * to determine whether the user selected reduced motion in the phone settings
4
4
  * @returns {boolean} whether the user prefers reduced motions in the settings
5
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;};
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]);}
@@ -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,4 +1,5 @@
1
- import React from'react';import{createPortal}from'react-dom';import Sheet from'@shopgate/pwa-ui-shared/Sheet';var node=document.getElementById('portals');/**
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){return createPortal(React.createElement(Sheet,props),node);}export default SheetDrawer;
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 UIEvents from'@shopgate/pwa-core/emitters/ui';import{emitScrollEvents}from'@shopgate/pwa-common/streams/view';import{MODAL_EVENTS}from'@shopgate/pwa-common/components/ModalContainer';import{ViewContext}from"./context";/**
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:false};// Last view active element
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/index.js CHANGED
@@ -1,5 +1,3 @@
1
- /** @module core */ // --------------- 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";
@@ -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
- * @returns {JSX}
5
- */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.open=openSheet;
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
- * @return {JSX}
4
- */export 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)));}
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};
@@ -4,4 +4,4 @@ import _isEmpty from"lodash/isEmpty";import _every from"lodash/every";import Rea
4
4
  * @param {Object} props.hours The store's opening hours.
5
5
  * @param {boolean} props.pure Whether to render the opening hours without any wrapper components
6
6
  * @returns {JSX.Element}
7
- */export function StoreOpeningHours(_ref){var hours=_ref.hours,pure=_ref.pure;if(!hours||_every(hours,_isEmpty)){return null;}var storeHours=React.createElement("div",{className:openingHours},getWeekDaysOrder().map(function(weekDay){return React.createElement(StoreOpeningHoursLine,{hours:hours[weekDay],day:weekDay,key:weekDay});}));if(pure){return storeHours;}return React.createElement(StoreDetailsLine,{icon:TimeIcon},React.createElement(I18n.Text,{string:"locations.hours_details",className:detailsSecondary}),storeHours);}StoreOpeningHours.defaultProps={hours:null,pure:false};
7
+ */export function StoreOpeningHours(_ref){var hours=_ref.hours,pure=_ref.pure;if(!hours||_every(hours,_isEmpty)){return null;}var storeHours=React.createElement("tbody",{className:openingHours},getWeekDaysOrder().map(function(weekDay){return React.createElement(StoreOpeningHoursLine,{hours:hours[weekDay],day:weekDay,key:weekDay});}));if(pure){return storeHours;}return React.createElement(StoreDetailsLine,{icon:TimeIcon},React.createElement(I18n.Text,{string:"locations.hours_details",className:detailsSecondary}),React.createElement("table",null,storeHours));}StoreOpeningHours.defaultProps={hours:null,pure:false};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.25.0-beta.5",
3
+ "version": "7.25.0",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,12 +16,12 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@shopgate/native-modules": "^1.0.0-beta.22",
19
- "@shopgate/pwa-common": "7.25.0-beta.5",
20
- "@shopgate/pwa-common-commerce": "7.25.0-beta.5",
21
- "@shopgate/pwa-core": "7.25.0-beta.5",
22
- "@shopgate/pwa-ui-ios": "7.25.0-beta.5",
23
- "@shopgate/pwa-ui-material": "7.25.0-beta.5",
24
- "@shopgate/pwa-ui-shared": "7.25.0-beta.5",
19
+ "@shopgate/pwa-common": "7.25.0",
20
+ "@shopgate/pwa-common-commerce": "7.25.0",
21
+ "@shopgate/pwa-core": "7.25.0",
22
+ "@shopgate/pwa-ui-ios": "7.25.0",
23
+ "@shopgate/pwa-ui-material": "7.25.0",
24
+ "@shopgate/pwa-ui-shared": "7.25.0",
25
25
  "@stripe/react-stripe-js": "^1.16.5",
26
26
  "@stripe/stripe-js": "^1.3.1",
27
27
  "@virtuous/conductor": "~2.5.0",
@@ -14,7 +14,7 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
14
14
  * @return {React.Component|null}
15
15
  */_defineProperty(_this2,"renderAvailability",function(value){var _this2$props=_this2.props,fulfillmentMethods=_this2$props.fulfillmentMethods,isFetching=_this2$props.isFetching;if(fulfillmentMethods||isFetching){return null;}var selection=_extends({},_this2.props.selection,_defineProperty({},_this2.props.charId,value));return React.createElement(VariantAvailability,{characteristics:selection,productId:_this2.props.productId});});return _this2;}_inherits(CharacteristicSheet,_PureComponent);return _createClass(CharacteristicSheet,[{key:"render",value:/**
16
16
  * @return {JSX}
17
- */function render(){var _this3=this;var _this$props=this.props,items=_this$props.items,label=_this$props.label,open=_this$props.open,selectedValue=_this$props.selectedValue,contextRef=_this$props.contextRef;var selectedIndex;if(selectedValue){selectedIndex=items.findIndex(function(item){return item.id===selectedValue;});}else{selectedIndex=items.findIndex(function(item){return item.selectable;});}return React.createElement(Fragment,null,React.createElement(ResponsiveContainer,{appAlways:true,breakpoint:"xs"},React.createElement(SheetDrawer,{title:label,isOpen:open,onClose:this.onClose,onDidOpen:this.onDidOpen},React.createElement(SheetList,{className:"theme__product__characteristic__sheet"},items.map(function(item,index){return React.createElement(Item,{item:item,key:item.id,onClick:_this3.handleItemClick,rightComponent:function rightComponent(){return _this3.renderAvailability(item.id);},selected:item.id===selectedValue,ref:index===selectedIndex?_this3.firstSelectableItemRef:null,characteristics:_extends({},_this3.props.selection,_defineProperty({},_this3.props.charId,item.id))});})))),React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement(ThemeContext.Consumer,null,function(_ref){var contextProps=_extends({},(_objectDestructuringEmpty(_ref),_ref));return React.createElement(Menu,{isOpen:open,onClose:_this3.onClose,contextRef:contextRef},React.createElement(ThemeContext.Provider,{value:contextProps},items.map(function(item,index){return React.createElement(Item,{key:item.id,item:item,onClick:_this3.handleItemClick,rightComponent:function rightComponent(){return _this3.renderAvailability(item.id);},selected:item.id===selectedValue,ref:index===selectedIndex?_this3.firstSelectableItemRef:null,characteristics:_extends({},_this3.props.selection,_defineProperty({},_this3.props.charId,item.id))});})));})));}}]);}(PureComponent);/**
17
+ */function render(){var _this3=this;var _this$props=this.props,items=_this$props.items,label=_this$props.label,open=_this$props.open,selectedValue=_this$props.selectedValue,contextRef=_this$props.contextRef,onDidClose=_this$props.onDidClose;var selectedIndex;if(selectedValue){selectedIndex=items.findIndex(function(item){return item.id===selectedValue;});}else{selectedIndex=items.findIndex(function(item){return item.selectable;});}return React.createElement(Fragment,null,React.createElement(ResponsiveContainer,{appAlways:true,breakpoint:"xs"},React.createElement(SheetDrawer,{title:label,isOpen:open,onClose:this.onClose,onDidOpen:this.onDidOpen,onDidClose:onDidClose},React.createElement(SheetList,{className:"theme__product__characteristic__sheet"},items.map(function(item,index){return React.createElement(Item,{item:item,key:item.id,onClick:_this3.handleItemClick,rightComponent:function rightComponent(){return _this3.renderAvailability(item.id);},selected:item.id===selectedValue,ref:index===selectedIndex?_this3.firstSelectableItemRef:null,characteristics:_extends({},_this3.props.selection,_defineProperty({},_this3.props.charId,item.id))});})))),React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement(ThemeContext.Consumer,null,function(_ref){var contextProps=_extends({},(_objectDestructuringEmpty(_ref),_ref));return React.createElement(Menu,{isOpen:open,onClose:_this3.onClose,contextRef:contextRef},React.createElement(ThemeContext.Provider,{value:contextProps},items.map(function(item,index){return React.createElement(Item,{key:item.id,item:item,onClick:_this3.handleItemClick,rightComponent:function rightComponent(){return _this3.renderAvailability(item.id);},selected:item.id===selectedValue,ref:index===selectedIndex?_this3.firstSelectableItemRef:null,characteristics:_extends({},_this3.props.selection,_defineProperty({},_this3.props.charId,item.id))});})));})));}}]);}(PureComponent);/**
18
18
  * @param {Object} props The original component props.
19
19
  * @returns {JSX}
20
- */_defineProperty(CharacteristicSheet,"defaultProps",{fulfillmentMethods:null,onClose:function onClose(){},onSelect:function onSelect(){},productId:null,selectedValue:null,contextRef:null,selection:null,isFetching:false});var SheetComponent=function SheetComponent(props){return React.createElement(ViewContext.Consumer,null,function(_ref2){var setAriaHidden=_ref2.setAriaHidden;return React.createElement(ProductContext.Consumer,null,function(_ref3){var productId=_ref3.productId,fulfillmentMethods=_ref3.fulfillmentMethods,isFetching=_ref3.isFetching;return React.createElement(VariantContext.Consumer,null,function(_ref4){var characteristics=_ref4.characteristics;return React.createElement(CharacteristicSheet,_extends({productId:productId,selection:characteristics,setViewAriaHidden:setAriaHidden,fulfillmentMethods:fulfillmentMethods,isFetching:isFetching},props));});});});};export default SheetComponent;
20
+ */_defineProperty(CharacteristicSheet,"defaultProps",{fulfillmentMethods:null,onClose:function onClose(){},onSelect:function onSelect(){},onDidClose:function onDidClose(){},productId:null,selectedValue:null,contextRef:null,selection:null,isFetching:false});var SheetComponent=function SheetComponent(props){return React.createElement(ViewContext.Consumer,null,function(_ref2){var setAriaHidden=_ref2.setAriaHidden;return React.createElement(ProductContext.Consumer,null,function(_ref3){var productId=_ref3.productId,fulfillmentMethods=_ref3.fulfillmentMethods,isFetching=_ref3.isFetching;return React.createElement(VariantContext.Consumer,null,function(_ref4){var characteristics=_ref4.characteristics;return React.createElement(CharacteristicSheet,_extends({productId:productId,selection:characteristics,setViewAriaHidden:setAriaHidden,fulfillmentMethods:fulfillmentMethods,isFetching:isFetching},props));});});});};export default SheetComponent;
@@ -7,7 +7,8 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
7
7
  * @param {Object} event The event object.
8
8
  */_defineProperty(_this2,"handleButtonClick",function(event){event.preventDefault();if(_this2.props.disabled){return;}_this2.setState({sheet:true});});/**
9
9
  * @param {string} valueId The ID of the selected value.
10
- */_defineProperty(_this2,"handleItemSelection",function(valueId){_this2.props.select({id:_this2.props.id,value:valueId});_this2.closeSheet();});_defineProperty(_this2,"closeSheet",function(){_this2.setState({sheet:false});if(_this2.props.charRef&&_this2.props.charRef.current){_this2.props.charRef.current.focus();}});_defineProperty(_this2,"removeHighlight",function(){_this2.setState({highlight:false});});/**
10
+ */_defineProperty(_this2,"handleItemSelection",function(valueId){_this2.props.select({id:_this2.props.id,value:valueId});_this2.closeSheet();});_defineProperty(_this2,"closeSheet",function(){_this2.setState({sheet:false});});_defineProperty(_this2,"sheetDidClose",function(){if(_this2.props.charRef&&_this2.props.charRef.current){// Focus the element that triggered the CharacteristicsSheet after it closes
11
+ _this2.props.charRef.current.focus();}});_defineProperty(_this2,"removeHighlight",function(){_this2.setState({highlight:false});});/**
11
12
  * Renders the transition contents.
12
13
  * @param {string} state The current transition state.
13
14
  * @returns {JSX}
@@ -15,4 +16,4 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
15
16
  * @param {Object} nextProps The next component props.
16
17
  */function UNSAFE_componentWillReceiveProps(nextProps){this.setState({highlight:nextProps.highlight});}},{key:"render",value:/**
17
18
  * @return {JSX}
18
- */function render(){var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var _this$props=this.props,id=_this$props.id,selected=_this$props.selected,values=_this$props.values,charRef=_this$props.charRef;var displayLabel=this.props.label;var translatedLabel=__('product.pick_an_attribute',[displayLabel]);return React.createElement(Fragment,null,React.createElement(Transition,{"in":this.state.highlight,timeout:500,onEntered:this.removeHighlight},this.transitionRenderer),React.createElement(Sheet,{charId:id,contextRef:charRef,items:values,label:translatedLabel,onClose:this.closeSheet,onSelect:this.handleItemSelection,open:this.state.sheet,selectedValue:selected}));}}]);}(PureComponent);_defineProperty(Characteristic,"contextTypes",{i18n:PropTypes.func});_defineProperty(Characteristic,"defaultProps",{selected:null});export default Characteristic;
19
+ */function render(){var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var _this$props=this.props,id=_this$props.id,selected=_this$props.selected,values=_this$props.values,charRef=_this$props.charRef;var displayLabel=this.props.label;var translatedLabel=__('product.pick_an_attribute',[displayLabel]);return React.createElement(Fragment,null,React.createElement(Transition,{"in":this.state.highlight,timeout:500,onEntered:this.removeHighlight},this.transitionRenderer),React.createElement(Sheet,{charId:id,contextRef:charRef,items:values,label:translatedLabel,onClose:this.closeSheet,onDidClose:this.sheetDidClose,onSelect:this.handleItemSelection,open:this.state.sheet,selectedValue:selected}));}}]);}(PureComponent);_defineProperty(Characteristic,"contextTypes",{i18n:PropTypes.func});_defineProperty(Characteristic,"defaultProps",{selected:null});export default Characteristic;
@@ -7,4 +7,4 @@ try{// encode SVG string to UTF-8 byte array to handle non-Latin1 characters
7
7
  // (e.g. Unicode characters like emojis)
8
8
  var utf8Encoder=new TextEncoder();var svgBytes=utf8Encoder.encode(modalImageSVG);// Convert the byte array to a Base64 string
9
9
  var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return pushImage;}},[modalImageSVG,modalImageURL]);// Button event handlers are throttled to prevent multiple clicks
10
- var handleAllowPushOptIn=useCallback(throttle(allowPushOptIn,1000,{leading:true,trailing:false}),[]);var handleDenyPushOptIn=useCallback(throttle(denyPushOptIn,1000,{leading:true,trailing:false}),[]);if(!isPushOptInModalVisible){return null;}return React.createElement(Modal,{isOpened:isPushOptInModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{className:classNames(styles.container,'push-opt-in-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"pushOptInDialogTitle","aria-describedby":"pushOptInDialogMessage"},React.createElement(Grid.Item,{className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'push-opt-in-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'push-opt-in-modal__title'),string:modalTitle||'pushOptInModal.title',id:"pushOptInDialogTitle"}),React.createElement(I18n.Text,{className:classNames('push-opt-in-modal__message'),string:modalMessage||'pushOptInModal.message',id:"pushOptInDialogMessage"}),React.createElement(Button,{onClick:handleAllowPushOptIn,type:"primary",className:classNames(styles.button,'push-opt-in-modal__button-allow')},React.createElement(I18n.Text,{string:modalButtonAllow||'pushOptInModal.buttonAllow'})),React.createElement(Button,{onClick:handleDenyPushOptIn,type:"plain",className:classNames(styles.button,'push-opt-in-modal__button-deny')},React.createElement(I18n.Text,{string:modalButtonDeny||'pushOptInModal.buttonDeny',className:styles.buttonText})))));};export default connect(PushOptInModal);
10
+ var handleAllowPushOptIn=useCallback(throttle(allowPushOptIn,1000,{leading:true,trailing:false}),[]);var handleDenyPushOptIn=useCallback(throttle(denyPushOptIn,1000,{leading:true,trailing:false}),[]);if(!isPushOptInModalVisible){return null;}return React.createElement(Modal,{classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{className:classNames(styles.container,'push-opt-in-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"pushOptInDialogTitle","aria-describedby":"pushOptInDialogMessage"},React.createElement(Grid.Item,{className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'push-opt-in-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'push-opt-in-modal__title'),string:modalTitle||'pushOptInModal.title',id:"pushOptInDialogTitle"}),React.createElement(I18n.Text,{className:classNames('push-opt-in-modal__message'),string:modalMessage||'pushOptInModal.message',id:"pushOptInDialogMessage"}),React.createElement(Button,{onClick:handleAllowPushOptIn,type:"primary",className:classNames(styles.button,'push-opt-in-modal__button-allow')},React.createElement(I18n.Text,{string:modalButtonAllow||'pushOptInModal.buttonAllow'})),React.createElement(Button,{onClick:handleDenyPushOptIn,type:"plain",className:classNames(styles.button,'push-opt-in-modal__button-deny')},React.createElement(I18n.Text,{string:modalButtonDeny||'pushOptInModal.buttonDeny',className:styles.buttonText})))));};export default connect(PushOptInModal);
@@ -5,7 +5,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj
5
5
  * @param {Object} subscriptionParams Params from the subscription callback
6
6
  * @param {string} configKey The "pushOptIn" key to be used
7
7
  * @param {Function} increaseCountAction Action to increase the count in Redux for the configKey
8
- * @returns {void}
8
+ * @returns {Promise<void>}
9
9
  */var showOptInAfterChecks=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2,configKey,increaseCountAction){var dispatch,getState,_appConfig$pushOptIn,_appConfig$pushOptIn2,appStarts,ordersPlaced,rejectionMaxCount,minDaysBetweenOptIns,_ref4,pushStatus,state,configValue,resetAction,resetCountState,configCountState,mustShowModal,hasRepeats,minDaysElapsed,meta;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref2.dispatch,getState=_ref2.getState;if(appSupportsPushOptIn()){_context.next=3;break;}return _context.abrupt("return");case 3:_appConfig$pushOptIn=appConfig.pushOptIn,_appConfig$pushOptIn2=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn,appStarts=_appConfig$pushOptIn2.appStarts,ordersPlaced=_appConfig$pushOptIn2.ordersPlaced,rejectionMaxCount=_appConfig$pushOptIn2.rejectionMaxCount,minDaysBetweenOptIns=_appConfig$pushOptIn2.minDaysBetweenOptIns;// Deactivate feature when config is invalid
10
10
  if(!(typeof minDaysBetweenOptIns!=='number'||typeof rejectionMaxCount!=='number'||_typeof(ordersPlaced)!=='object'||_typeof(appStarts)!=='object')){_context.next=7;break;}logger.error('PushOptInTrigger - Config invalid',appConfig===null||appConfig===void 0?void 0:appConfig.pushOptIn);return _context.abrupt("return");case 7:_context.next=9;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 9:_ref4=_context.sent;pushStatus=_ref4.status;if(!(pushStatus!==PERMISSION_STATUS_NOT_DETERMINED)){_context.next=13;break;}return _context.abrupt("return");case 13:dispatch(increaseCountAction());state=getPushOptInTriggerState(getState());configValue=appStarts;resetAction=resetAppStartCount;resetCountState=state.appStartResetCount;configCountState=state.appStartCount;if(configKey==='ordersPlaced'){configValue=ordersPlaced;resetAction=resetOrdersPlacedCount;resetCountState=state.ordersPlacedResetCount;configCountState=state.ordersPlacedCount;}if(!(state.rejectionCount>=rejectionMaxCount)){_context.next=22;break;}return _context.abrupt("return");case 22:mustShowModal=Number(configValue.value)>0&&configCountState>=configValue.value;hasRepeats=configValue.repeats===null||resetCountState<=configValue.repeats;minDaysElapsed=Date.now()-new Date(state.lastPopupAt)>=minDaysBetweenOptIns*DAY_IN_MS;if(mustShowModal&&hasRepeats&&minDaysElapsed){meta=getPushOptInTrackingMeta(getState());dispatch(softOptInShown({meta:meta}));dispatch(setLastPopupTimestamp());dispatch(resetAction());dispatch(showPushOptInModal(configKey));}case 26:case"end":return _context.stop();}},_callee);}));return function showOptInAfterChecks(_x,_x2,_x3){return _ref3.apply(this,arguments);};}();// event subscriber to handle app start based push opt in
11
11
  subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5){var dispatch,getState;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:dispatch=_ref5.dispatch,getState=_ref5.getState;_context2.next=3;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'appStarts',increaseAppStartCount);case 3:case"end":return _context2.stop();}},_callee2);}));return function(_x4){return _ref6.apply(this,arguments);};}());// event subscriber to handle order based push opt in
@@ -7,4 +7,4 @@ try{// encode SVG string to UTF-8 byte array to handle non-Latin1 characters
7
7
  // (e.g. Unicode characters like emojis)
8
8
  var utf8Encoder=new TextEncoder();var svgBytes=utf8Encoder.encode(modalImageSVG);// Convert the byte array to a Base64 string
9
9
  var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return cookieImage;}},[modalImageSVG,modalImageURL]);// Button event handlers are throttled to prevent multiple clicks
10
- var handleAcceptAllCookies=useCallback(throttle(acceptAllCookies,1000,{leading:true,trailing:false}),[]);var handleAcceptRequiredCookies=useCallback(throttle(acceptRequiredCookies,1000,{leading:true,trailing:false}),[]);var handleOpenPrivacySettings=useCallback(throttle(openPrivacySettings,1000,{leading:true,trailing:false}),[]);if(!isCookieConsentModalVisible){return null;}return React.createElement(Modal,{isOpened:isCookieConsentModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{component:"div",className:classNames(styles.container,'cookie-consent-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"cookieConsentDialogTitle","aria-describedby":"cookieConsentDialogMessage"},React.createElement(Grid.Item,{component:"div",className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'cookie-consent-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'cookie-consent-modal__title'),string:modalTitle||'cookieConsentModal.title',id:"cookieConsentDialogTitle"}),React.createElement(I18n.Text,{string:modalMessage||'cookieConsentModal.message',className:classNames('cookie-consent-modal__message'),acceptPlainTextWithPlaceholders:true,id:"cookieConsentDialogMessage"},React.createElement(I18n.Placeholder,{forKey:"privacyLink"},React.createElement(ConditionalWrapper,{condition:!!privacyPolicyLink,wrapper:function wrapper(children){return React.createElement(Link,{href:privacyPolicyLink,tag:"span"},children);}},React.createElement(I18n.Text,{string:"cookieConsentModal.privacyText",className:styles.link})))),React.createElement(Grid.Item,{component:"div",className:styles.buttonWrapper},React.createElement(Button,{onClick:handleAcceptAllCookies,type:"primary",className:classNames(styles.button,'cookie-consent-modal__button-accept-all')},React.createElement(I18n.Text,{string:modalButtonAcceptAll||'cookieConsentModal.buttonAcceptAll'})),showRequiredCookiesButton?React.createElement(Button,{onClick:handleAcceptRequiredCookies,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-accept-required')},React.createElement(I18n.Text,{string:modalButtonOnlyRequired||'cookieConsentModal.modalButtonOnlyRequired'})):null,React.createElement(Button,{onClick:handleOpenPrivacySettings,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-open-settings')},React.createElement(I18n.Text,{string:modalButtonConfigureSettings||'cookieConsentModal.buttonConfigure'}))))));};CookieConsentModal.defaultProps={privacyPolicyLink:null};export default connect(CookieConsentModal);
10
+ var handleAcceptAllCookies=useCallback(throttle(acceptAllCookies,1000,{leading:true,trailing:false}),[]);var handleAcceptRequiredCookies=useCallback(throttle(acceptRequiredCookies,1000,{leading:true,trailing:false}),[]);var handleOpenPrivacySettings=useCallback(throttle(openPrivacySettings,1000,{leading:true,trailing:false}),[]);if(!isCookieConsentModalVisible){return null;}return React.createElement(Modal,{classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{component:"div",className:classNames(styles.container,'cookie-consent-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"cookieConsentDialogTitle","aria-describedby":"cookieConsentDialogMessage"},React.createElement(Grid.Item,{component:"div",className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'cookie-consent-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'cookie-consent-modal__title'),string:modalTitle||'cookieConsentModal.title',id:"cookieConsentDialogTitle"}),React.createElement(I18n.Text,{string:modalMessage||'cookieConsentModal.message',className:classNames('cookie-consent-modal__message'),acceptPlainTextWithPlaceholders:true,id:"cookieConsentDialogMessage"},React.createElement(I18n.Placeholder,{forKey:"privacyLink"},React.createElement(ConditionalWrapper,{condition:!!privacyPolicyLink,wrapper:function wrapper(children){return React.createElement(Link,{href:privacyPolicyLink,tag:"span"},children);}},React.createElement(I18n.Text,{string:"cookieConsentModal.privacyText",className:styles.link})))),React.createElement(Grid.Item,{component:"div",className:styles.buttonWrapper},React.createElement(Button,{onClick:handleAcceptAllCookies,type:"primary",className:classNames(styles.button,'cookie-consent-modal__button-accept-all')},React.createElement(I18n.Text,{string:modalButtonAcceptAll||'cookieConsentModal.buttonAcceptAll'})),showRequiredCookiesButton?React.createElement(Button,{onClick:handleAcceptRequiredCookies,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-accept-required')},React.createElement(I18n.Text,{string:modalButtonOnlyRequired||'cookieConsentModal.modalButtonOnlyRequired'})):null,React.createElement(Button,{onClick:handleOpenPrivacySettings,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-open-settings')},React.createElement(I18n.Text,{string:modalButtonConfigureSettings||'cookieConsentModal.buttonConfigure'}))))));};CookieConsentModal.defaultProps={privacyPolicyLink:null};export default connect(CookieConsentModal);